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+ });
0 commit comments