Skip to content

Commit 28d34b6

Browse files
committed
Add nightly build ci
1 parent 3b20d48 commit 28d34b6

File tree

2 files changed

+207
-2
lines changed

2 files changed

+207
-2
lines changed
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
name: Jan Build Electron App
2+
3+
on:
4+
schedule:
5+
- cron: '0 17 * * *' # At 5 PM UTC, which is 12 AM UTC+7
6+
7+
workflow_dispatch:
8+
inputs:
9+
branch:
10+
description: 'Branch to build'
11+
required: true
12+
default: 'main'
13+
14+
jobs:
15+
build-macos:
16+
runs-on: macos-latest
17+
environment: production
18+
permissions:
19+
contents: write
20+
steps:
21+
- name: Getting the repo
22+
uses: actions/checkout@v3
23+
24+
- name: Installing node
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: 20
28+
29+
- name: Install jq
30+
uses: dcarbone/[email protected]
31+
32+
- name: Get tag
33+
id: tag
34+
uses: dawidd6/action-get-tag@v1
35+
36+
- name: Update app version based on latest release tag with build number
37+
id: version_update
38+
run: |
39+
# Get the latest release tag from GitHub API
40+
LATEST_TAG=$(curl -s https://api.github.com/repos/owner/repo/releases/latest | jq -r .tag_name)
41+
42+
# Check if the tag is valid
43+
if [[ ! "$LATEST_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
44+
echo "Error: Latest tag is not valid!"
45+
exit 1
46+
fi
47+
48+
# Remove the 'v' and append the build number to the version
49+
NEW_VERSION="${LATEST_TAG#v}.${GITHUB_RUN_NUMBER}"
50+
echo "New version: $NEW_VERSION"
51+
52+
# Update the version in electron/package.json
53+
jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
54+
mv /tmp/package.json electron/package.json
55+
echo "::set-output name=new_version::$NEW_VERSION"
56+
57+
- name: Get Cer for code signing
58+
run: base64 -d <<< "$CODE_SIGN_P12_BASE64" > /tmp/codesign.p12
59+
shell: bash
60+
env:
61+
CODE_SIGN_P12_BASE64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
62+
63+
- uses: apple-actions/import-codesign-certs@v2
64+
continue-on-error: true
65+
with:
66+
p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
67+
p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
68+
69+
- name: Build and publish app
70+
run: |
71+
make build
72+
env:
73+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
CSC_LINK: "/tmp/codesign.p12"
75+
CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
76+
CSC_IDENTITY_AUTO_DISCOVERY: "true"
77+
APPLE_ID: ${{ secrets.APPLE_ID }}
78+
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
79+
APP_PATH: "."
80+
DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }}
81+
82+
- name: Upload Artifact
83+
uses: actions/upload-artifact@v2
84+
with:
85+
name: ${{ steps.version_update.outputs.new_version }}
86+
path: ./electron/dist/*.dmg
87+
88+
build-windows-x64:
89+
runs-on: windows-latest
90+
permissions:
91+
contents: write
92+
steps:
93+
- name: Getting the repo
94+
uses: actions/checkout@v3
95+
96+
- name: Installing node
97+
uses: actions/setup-node@v1
98+
with:
99+
node-version: 20
100+
101+
- name: Install jq
102+
uses: dcarbone/[email protected]
103+
104+
- name: Get tag
105+
id: tag
106+
uses: dawidd6/action-get-tag@v1
107+
108+
- name: Update app version base on tag
109+
id: version_update
110+
shell: bash
111+
run: |
112+
# Get the latest release tag from GitHub API
113+
LATEST_TAG=$(curl -s https://api.github.com/repos/owner/repo/releases/latest | jq -r .tag_name)
114+
115+
# Check if the tag is valid
116+
if [[ ! "$LATEST_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
117+
echo "Error: Latest tag is not valid!"
118+
exit 1
119+
fi
120+
121+
# Remove the 'v' and append the build number to the version
122+
NEW_VERSION="${LATEST_TAG#v}.${GITHUB_RUN_NUMBER}"
123+
echo "New version: $NEW_VERSION"
124+
125+
# Update the version in electron/package.json
126+
jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
127+
mv /tmp/package.json electron/package.json
128+
129+
echo "::set-output name=new_version::$NEW_VERSION"
130+
131+
- name: Build app
132+
shell: cmd
133+
run: |
134+
make build
135+
136+
- name: Windows Code Sign with AzureSignTool
137+
run: |
138+
dotnet tool install --global AzureSignTool
139+
cd ./electron/dist
140+
azuresigntool.exe sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.globalsign.com/tsa/r6advanced1 -v "jan-win-x64-${{ steps.version_update.outputs.new_version }}.exe"
141+
142+
- name: Upload Artifact
143+
uses: actions/upload-artifact@v2
144+
with:
145+
name: ${{ steps.version_update.outputs.new_version }}
146+
path: ./electron/dist/*.exe
147+
148+
build-linux-x64:
149+
runs-on: ubuntu-latest
150+
environment: production
151+
env:
152+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
153+
permissions:
154+
contents: write
155+
steps:
156+
- name: Getting the repo
157+
uses: actions/checkout@v3
158+
159+
- name: Installing node
160+
uses: actions/setup-node@v1
161+
with:
162+
node-version: 20
163+
164+
- name: Install jq
165+
uses: dcarbone/[email protected]
166+
167+
- name: Install Snapcraft
168+
uses: samuelmeuli/action-snapcraft@v2
169+
170+
- name: Get tag
171+
id: tag
172+
uses: dawidd6/action-get-tag@v1
173+
174+
- name: Update app version base on tag
175+
id: version_update
176+
run: |
177+
# Get the latest release tag from GitHub API
178+
LATEST_TAG=$(curl -s https://api.github.com/repos/owner/repo/releases/latest | jq -r .tag_name)
179+
180+
# Check if the tag is valid
181+
if [[ ! "$LATEST_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
182+
echo "Error: Latest tag is not valid!"
183+
exit 1
184+
fi
185+
186+
# Remove the 'v' and append the build number to the version
187+
NEW_VERSION="${LATEST_TAG#v}.${GITHUB_RUN_NUMBER}"
188+
echo "New version: $NEW_VERSION"
189+
190+
# Update the version in electron/package.json
191+
jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
192+
mv /tmp/package.json electron/package.json
193+
echo "::set-output name=new_version::$NEW_VERSION"
194+
195+
- name: Build and publish app
196+
run: |
197+
make build
198+
env:
199+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
200+
201+
- name: Upload Artifact
202+
uses: actions/upload-artifact@v2
203+
with:
204+
name: ${{ steps.version_update.outputs.new_version }}
205+
path: ./electron/dist/*.deb

electron/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
"build:test:darwin": "tsc -p . && electron-builder -p never -m --dir",
5858
"build:test:win32": "tsc -p . && electron-builder -p never -w --dir",
5959
"build:test:linux": "tsc -p . && electron-builder -p never -l --dir",
60-
"build:darwin": "tsc -p . && electron-builder -p never -m",
60+
"build:darwin": "tsc -p . && electron-builder -p never -m --x64 --arm64",
6161
"build:win32": "tsc -p . && electron-builder -p never -w",
62-
"build:linux": "tsc -p . && electron-builder -p never --linux deb",
62+
"build:linux": "tsc -p . && electron-builder -p never -l deb",
6363
"build:publish": "run-script-os",
6464
"build:publish:darwin": "tsc -p . && electron-builder -p onTagOrDraft -m --x64 --arm64",
6565
"build:publish:win32": "tsc -p . && electron-builder -p onTagOrDraft -w",

0 commit comments

Comments
 (0)