Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: ./scripts/create-release.sh true
run: ./scripts/create-release.sh

- name: Build
if: steps.create-release.outputs.released == 'true'
Expand All @@ -55,4 +55,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./scripts/publish.sh "${{ steps.create-release.outputs.tag }}"
run: ./scripts/publish.sh "${{ steps.create-release.outputs.tag }}" "${{ steps.build.outputs.sha256 }}"
13 changes: 11 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,26 @@ function sha256_hash() {
fi
}

function write_gha_outputs() {
echo "size=$1" >> "$GITHUB_OUTPUT"
echo "sha256=$2" >> "$GITHUB_OUTPUT"
}

function main() {
cleanup
build
verify_build

zip_size=$(ls -lh dist/lambda.zip | awk '{print $5}')
zip_hash=$(sha256_hash)
zip_sha256=$(sha256_hash)
echo "Lambda deployment package built"
echo "path=${DIST_PATH}"
echo "size=${zip_size}"
echo "hash=${zip_hash}"
echo "sha256=${zip_sha256}"

if [ -n "$GITHUB_OUTPUT" ]; then
write_gha_outputs "$zip_size" "$zip_sha256"
fi
}

main
1 change: 0 additions & 1 deletion scripts/create-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# - Create a GitHub release with semantic-release.
# - Output the release tag and whether a release was created.

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

# Only configure Git identity in CI environment
Expand Down
33 changes: 23 additions & 10 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
#!/bin/bash

dist_path="dist"
tag="${1}"
sha256="${2}"
dist_path="dist"

if [ -z "$tag" ] || [ "$tag" = "none" ]; then
echo "Valid tag is required (got: '$tag')"
exit 1
fi

echo "Publishing distribution artifacts to GitHub Release $tag"

# Ensure distribution artifacts exist. Add more files if you have them.
if [ ! -d "$dist_path" ]; then
elif [ -z "$sha256" ] || [ "$sha256" = "none" ]; then
echo "Valid SHA256 hash is required (got: '$sha256')"
exit 1
elif [ ! -d "$dist_path" ]; then
echo "Distribution directory $dist_path does not exist"
exit 1
fi

ls -lah "$dist_path"
function publish_github_release() {
# Upload distribution artifacts to GitHub Release (idempotent if re-run).
echo "Publishing distribution artifacts to GitHub Release $tag"
gh release upload "$tag" "$dist_path/*" --clobber
}

function publish_s3_object() {
bucket_path="lambda/lambda-application/$tag/$sha256/lambda.zip"
echo "Publishing distribution artifacts to S3 bucket $bucket_path"
}

function main() {
ls -lah "$dist_path"

publish_github_release
}

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