1+ # GitHub Actions Workflow for Automated Releases
2+
3+ name : Automated Release Workflow
4+
5+ on :
6+ schedule :
7+ # Nightly builds at 6 PM PST every day
8+ - cron : ' 0 2 * * *'
9+ release :
10+ types :
11+ - created
12+ - published
13+
14+ jobs :
15+ nightly-build :
16+ if : github.event_name == 'schedule'
17+ runs-on : ubuntu-latest
18+ name : Nightly Build and Release
19+ steps :
20+ - name : Checkout Repository
21+ uses : actions/checkout@v4
22+
23+ - name : Set Up Node.js
24+ uses : actions/setup-node@v4
25+ with :
26+ node-version : ' lts/iron' # Specify your Node.js version
27+ registry-url : ' https://registry.npmjs.org/'
28+
29+ - name : Install Dependencies
30+ run : npm ci
31+
32+ - name : Bump Version for Nightly
33+ id : bump_version
34+ run : |
35+ PACKAGE_VERSION=$(node -p "require('./package.json').version")
36+ DATE=$(date +%Y%m%d)
37+ NIGHTLY_VERSION=$(echo $PACKAGE_VERSION | awk -F. -v OFS=. '{$NF+=1; print}')-nightly-$DATE
38+ echo "NIGHTLY_VERSION=${NIGHTLY_VERSION}" >> $GITHUB_ENV
39+
40+ - name : Update package.json
41+ run : |
42+ npm version $NIGHTLY_VERSION --no-git-tag-version
43+ git config user.name "github-actions[bot]"
44+ git config user.email "github-actions[bot]@users.noreply.github.com"
45+ git add package.json
46+ git commit -m "chore: bump version to $NIGHTLY_VERSION for nightly build"
47+
48+ - name : Push Changes
49+ uses : ad-m/github-push-action@v0.6.0
50+ with :
51+ github_token : ${{ secrets.GITHUB_TOKEN }}
52+ branch : ${{ github.ref }}
53+
54+ - name : Build Project
55+ run : npm run build:prod
56+
57+ - name : Publish Nightly to NPM
58+ run : |
59+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
60+ npm publish --access public --tag nightly
61+ env :
62+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
63+
64+ prerelease-build :
65+ if : github.event.release.prerelease == true
66+ runs-on : ubuntu-latest
67+ name : Pre-release (Beta) Build and Publish
68+ steps :
69+ - name : Checkout Repository
70+ uses : actions/checkout@v4
71+
72+ - name : Set Up Node.js
73+ uses : actions/setup-node@v4
74+ with :
75+ node-version : ' 16' # Specify your Node.js version
76+ registry-url : ' https://registry.npmjs.org/'
77+
78+ - name : Install Dependencies
79+ run : npm ci
80+
81+ - name : Build Project
82+ run : npm run build:prod
83+
84+ - name : Publish Beta to NPM
85+ run : |
86+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
87+ npm publish --access public --tag beta
88+ env :
89+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
90+
91+ stable-release-build :
92+ if : github.event.release.prerelease == false
93+ runs-on : ubuntu-latest
94+ name : Stable Release Build and Publish
95+ steps :
96+ - name : Checkout Repository
97+ uses : actions/checkout@v4
98+
99+ - name : Set Up Node.js
100+ uses : actions/setup-node@v4
101+ with :
102+ node-version : ' 16' # Specify your Node.js version
103+ registry-url : ' https://registry.npmjs.org/'
104+
105+ - name : Install Dependencies
106+ run : npm ci
107+
108+ - name : Build Project
109+ run : npm run build:prod
110+
111+ - name : Publish to NPM
112+ run : |
113+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
114+ npm publish --access public
115+ env :
116+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments