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
28 changes: 28 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ jobs:
steps:
- uses: actions/checkout@v4

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

- name: Install Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -67,6 +72,29 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- 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
92 changes: 92 additions & 0 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Publish Next Release (Manual)

on:
workflow_dispatch:
inputs:
ref:
description: Reference git commit to release (e.g. "master", "12341fa")
required: true
default: master

env:
NODE_VERSION: 18

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}

- name: AWS, credentials setup
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

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

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

- 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: Install Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

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

- name: Configure NPM
run: npm ci

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

- name: Create Github Release
uses: actions/github-script@v7
env:
GE_NEXT_VERSION: ${{ steps.next-version.outputs.result }}
INPUT_SHA: ${{ env.INPUT_SHA }}
with:
result-encoding: string
script: |
const createRelease = require('./.branch-github-actions/custom-scripts/create-release');
const sha = process.env.INPUT_SHA;
const version = process.env.GE_NEXT_VERSION;
await createRelease({
core,
context,
github,
sha,
version,
});
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ test-results.json
.direnv/
dev.config
dev.html
example.html
example.html
dist/
4 changes: 1 addition & 3 deletions deployment/deploy-qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ 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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

was looking at this more, we did this before my previous pr so i kept it in that pr. But, i dont understand the point of this so i removed it

Copy link
Contributor

Choose a reason for hiding this comment

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

how is the example page going to be uploaded in this new flow?

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like it happens in a later file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah this was deploying to prod, and also under this web-sdk prefix for some reason


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"

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

# Exit prompts
echo -en "${GREEN}Done deploy QA script ...${NC}\n"
174 changes: 0 additions & 174 deletions deployment/deploy.sh

This file was deleted.

31 changes: 31 additions & 0 deletions deployment/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

[ $# -eq 0 ] && { echo "Usage: $0 1.0.0"; exit 1; }

VERSION_NO_V=$1
VERSION="v"$VERSION_NO_V
DATE=$(date "+%Y-%m-%d")

echo "Releasing Branch Web SDK"

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

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
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
7 changes: 7 additions & 0 deletions deployment/write-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

[ $# -eq 0 ] && { echo "Usage: $0 1.0.0"; exit 1; }

sed -i -e "s/\"version\":.*$/\"version\": \"$1\",/" package.json
sed -i -e "s/version = '.*';$/version = '$1';/" src/0_config.js
sed -i -e "s/version = '.*';$/version = '$1';/" test/web-config.js
Loading
Loading