Skip to content

Commit 13cac6b

Browse files
committed
ci: add github actions to build binaries
1 parent a4c31d2 commit 13cac6b

File tree

4 files changed

+342
-3
lines changed

4 files changed

+342
-3
lines changed

.github/workflows/auto-release.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
concurrency:
11+
group: main-release-check
12+
13+
jobs:
14+
check-version:
15+
name: Check version increment
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Clean workspace
19+
uses: Chia-Network/actions/clean-workspace@main
20+
21+
- name: Checkout current branch
22+
uses: actions/checkout@v3
23+
with:
24+
# Need PACKAGE_ADMIN_PAT token so when the tag is created, the tag automation runs
25+
token: ${{ secrets.PACKAGE_ADMIN_PAT }}
26+
fetch-depth: 0
27+
28+
- name: Setup commit signing for ChiaAutomation
29+
uses: Chia-Network/actions/commit-sign/gpg@main
30+
with:
31+
gpg_private_key: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_KEY }}
32+
passphrase: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_PASSPHRASE }}
33+
34+
- name: Check for current version tag. Create if it doesn't exist
35+
run: |
36+
version=$(cat $GITHUB_WORKSPACE/package.json | jq -r '.version')
37+
echo "Version is: $version"
38+
39+
if [ $(git tag -l "$version") ]; then
40+
echo "Tag exists, nothing to do"
41+
else
42+
echo "Tag does not exist. Creating and pushing tag"
43+
rm -f CHANGELOG.md
44+
npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0
45+
changes=$(npx conventional-changelog-cli -r 1 | tail -n +2)
46+
git add CHANGELOG.md
47+
sed -i -e '/<s>/d' CHANGELOG.md
48+
git commit -m "Updating changelog for $version"
49+
git tag $version -m "Release $version $changes"
50+
git push origin $version
51+
git push origin main
52+
fi
+245
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
name: Build & Release
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
tags:
8+
- '**'
9+
pull_request:
10+
branches:
11+
- '**'
12+
13+
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 || '' }}
16+
cancel-in-progress: true
17+
18+
env:
19+
APP_NAME: core-registry-ui
20+
21+
jobs:
22+
build_mac:
23+
name: Build Mac Installer
24+
runs-on: macos-latest
25+
steps:
26+
- uses: Chia-Network/actions/clean-workspace@main
27+
28+
- name: Checkout Code
29+
uses: actions/checkout@v3
30+
31+
- name: Setup Node 18.16
32+
uses: actions/setup-node@v3
33+
with:
34+
node-version: '18.16'
35+
36+
- name: Install Husky
37+
run: npm install --save-dev husky
38+
39+
- name: install dmg-license
40+
run: npm i dmg-license
41+
42+
- name: npm install and build
43+
run: |
44+
npm install
45+
npm run build
46+
47+
- name: Import Apple installer signing certificate
48+
uses: Apple-Actions/import-codesign-certs@v1
49+
with:
50+
p12-file-base64: ${{ secrets.APPLE_DEV_ID_APP }}
51+
p12-password: ${{ secrets.APPLE_DEV_ID_APP_PASS }}
52+
53+
- name: Build electron app
54+
env:
55+
CSC_FOR_PULL_REQUEST: "true"
56+
run: npm run electron:package:mac
57+
58+
- name: Notarize
59+
run: |
60+
DMG_FILE=$(find ${{ github.workspace }}/dist/ -type f -name '*.dmg')
61+
npm install -g notarize-cli
62+
notarize-cli \
63+
--file="$DMG_FILE" \
64+
--bundle-id net.chia.$APP_NAME \
65+
--username "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \
66+
--password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}"
67+
68+
- name: Upload Mac Installer
69+
uses: actions/upload-artifact@v3
70+
with:
71+
name: $APP_NAME-mac-installer
72+
path: ${{ github.workspace }}/dist/*.dmg
73+
74+
build_windows:
75+
name: Build Windows Installer
76+
runs-on: windows-2019
77+
steps:
78+
- name: Checkout Code
79+
uses: actions/checkout@v3
80+
81+
- name: Setup Node 18.16
82+
uses: actions/setup-node@v3
83+
with:
84+
node-version: '18.16'
85+
86+
- name: Install Husky
87+
run: npm install --save-dev husky
88+
89+
- name: Ignore Husky where not compatible
90+
run: npm pkg delete scripts.prepare
91+
92+
- name: npm install
93+
run: |
94+
node --version
95+
npm install
96+
97+
- name: Build electron app
98+
run: npm run electron:package:win
99+
100+
# Windows Code Signing
101+
- name: Get installer name for signing
102+
shell: bash
103+
run: |
104+
FILE=$(find dist -type f -maxdepth 1 -name '*.exe')
105+
echo "Installer file is $FILE"
106+
echo "INSTALLER_FILE=$FILE" >> "$GITHUB_ENV"
107+
108+
- name: Sign windows artifacts
109+
uses: chia-network/actions/digicert/windows-sign@main
110+
with:
111+
sm_api_key: ${{ secrets.SM_API_KEY }}
112+
sm_client_cert_file_b64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
113+
sm_client_cert_password: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
114+
sm_code_signing_cert_sha1_hash: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}
115+
file: "${{ github.workspace }}/${{ env.INSTALLER_FILE }}"
116+
117+
- name: Upload Windows Installer
118+
uses: actions/upload-artifact@v3
119+
with:
120+
name: $APP_NAME-windows-installer
121+
path: "${{ github.workspace }}/${{ env.INSTALLER_FILE }}"
122+
123+
build_linux:
124+
name: Build Linux Installer
125+
runs-on: ubuntu-latest
126+
steps:
127+
- name: Checkout Code
128+
uses: actions/checkout@v3
129+
130+
- name: Setup Node 18.16
131+
uses: actions/setup-node@v3
132+
with:
133+
node-version: '18.16'
134+
135+
- name: Install Husky
136+
run: npm install --save-dev husky
137+
138+
- name: npm install
139+
run: |
140+
node --version
141+
npm install
142+
143+
- name: Build electron app
144+
run: npm run electron:package:linux
145+
146+
- name: Rename Linux installer to be standard format for apt
147+
run: |
148+
ORIGINAL=$(ls dist/*.deb)
149+
MODIFIED=${ORIGINAL:0:-10}-1${ORIGINAL#${ORIGINAL:0:-10}}
150+
mv $ORIGINAL $MODIFIED
151+
152+
- name: Upload Linux Installer
153+
uses: actions/upload-artifact@v3
154+
with:
155+
name: $APP_NAME-linux-installer
156+
path: ${{ github.workspace }}/dist/*.deb
157+
158+
build_web:
159+
name: Build CADT UI Web App
160+
runs-on: ubuntu-latest
161+
steps:
162+
- name: Checkout Code
163+
uses: actions/checkout@v3
164+
165+
- name: Setup Node 18.16
166+
uses: actions/setup-node@v3
167+
with:
168+
node-version: '18.16'
169+
170+
- name: Install Husky
171+
run: npm install --save-dev husky
172+
173+
- name: npm install and build
174+
run: |
175+
node --version
176+
npm install
177+
npm run build
178+
179+
- name: Create .tar.gz of the web build
180+
run: tar -cvzf $APP_NAME-web-build.tar.gz build
181+
182+
- name: Upload build artifact
183+
uses: actions/upload-artifact@v3
184+
with:
185+
name: $APP_NAME-web-build
186+
path: $APP_NAME-web-build.tar.gz
187+
188+
release:
189+
runs-on: ubuntu-latest
190+
if: startsWith(github.ref, 'refs/tags/')
191+
needs:
192+
- build_mac
193+
- build_windows
194+
- build_linux
195+
- build_web
196+
steps:
197+
- name: Download Windows artifacts
198+
uses: actions/download-artifact@v3
199+
with:
200+
name: $APP_NAME-windows-installer
201+
path: $APP_NAME-windows-installer
202+
203+
- name: Download MacOS artifacts
204+
uses: actions/download-artifact@v3
205+
with:
206+
name: $APP_NAME-mac-installer
207+
path: $APP_NAME-mac-installer
208+
209+
- name: Download Linux artifacts
210+
uses: actions/download-artifact@v3
211+
with:
212+
name: $APP_NAME-linux-installer
213+
path: $APP_NAME-linux-installer
214+
215+
- name: Download Web artifact
216+
uses: actions/download-artifact@v3
217+
with:
218+
name: $APP_NAME-web-build
219+
path: $APP_NAME-web-build
220+
221+
- name: Get Filenames
222+
run: |
223+
DMG_FILE=$(find ${{ github.workspace }}/$APP_NAME-mac-installer/ -type f -name '*.dmg')
224+
DEB_FILE=$(find ${{ github.workspace }}/$APP_NAME-linux-installer/ -type f -name '*.deb')
225+
EXE_FILE=$(find ${{ github.workspace }}/$APP_NAME-windows-installer/ -type f -name '*.exe')
226+
WEB_FILE=$(find ${{ github.workspace }}/$APP_NAME-web-build/ -type f -name '*.tar.gz')
227+
228+
echo "DMG_FILE=$DMG_FILE" >>$GITHUB_ENV
229+
echo "DEB_FILE=$DEB_FILE" >>$GITHUB_ENV
230+
echo "EXE_FILE=$EXE_FILE" >>$GITHUB_ENV
231+
echo "WEB_FILE=$WEB_FILE" >>$GITHUB_ENV
232+
233+
- name: Release
234+
uses: softprops/[email protected]
235+
with:
236+
files: |
237+
${{ env.DMG_FILE }}
238+
${{ env.DEB_FILE }}
239+
${{ env.EXE_FILE }}
240+
${{ env.WEB_FILE }}
241+
242+
- name: Trigger apt repo update
243+
run: |
244+
curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"$APP_NAME","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/start
245+
curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"$APP_NAME","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/success/deploy
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow runs on any PRs that are targeting main, and ensures that the version in package.json is incremented
2+
name: Check Version Increment
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- 'main'
8+
9+
concurrency:
10+
# SHA is added to the end if on `main` to let all main workflows run
11+
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
check-version:
16+
name: Check version increment
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: Chia-Network/actions/clean-workspace@main
20+
21+
- name: Checkout current branch
22+
uses: actions/checkout@v3
23+
with:
24+
path: branch-repo
25+
26+
- name: Checkout main
27+
uses: actions/checkout@v3
28+
with:
29+
ref: main
30+
path: main-repo
31+
32+
- name: Check Versions
33+
run: |
34+
main_version=$(cat $GITHUB_WORKSPACE/main-repo/package.json | jq -r '.version')
35+
branch_version=$(cat $GITHUB_WORKSPACE/branch-repo/package.json | jq -r '.version')
36+
echo "Main version: $main_version"
37+
echo "Branch version: $branch_version"
38+
39+
if [[ "$branch_version" == "$main_version" ]]; then
40+
echo "Version in package.json on this branch is not changing. Version must incremenet for a merge to main"
41+
exit 1
42+
fi

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"vite": "^4.4.7",
3939
"vitest": "^0.33.0"
4040
},
41-
"description": "<h1 align=\"center\"> Vite Template React </h1>",
41+
"description": "Core Registry Unified User Interface",
4242
"main": "src/start.js",
43-
"author": "",
44-
"license": "ISC"
43+
"author": "Chia Network Inc. <[email protected]>",
44+
"license": "Apache-2.0"
4545
}

0 commit comments

Comments
 (0)