Skip to content

Commit 13b264f

Browse files
authored
feat(gha): show S3 publish path (#20)
1 parent 0acd245 commit 13b264f

4 files changed

Lines changed: 36 additions & 15 deletions

File tree

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4444
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4545
shell: bash
46-
run: ./scripts/create-release.sh true
46+
run: ./scripts/create-release.sh
4747

4848
- name: Build
4949
if: steps.create-release.outputs.released == 'true'
@@ -55,4 +55,4 @@ jobs:
5555
env:
5656
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
run: ./scripts/publish.sh "${{ steps.create-release.outputs.tag }}"
58+
run: ./scripts/publish.sh "${{ steps.create-release.outputs.tag }}" "${{ steps.build.outputs.sha256 }}"

scripts/build.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,26 @@ function sha256_hash() {
8888
fi
8989
}
9090

91+
function write_gha_outputs() {
92+
echo "size=$1" >> "$GITHUB_OUTPUT"
93+
echo "sha256=$2" >> "$GITHUB_OUTPUT"
94+
}
95+
9196
function main() {
9297
cleanup
9398
build
9499
verify_build
95100

96101
zip_size=$(ls -lh dist/lambda.zip | awk '{print $5}')
97-
zip_hash=$(sha256_hash)
102+
zip_sha256=$(sha256_hash)
98103
echo "Lambda deployment package built"
99104
echo "path=${DIST_PATH}"
100105
echo "size=${zip_size}"
101-
echo "hash=${zip_hash}"
106+
echo "sha256=${zip_sha256}"
107+
108+
if [ -n "$GITHUB_OUTPUT" ]; then
109+
write_gha_outputs "$zip_size" "$zip_sha256"
110+
fi
102111
}
103112

104113
main

scripts/create-release.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# - Create a GitHub release with semantic-release.
88
# - Output the release tag and whether a release was created.
99

10-
PUSH_TAG="${1:-false}"
1110
INITIAL_VERSION_TAG="v0.0.0"
1211

1312
# Only configure Git identity in CI environment

scripts/publish.sh

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
#!/bin/bash
22

3-
dist_path="dist"
43
tag="${1}"
4+
sha256="${2}"
5+
dist_path="dist"
56

67
if [ -z "$tag" ] || [ "$tag" = "none" ]; then
78
echo "Valid tag is required (got: '$tag')"
89
exit 1
9-
fi
10-
11-
echo "Publishing distribution artifacts to GitHub Release $tag"
12-
13-
# Ensure distribution artifacts exist. Add more files if you have them.
14-
if [ ! -d "$dist_path" ]; then
10+
elif [ -z "$sha256" ] || [ "$sha256" = "none" ]; then
11+
echo "Valid SHA256 hash is required (got: '$sha256')"
12+
exit 1
13+
elif [ ! -d "$dist_path" ]; then
1514
echo "Distribution directory $dist_path does not exist"
1615
exit 1
1716
fi
1817

19-
ls -lah "$dist_path"
18+
function publish_github_release() {
19+
# Upload distribution artifacts to GitHub Release (idempotent if re-run).
20+
echo "Publishing distribution artifacts to GitHub Release $tag"
21+
gh release upload "$tag" "$dist_path/*" --clobber
22+
}
23+
24+
function publish_s3_object() {
25+
bucket_path="lambda/lambda-application/$tag/$sha256/lambda.zip"
26+
echo "Publishing distribution artifacts to S3 bucket $bucket_path"
27+
}
28+
29+
function main() {
30+
ls -lah "$dist_path"
31+
32+
publish_github_release
33+
}
2034

21-
# Upload distribution artifacts to GitHub Release (idempotent if re-run).
22-
gh release upload "$tag" "$dist_path/*" --clobber
35+
main

0 commit comments

Comments
 (0)