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 39fbda1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: upload codecov
uses: codecov/codecov-action@v4

- name: check in whether updated build files are checked in
- name: check whether updated build files are checked in
run: |
make
git diff --exit-code || (echo "Please run \"make\" and commit changes to dist/build.js and dist/build.min.js" && exit 1)
Expand Down
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
2 changes: 1 addition & 1 deletion dist/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ var config = {}, DEFAULT_API_ENDPOINT = "https://api2.branch.io";
config.app_service_endpoint = "https://app.link";
config.link_service_endpoint = "https://bnc.lt";
config.api_endpoint = DEFAULT_API_ENDPOINT;
config.version = "2.84.0";
config.version = "2.85.1";
// Input 3
var safejson = {parse:function(a) {
a = String(a);
Expand Down
8 changes: 4 additions & 4 deletions dist/build.min.js

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

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: 11 additions & 110 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,126 +27,27 @@ check_git_branch() {

check_git_branch

# update to the latest
git pull origin master

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
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

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

read -p "Tag? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git tag $VERSION
fi

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
./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 "Publish to NPM? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
npm publish
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 "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
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 "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 39fbda1

Please sign in to comment.