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
72 changes: 34 additions & 38 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,40 @@ jobs:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Install branch-github-actions
uses: actions/checkout@v4
with:
repository: BranchMetrics/branch-github-actions
ref: master
path: .branch-github-actions
token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }}

- name: Add INPUT_SHA env var
run: |
export INPUT_SHA=$(git rev-parse ${{ github.ref }})
echo "INPUT_SHA=`echo $INPUT_SHA`" >> $GITHUB_ENV

- name: Get next release version
uses: actions/github-script@v7
id: next-version
with:
result-encoding: string
script: |
const getNextVersion = require('./.branch-github-actions/custom-scripts/next-version');
const nextVersion = await getNextVersion({
core,
github,
context,
sha: process.env.INPUT_SHA,
});
return nextVersion;
env:
INPUT_SHA: ${{ env.INPUT_SHA }}

- name: Write version to files
run: |
./deployment/write-versions.sh ${{ steps.next-version.outputs.result }}

- name: Install dependencies
run: npm run ci

Expand Down Expand Up @@ -67,44 +101,6 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Install branch-github-actions
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/checkout@v4
with:
repository: BranchMetrics/branch-github-actions
ref: master
path: .branch-github-actions
token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }}

- name: Add INPUT_SHA env var
if: ${{ github.ref == 'refs/heads/master' }}
run: |
export INPUT_SHA=$(git rev-parse ${{ github.ref }})
echo "INPUT_SHA=`echo $INPUT_SHA`" >> $GITHUB_ENV

- name: Get next release version
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/github-script@v7
id: next-version
with:
result-encoding: string
script: |
const getNextVersion = require('./.branch-github-actions/custom-scripts/next-version');
const nextVersion = await getNextVersion({
core,
github,
context,
sha: process.env.INPUT_SHA,
});
return nextVersion;
env:
INPUT_SHA: ${{ env.INPUT_SHA }}

- name: Write version to files
if: ${{ github.ref == 'refs/heads/master' }}
run: |
./deployment/write-versions.sh ${{ steps.next-version.outputs.result }}

- name: Deploy updated builds to staging
if: ${{ github.ref == 'refs/heads/master' }}
id: build
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ jobs:
- name: Configure NPM
run: npm ci

- name: Release to npm, s3, prod
- run: make release

- name: Publish to s3
run: |
./deployment/release.sh ${{ steps.next-version.outputs.result }}
./deployment/release-s3.sh ${{ steps.next-version.outputs.result }}

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISHER_TOKEN }}
run: npm publish

- name: Create Github Release
uses: actions/github-script@v7
Expand Down
6 changes: 3 additions & 3 deletions deployment/release.sh → deployment/release-s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ make release

./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
aws s3 cp example.html s3://branch-cdn/example.html

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-$VERSION.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.min.js --cache-control "max-age=300"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this 300 days? This policy should be documented, however unlikely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

300s

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure where to document it, but i looke dat the current files in prod and they had this on the cache control


echo -en "Invalidating cloudfront distribution...\n"
aws configure set preview.cloudfront true
aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js

npm publish

echo "Post-release sanity checks."
read -p "Can you visit https://cdn.branch.io/branch-$VERSION.min.js ?" -n 1 -r
Expand Down
Loading