Skip to content

Commit c083410

Browse files
Merge pull request #250 from Chia-Network/rc-release-process
Rc release process
2 parents ece13da + f90128d commit c083410

File tree

3 files changed

+155
-21
lines changed

3 files changed

+155
-21
lines changed

.github/workflows/auto-release-rc.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Compares the version in package.json to tags on the repo. If the tag doesn't exist, a new tag is created, which
2+
# then triggers the normal "on tag" release automation in the build job
3+
name: Auto Tag RC
4+
5+
on:
6+
push:
7+
branches:
8+
- develop
9+
10+
concurrency:
11+
group: rc-release-check
12+
13+
jobs:
14+
release-dev:
15+
name: Release rc version
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout current branch
19+
uses: actions/checkout@v4
20+
with:
21+
# Need REPO_COMMIT token so when the tag is created, the tag automation runs
22+
token: ${{ secrets.REPO_COMMIT }}
23+
fetch-depth: 0
24+
25+
- name: Setup commit signing for ChiaAutomation
26+
uses: Chia-Network/actions/commit-sign/gpg@main
27+
with:
28+
gpg_private_key: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_KEY }}
29+
passphrase: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_PASSPHRASE }}
30+
31+
- name: Check for current version tag. Create if it doesn't exist
32+
env:
33+
GH_TOKEN: ${{ github.token }}
34+
run: |
35+
stable_version=$(gh release list --limit 1 --order desc --exclude-pre-releases --json tagName --jq ".[].tagName")
36+
echo "Latest release is $stable_version"
37+
rc_version=$(gh release list --json tagName --jq ".[] | select(.tagName | test(\"${version}-rc*\")) | .tagName")
38+
echo "Latest release candidate is $rc_version"
39+
40+
if [[ -z ${rc_version} ]]; then
41+
# Extract the major, minor, and patch versions
42+
IFS='.' read -r major minor patch <<< "$stable_version"
43+
44+
# Increment the patch version
45+
new_patch=$((patch + 1))
46+
47+
# Construct the new version string
48+
version="$major.$minor.$new_patch-rc1"
49+
50+
echo "New version: $version"
51+
52+
else
53+
# Extract the major, minor, patch, and rc parts
54+
IFS='.-' read -r major minor patch rc <<< "$rc_version"
55+
56+
# Extract just the number of the rc
57+
rc_number="${rc#rc}"
58+
59+
# Increment the rc number
60+
rc_number=$((rc_number +1))
61+
62+
# Construct the new version string
63+
version="$major.$minor.$patch-rc$rc_number"
64+
65+
echo "New version: $version"
66+
67+
fi
68+
69+
if [ $(git tag -l "$version") ]; then
70+
echo "$version tag exists, deleting..."
71+
git tag -d $version
72+
git push --delete origin $version
73+
fi
74+
echo "Tag does not exist. Creating and pushing tag"
75+
rm -f CHANGELOG.md
76+
npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0
77+
changes=$(npx conventional-changelog-cli -r 1 | tail -n +2)
78+
git tag $version -m "Release $version $changes"
79+
git push origin $version

.github/workflows/build-installers.yaml

+75-20
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ on:
44
push:
55
tags:
66
- '**'
7-
branches:
8-
- refactor/refactor-base #remove this once rebuild is merged
97
pull_request:
108
branches:
119
- '**'
1210

1311
concurrency:
14-
# SHA is added to the end if on `main` to let all main workflows run
15-
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }}
12+
group: ${{ github.ref }}-${{ github.workflow }}
1613
cancel-in-progress: true
1714

1815
permissions:
@@ -27,15 +24,23 @@ jobs:
2724
name: Build Mac Installer
2825
runs-on: macos-latest
2926
steps:
30-
- uses: Chia-Network/actions/clean-workspace@main
31-
3227
- name: Checkout Code
3328
uses: actions/checkout@v4
3429

3530
- name: Setup Node 20
3631
uses: actions/setup-node@v4
3732
with:
38-
node-version: '20.10'
33+
node-version: '20.16'
34+
35+
- name: Change the package.json version if an RC tag
36+
if: startsWith(github.ref, 'refs/tags/') && contains( github.ref, '-rc')
37+
run: |
38+
echo "Github ref: $GITHUB_REF"
39+
IFS='/' read -r base directory tag <<< "$GITHUB_REF"
40+
echo "Extracted tag is $tag"
41+
42+
jq ".version = \"${tag}\"" package.json > package.tmp
43+
mv package.tmp package.json
3944
4045
- name: Install Husky
4146
run: npm install --save-dev husky
@@ -59,7 +64,7 @@ jobs:
5964
SIGNING_SECRET: "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}"
6065

6166
- name: Import Apple installer signing certificate
62-
if: steps.check_secrets.outputs.HAS_SIGNING_SECRET
67+
if: steps.check_secrets.outputs.HAS_SIGNING_SECRET && startsWith(github.ref, 'refs/tags/')
6368
uses: Apple-Actions/import-codesign-certs@v3
6469
with:
6570
p12-file-base64: ${{ secrets.APPLE_DEV_ID_APP }}
@@ -71,7 +76,7 @@ jobs:
7176
run: npm run electron:package:mac
7277

7378
- name: Notarize
74-
if: steps.check_secrets.outputs.HAS_SIGNING_SECRET
79+
if: steps.check_secrets.outputs.HAS_SIGNING_SECRET && startsWith(github.ref, 'refs/tags/')
7580
run: |
7681
DMG_FILE=$(find ${{ github.workspace }}/dist/ -type f -name '*.dmg')
7782
xcrun notarytool submit \
@@ -94,10 +99,19 @@ jobs:
9499
- name: Checkout Code
95100
uses: actions/checkout@v4
96101

