Skip to content

Commit

Permalink
[other] add gha for release
Browse files Browse the repository at this point in the history
Uses the github release as the source of truth. Updates the package.json and various configs with the proper version.

This means that the new versions will not be checked into the repo, but they will be deployed properly. I am not sure if that is problematic
  • Loading branch information
bredmond5 committed Nov 6, 2024
1 parent bb49881 commit 635bd62
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 124 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
INPUT_SHA: ${{ env.INPUT_SHA }}

- name: Install Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

Expand All @@ -70,16 +70,9 @@ jobs:
- name: Configure NPM
run: npm ci

- name: Publish to NPM
run: npm publish

- name: Publish to s3
- name: Release to npm, s3
run: |
make release
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --cache-control "max-age=300"
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest-${{ steps.next-version.outputs.result }}.min.js --cache-control "max-age=300"
aws configure set preview.cloudfront true
aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js
./release.sh v${{ steps.next-version.outputs.result }}
- name: Create Github Release
uses: actions/github-script@v7
Expand Down
3 changes: 0 additions & 3 deletions deployment/deploy-qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ NC='\033[0m'
./deployment/build-example-html.sh "key_live_feebgAAhbH9Tv85H5wLQhpdaefiZv5Dv" "https://api.stage.branch.io" "https://cdn.branch.io/branch-staging-latest.min.js"
aws s3 cp example.html s3://branch-cdn/example-staging.html

./deployment/build-example-html.sh "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB" "https://api2.branch.io" "https://cdn.branch.io/branch-latest.min.js"
aws s3 cp example.html s3://branch-builds/web-sdk/example.html

echo -en "${GREEN}Pushing to CDN ...${NC}\n"
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-staging-latest.min.js --cache-control "max-age=300"

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 12 additions & 109 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,126 +27,29 @@ check_git_branch() {

check_git_branch

# update to the latest
git pull origin master
sed -i -e "s/version = '.*';$/version = '$VERSION_NO_V';/" src/0_config.js
sed -i -e "s/version = '.*';$/version = '$VERSION_NO_V';/" test/web-config.js

read -p "Update CHANGELOG.md?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
vi CHANGELOG.md
git commit -am "Updated CHANGELOG.md"
fi

echo "Building files"

read -p "Update 0_config.js? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
sed -i -e "s/version = '.*';$/version = '$VERSION_NO_V';/" src/0_config.js
sed -i -e "s/version = '.*';$/version = '$VERSION_NO_V';/" test/web-config.js
fi

read -p "Update package.json? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
sed -i -e "s/\"version\":.*$/\"version\": \"$VERSION_NO_V\",/" package.json
sed -i -e "s/\"build\":.*$/\"build\": \"$VERSION_NO_V\"/" package.json
fi

read -p "Bump CHANGELOG version? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
sed -i -e "s/## \[VERSION\] - unreleased/## [$VERSION] - $DATE/" CHANGELOG.md
fi

read -p "Update bower.json? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
sed -i -e "s/\"version\":.*$/\"version\": \"$VERSION_NO_V\",/" bower.json
sed -i -e "s/\"build\":.*$/\"build\": \"$VERSION_NO_V\"/" bower.json
fi
exit 1

make release

read -p "Commit? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git add dist/build.min.js.gz
git commit -am "Tagging release $VERSION"
check_git_branch
fi
./deployment/build-example-html.sh "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB" "https://api2.branch.io" "https://cdn.branch.io/branch-latest.min.js"
aws s3 cp example.html s3://branch-builds/example.html

read -p "Tag? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git tag $VERSION
fi
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-$VERSION.min.js --acl public-read
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --acl public-read

read -p "Copy to S3? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-$VERSION.min.js --acl public-read
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --acl public-read
aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-v2.0.0.min.js --acl public-read
aws s3 cp example.html s3://branch-cdn/example.html --acl public-read
fi
echo -en "Invalidating cloudfront distribution...\n"
aws configure set preview.cloudfront true
aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js

read -p "Publish to NPM? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
npm publish
fi

read -p "Reset? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
perl -i -pe '$_ = "\n## [VERSION] - unreleased\n\n" if $. ==4' CHANGELOG.md
make clean
make
git commit -am "Resetting to HEAD"
fi

read -p "Clean up -e backup files?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm -f bower.json-e CHANGELOG.md-e package.json-e src/0_config.js-e test/web-config.js-e
fi

echo "Done script."
read -p "Have you updated the javascript version in https://github.com/BranchMetrics/documentation/edit/master/ingredients/web_sdk/_initialization.md ?" -n 1 -r
echo
npm publish

echo "Post-release sanity checks."
read -p "Can you visit https://cdn.branch.io/branch-$VERSION.min.js ?" -n 1 -r
echo
read -p "Is https://cdn.branch.io/example.html using the right version number $VERSION?" -n 1 -r
echo
read -p "Is https://www.npmjs.com/package/branch-sdk using the right version number $VERSION?" -n 1 -r
echo

echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Ok"
fi

echo "Last step, run:"
echo " git push; git push origin $VERSION"

echo
echo "Remember to check https://github.com/BranchMetrics/Smart-App-Banner-Deep-Linking-Web-SDK/tree/$VERSION/CHANGELOG.md "
echo
echo "Remember to ping @jed on slack about this release "

echo
echo

0 comments on commit 635bd62

Please sign in to comment.