Skip to content

Commit f3af38a

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

File tree

3 files changed

+196
-5
lines changed

3 files changed

+196
-5
lines changed
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
name: Jan Build Electron App Nightly
2+
3+
on:
4+
push:
5+
branches:
6+
- chore/nightly-build
7+
schedule:
8+
- cron: '0 17 * * *' # At 5 PM UTC, which is 12 AM UTC+7
9+
10+
workflow_dispatch:
11+
inputs:
12+
branch:
13+
description: 'Branch to build'
14+
required: true
15+
default: 'main'
16+
17+
jobs:
18+
build-macos:
19+
runs-on: macos-latest
20+
environment: production
21+
permissions:
22+
contents: write
23+
steps:
24+
- name: Getting the repo
25+
uses: actions/checkout@v3
26+
27+
- name: Installing node
28+
uses: actions/setup-node@v1
29+
with:
30+
node-version: 20
31+
32+
- name: Install jq
33+
uses: dcarbone/[email protected]
34+
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/janhq/jan/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: Update app version base on tag
105+
id: version_update
106+
shell: bash
107+
run: |
108+
# Get the latest release tag from GitHub API
109+
LATEST_TAG=$(curl -s https://api.github.com/repos/janhq/jan/releases/latest | jq -r .tag_name)
110+
111+
# Check if the tag is valid
112+
if [[ ! "$LATEST_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
113+
echo "Error: Latest tag is not valid!"
114+
exit 1
115+
fi
116+
117+
# Remove the 'v' and append the build number to the version
118+
NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}"
119+
echo "New version: $NEW_VERSION"
120+
121+
# Update the version in electron/package.json
122+
jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
123+
mv /tmp/package.json electron/package.json
124+
125+
echo "::set-output name=new_version::$NEW_VERSION"
126+
127+
- name: Build app
128+
shell: cmd
129+
run: |
130+
make build
131+
132+
- name: Windows Code Sign with AzureSignTool
133+
run: |
134+
dotnet tool install --global AzureSignTool
135+
cd ./electron/dist
136+
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"
137+
138+
- name: Upload Artifact
139+
uses: actions/upload-artifact@v2
140+
with:
141+
name: ${{ steps.version_update.outputs.new_version }}
142+
path: ./electron/dist/*.exe
143+
144+
build-linux-x64:
145+
runs-on: ubuntu-latest
146+
environment: production
147+
env:
148+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
149+
permissions:
150+
contents: write
151+
steps:
152+
- name: Getting the repo
153+
uses: actions/checkout@v3
154+
155+
- name: Installing node
156+
uses: actions/setup-node@v1
157+
with:
158+
node-version: 20
159+
160+
- name: Install jq
161+
uses: dcarbone/[email protected]
162+
163+
- name: Update app version base on tag
164+
id: version_update
165+
run: |
166+
# Get the latest release tag from GitHub API
167+
LATEST_TAG=$(curl -s https://api.github.com/repos/janhq/jan/releases/latest | jq -r .tag_name)
168+
169+
# Check if the tag is valid
170+
if [[ ! "$LATEST_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
171+
echo "Error: Latest tag is not valid!"
172+
exit 1
173+
fi
174+
175+
# Remove the 'v' and append the build number to the version
176+
NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}"
177+
echo "New version: $NEW_VERSION"
178+
179+
# Update the version in electron/package.json
180+
jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
181+
mv /tmp/package.json electron/package.json
182+
echo "::set-output name=new_version::$NEW_VERSION"
183+
184+
- name: Build and publish app
185+
run: |
186+
make build
187+
env:
188+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
189+
190+
- name: Upload Artifact
191+
uses: actions/upload-artifact@v2
192+
with:
193+
name: ${{ steps.version_update.outputs.new_version }}
194+
path: ./electron/dist/*.deb

.github/workflows/jan-electron-build.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ jobs:
182182
- name: Install jq
183183
uses: dcarbone/[email protected]
184184

185-
- name: Install Snapcraft
186-
uses: samuelmeuli/action-snapcraft@v2
187-
188185
- name: Get tag
189186
id: tag
190187
uses: dawidd6/action-get-tag@v1

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)