-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: bump version to 1.5.2 and update CI/CD for dev/production rele…
…ase (#46) * build: bump version to 1.5.2 and update CI/CD for dev/production release Signed-off-by: James Chien <james@numbersprotocol.io> * fix(scripts/deploy-release.sh): avoid bumping version in deploy script and reuse keys Signed-off-by: James Chien <james@numbersprotocol.io> --------- Signed-off-by: James Chien <james@numbersprotocol.io>
- Loading branch information
Showing
7 changed files
with
154 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Dev Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- release-* | ||
|
||
jobs: | ||
publish-s3: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Build the project | ||
run: npm run build | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v3 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
- name: Deploy to S3 | ||
run: sh -c scripts/deploy-staging.sh | ||
|
||
create-release: | ||
needs: [publish-s3] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
generate_release_notes: true | ||
name: Release ${{ github.ref_name }} | ||
tag_name: ${{ github.ref_name }} | ||
draft: false | ||
prerelease: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
# Variables | ||
DISTRIBUTION_ID="E1GEDS049Y53CA" | ||
FILE_PATH="dist/capture-eye.bundled.js" | ||
S3_BUCKET="numbers-static" | ||
|
||
# Define S3 keys for paths | ||
LATEST_KEY="capture-eye/release/latest/capture-eye.bundled.js" | ||
VERSION_KEY="capture-eye/release/$(npm pkg get version | tr -d \")/capture-eye.bundled.js" | ||
|
||
# CloudFront invalidation paths | ||
INVALIDATION_PATHS="/$LATEST_KEY /$VERSION_KEY" | ||
|
||
echo "Invalidation paths: $INVALIDATION_PATHS" | ||
|
||
# Upload to S3 (latest version) | ||
aws s3 cp $FILE_PATH s3://$S3_BUCKET/$LATEST_KEY | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to upload $FILE_PATH to s3://$S3_BUCKET/$LATEST_KEY" | ||
exit 1 | ||
fi | ||
echo "File uploaded to s3://$S3_BUCKET/$LATEST_KEY" | ||
|
||
# Upload to S3 (version-specific path) | ||
aws s3 cp $FILE_PATH s3://$S3_BUCKET/$VERSION_KEY | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to upload $FILE_PATH to s3://$S3_BUCKET/$VERSION_KEY" | ||
exit 1 | ||
fi | ||
echo "File uploaded to s3://$S3_BUCKET/$VERSION_KEY" | ||
|
||
# Create the invalidation | ||
INVALIDATION_ID=$(aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths $INVALIDATION_PATHS --query 'Invalidation.Id' --output text) | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to create invalidation" | ||
exit 1 | ||
fi | ||
echo "Invalidation created with ID: $INVALIDATION_ID" | ||
|
||
# Function to check the status of the invalidation | ||
check_invalidation_status() { | ||
STATUS=$(aws cloudfront get-invalidation --distribution-id $DISTRIBUTION_ID --id $INVALIDATION_ID --query 'Invalidation.Status' --output text) | ||
echo "Current status: $STATUS" | ||
} | ||
|
||
# Loop until the invalidation status is "Completed" | ||
while true; do | ||
check_invalidation_status | ||
if [ "$STATUS" = "Completed" ]; then | ||
echo "success/done" | ||
break | ||
fi | ||
# Wait for 5 seconds before checking again | ||
sleep 5 | ||
done |