Skip to content

Commit 0a2c7ac

Browse files
committed
[other] add gha deployment
1 parent 9fe08bb commit 0a2c7ac

File tree

7 files changed

+110
-177
lines changed

7 files changed

+110
-177
lines changed

.github/workflows/build-push.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ jobs:
5656
- name: upload codecov
5757
uses: codecov/codecov-action@v4
5858

59+
- name: check in whether updated build files are checked in
60+
run: |
61+
make
62+
git diff --exit-code || (echo "Please run \"make\" and commit changes to dist/build.js and dist/build.min.js" && exit 1)
63+
5964
- name: Check whether we will be able to make the release
6065
run: make release
6166

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Publish Next Release (Manual)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: Reference git commit to release (e.g. "master", "12341fa")
8+
required: true
9+
default: master
10+
11+
env:
12+
NODE_VERSION: 18
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.event.inputs.ref }}
21+
22+
- name: AWS, credentials setup
23+
uses: aws-actions/configure-aws-credentials@v4
24+
with:
25+
aws-region: us-west-1
26+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+
29+
- name: Add INPUT_SHA env var
30+
run: |
31+
export INPUT_SHA=$(git rev-parse ${{ github.event.inputs.ref }})
32+
echo "INPUT_SHA=`echo $INPUT_SHA`" >> $GITHUB_ENV
33+
34+
- name: Install branch-github-actions
35+
uses: actions/checkout@v4
36+
with:
37+
repository: BranchMetrics/branch-github-actions
38+
ref: master
39+
path: .branch-github-actions
40+
token: ${{ secrets.BRANCHLET_ACCESS_TOKEN }}
41+
42+
- name: Get next release version
43+
uses: actions/github-script@v7
44+
id: next-version
45+
with:
46+
result-encoding: string
47+
script: |
48+
const getNextVersion = require('./.branch-github-actions/custom-scripts/next-version');
49+
const nextVersion = await getNextVersion({
50+
core,
51+
github,
52+
context,
53+
sha: process.env.INPUT_SHA,
54+
});
55+
return nextVersion;
56+
env:
57+
INPUT_SHA: ${{ env.INPUT_SHA }}
58+
59+
- name: Install Node ${{ env.NODE_VERSION }}
60+
uses: actions/setup-node@v3
61+
with:
62+
node-version: ${{ env.NODE_VERSION }}
63+
64+
- name: Bump package.json version
65+
run: |
66+
sed -i -e "s/\"version\":.*$/\"version\": \"$GE_NEXT_VERSION\",/" package.json
67+
env:
68+
GE_NEXT_VERSION: ${{ steps.next-version.outputs.result }}
69+
70+
- name: Configure NPM
71+
run: npm ci
72+
73+
- name: Publish to NPM
74+
run: npm publish
75+
76+
- name: Publish to s3
77+
run: |
78+
make release
79+
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"
80+
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"
81+
aws configure set preview.cloudfront true
82+
aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js
83+
84+
- name: Create Github Release
85+
uses: actions/github-script@v7
86+
env:
87+
GE_NEXT_VERSION: ${{ steps.next-version.outputs.result }}
88+
INPUT_SHA: ${{ env.INPUT_SHA }}
89+
with:
90+
result-encoding: string
91+
script: |
92+
const createRelease = require('./.branch-github-actions/custom-scripts/create-release');
93+
const sha = process.env.INPUT_SHA;
94+
const version = process.env.GE_NEXT_VERSION;
95+
await createRelease({
96+
core,
97+
context,
98+
github,
99+
sha,
100+
version,
101+
});

deployment/deploy-qa.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ NC='\033[0m'
3333
echo -en "Invalidating cloudfront distribution for staging ...\n"
3434
aws configure set preview.cloudfront true
3535
aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-staging-latest.min.js /example-staging
36+
3637
# Exit prompts
3738
echo -en "${GREEN}Done deploy QA script ...${NC}\n"

deployment/deploy.sh

Lines changed: 0 additions & 174 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "branch-sdk",
3-
"version": "2.85.1",
3+
"version": "0.0.0",
44
"description": "Branch Metrics Deep Linking/Smart Banner Web SDK",
55
"main": "dist/build.min.js",
66
"files": [

src/0_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ var DEFAULT_API_ENDPOINT = 'https://api2.branch.io';
88
config.app_service_endpoint = 'https://app.link';
99
config.link_service_endpoint = 'https://bnc.lt';
1010
config.api_endpoint = DEFAULT_API_ENDPOINT;
11-
config.version = '2.84.0';
11+
config.version = '2.85.1';

test/web-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ goog.provide('config');
66
config.app_service_endpoint = 'https://app.link';
77
config.link_service_endpoint = 'https://bnc.lt';
88
config.api_endpoint = 'https://api.branch.io';
9-
config.version = '2.84.0';
9+
config.version = '2.85.1';

0 commit comments

Comments
 (0)