97-
- name: Setup Node 20.10
102+
- name: Setup Node 20.16
98103
uses: actions/setup-node@v4
99104
with:
100-
node-version: '20.10'
105+
node-version: '20.16'
106+
107+
- name: Change the package.json version if an RC tag
108+
if: startsWith(github.ref, 'refs/tags/') && contains( github.ref, '-rc')
109+
shell: bash
110+
run: |
111+
IFS='/' read -r base directory tag <<< "$GITHUB_REF"
112+
113+
jq ".version = \"${tag}\"" package.json > package.tmp
114+
mv package.tmp package.json
101115
102116
- name: Install Husky
103117
run: npm install --save-dev husky
@@ -155,10 +169,19 @@ jobs:
155169
- name: Checkout Code
156170
uses: actions/checkout@v4
157171

158-
- name: Setup Node 20.10
172+
- name: Setup Node 20.16
159173
uses: actions/setup-node@v4
160174
with:
161-
node-version: '20.10'
175+
node-version: '20.16'
176+
177+
- name: Change the package.json version if an RC tag
178+
if: startsWith(github.ref, 'refs/tags/') && contains( github.ref, '-rc')
179+
shell: bash
180+
run: |
181+
IFS='/' read -r base directory tag <<< "$GITHUB_REF"
182+
183+
jq ".version = \"${tag}\"" package.json > package.tmp
184+
mv package.tmp package.json
162185
163186
- name: Install Husky
164187
run: npm install --save-dev husky
@@ -190,10 +213,19 @@ jobs:
190213
- name: Checkout Code
191214
uses: actions/checkout@v4
192215

193-
- name: Setup Node 20.10
216+
- name: Setup Node 20.16
194217
uses: actions/setup-node@v4
195218
with:
196-
node-version: '20.10'
219+
node-version: '20.16'
220+
221+
- name: Change the package.json version if an RC tag
222+
if: startsWith(github.ref, 'refs/tags/') && contains( github.ref, '-rc')
223+
shell: bash
224+
run: |
225+
IFS='/' read -r base directory tag <<< "$GITHUB_REF"
226+
227+
jq ".version = \"${tag}\"" package.json > package.tmp
228+
mv package.tmp package.json
197229
198230
- name: Install Husky
199231
run: npm install --save-dev husky
@@ -258,29 +290,52 @@ jobs:
258290
echo "EXE_FILE=$EXE_FILE" >>$GITHUB_ENV
259291
echo "WEB_FILE=$WEB_FILE" >>$GITHUB_ENV
260292
293+
# RC release should not be set as latest
294+
- name: Decide if release should be set as latest
295+
id: is_latest
296+
shell: bash
297+
run: |
298+
unset IS_LATEST
299+
300+
echo "Github ref is $GITHUB_REF"
301+
302+
if [[ "$GITHUB_REF" =~ "-rc" ]]; then
303+
echo "release candidate tag matched"
304+
IS_LATEST='false'
305+
IS_PRERELEASE='true'
306+
else
307+
echo "main branch release matched"
308+
IS_LATEST='true'
309+
IS_PRERELEASE='false'
310+
fi
311+
312+
echo "IS_LATEST=${IS_LATEST}" >> "$GITHUB_OUTPUT"
313+
echo "IS_PRERELEASE=${IS_PRERELEASE}" >> "$GITHUB_OUTPUT"
314+
261315
- name: Release
262-
uses: softprops/action-gh-release@v2.2.0
316+
uses: softprops/action-gh-release@v2
263317
with:
318+
prerelease: ${{steps.is_latest.outputs.IS_PRERELEASE}}
319+
make_latest: "${{steps.is_latest.outputs.IS_LATEST}}"
264320
files: |
265321
${{ env.DMG_FILE }}
266322
${{ env.DEB_FILE }}
267323
${{ env.EXE_FILE }}
268324
${{ env.WEB_FILE }}
269325
270326
- name: Get repo name
327+
if: startsWith(github.ref, 'refs/tags/') && !contains( github.ref, '-rc')
271328
id: repo-name
272329
run: |
273330
echo "REPO_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2)" >>$GITHUB_OUTPUT
274331
275332
- name: Get tag name
333+
if: startsWith(github.ref, 'refs/tags/') && !contains( github.ref, '-rc')
276334
id: tag-name
277335
run: |
278-
echo "TAGNAME=$(echo $GITHUB_REF | cut -d / -f 3)" >>$GITHUB_OUTPUT
279-
280-
- name: Gets JWT Token from GitHub
281-
uses: Chia-Network/actions/github/jwt@main
282336
283337
- name: Trigger apt repo update
338+
if: startsWith(github.ref, 'refs/tags/') && !contains( github.ref, '-rc')
284339
uses: Chia-Network/actions/github/glue@main
285340
with:
286341
json_data: '{"climate_tokenization_repo":"${{ steps.repo-name.outputs.REPO_NAME }}","application_name":"[\"${{ env.APP_NAME }}\"]","release_version":"${{ steps.tag-name.outputs.TAGNAME }}","add_debian_version":"true","arm64":"available"}'

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "climate-explorer-ui",
33
"private": true,
4-
"version": "1.2.2",
4+
"version": "1.2.3",
55
"type": "module",
66
"main": "build/main.js",
77
"engineStrict": true,

0 commit comments

Comments
 (0)