File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Build and Upload to S3
2
+
3
+ on :
4
+ workflow_dispatch : # Allows manual trigger
5
+
6
+ jobs :
7
+ build :
8
+ runs-on : ubuntu-latest
9
+
10
+ steps :
11
+ - name : Checkout code
12
+ uses : actions/checkout@v4
13
+
14
+ - name : Set up Python
15
+ uses : actions/setup-python@v5
16
+ with :
17
+ python-version : ' 3.x'
18
+
19
+ - name : Install build dependencies
20
+ run : pip install setuptools wheel
21
+
22
+ - name : Get latest commit hash
23
+ run : echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
24
+
25
+ - name : Build source distribution
26
+ run : python3 setup.py sdist
27
+
28
+ - name : Rename package with commit hash
29
+ run : |
30
+ FILE=$(ls dist/*.tar.gz)
31
+ BASENAME=$(basename "$FILE")
32
+ NAME="${BASENAME%.tar.gz}"
33
+ NEW_NAME="${NAME}-${COMMIT_HASH}.tar.gz"
34
+ mv "$FILE" "dist/$NEW_NAME"
35
+ echo "NEW_PACKAGE=dist/$NEW_NAME" >> $GITHUB_ENV
36
+
37
+ - name : Configure AWS credentials
38
+ uses : aws-actions/configure-aws-credentials@v3
39
+ with :
40
+ aws-access-key-id : ${{ secrets.PKG_AWS_ACCESS_KEY_ID }}
41
+ aws-secret-access-key : ${{ secrets.PKG_AWS_SECRET_ACCESS_KEY }}
42
+ aws-region : ap-south-1
43
+
44
+ - name : Upload to S3
45
+ run : |
46
+ aws s3 cp "$NEW_PACKAGE" "s3://sr-devops-public/gh-actions/"
47
+ echo "S3_URL=https://sr-devops-public.s3.ap-south-1.amazonaws.com/gh-actions/$NEW_PACKAGE" >> $GITHUB_ENV
48
+
You can’t perform that action at this time.
0 commit comments