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+ 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+ # Remove the 'v' and append the build number to the version
43+ NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}"
44+ echo "New version: $NEW_VERSION"
45+
46+ # Update the version in electron/package.json
47+ jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
48+ mv /tmp/package.json electron/package.json
49+ echo "::set-output name=new_version::$NEW_VERSION"
50+
51+ - name : Get Cer for code signing
52+ run : base64 -d <<< "$CODE_SIGN_P12_BASE64" > /tmp/codesign.p12
53+ shell : bash
54+ env :
55+ CODE_SIGN_P12_BASE64 : ${{ secrets.CODE_SIGN_P12_BASE64 }}
56+
57+ - uses : apple-actions/import-codesign-certs@v2
58+ continue-on-error : true
59+ with :
60+ p12-file-base64 : ${{ secrets.CODE_SIGN_P12_BASE64 }}
61+ p12-password : ${{ secrets.CODE_SIGN_P12_PASSWORD }}
62+
63+ - name : Build and publish app
64+ run : |
65+ make build
66+ env :
67+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
68+ CSC_LINK : " /tmp/codesign.p12"
69+ CSC_KEY_PASSWORD : ${{ secrets.CODE_SIGN_P12_PASSWORD }}
70+ CSC_IDENTITY_AUTO_DISCOVERY : " true"
71+ APPLE_ID : ${{ secrets.APPLE_ID }}
72+ APPLE_APP_SPECIFIC_PASSWORD : ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
73+ APP_PATH : " ."
74+ DEVELOPER_ID : ${{ secrets.DEVELOPER_ID }}
75+
76+ - name : Upload Artifact
77+ uses : actions/upload-artifact@v2
78+ with :
79+ name : jan-mac-x64-${{ steps.version_update.outputs.new_version }}.dmg.zip
80+ path : ./electron/dist/jan-mac-x64-${{ steps.version_update.outputs.new_version }}.dmg
81+
82+ - name : Upload Artifact
83+ uses : actions/upload-artifact@v2
84+ with :
85+ name : jan-mac-arm64-${{ steps.version_update.outputs.new_version }}.dmg.zip
86+ path : ./electron/dist/jan-mac-arm64-${{ steps.version_update.outputs.new_version }}.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+ 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+ # Remove the 'v' and append the build number to the version
112+ NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}"
113+ echo "New version: $NEW_VERSION"
114+
115+ # Update the version in electron/package.json
116+ jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
117+ mv /tmp/package.json electron/package.json
118+
119+ echo "::set-output name=new_version::$NEW_VERSION"
120+
121+ - name : Build app
122+ shell : cmd
123+ run : |
124+ make build
125+
126+ - name : Windows Code Sign with AzureSignTool
127+ run : |
128+ dotnet tool install --global AzureSignTool
129+ cd ./electron/dist
130+ 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"
131+
132+ - name : Upload Artifact
133+ uses : actions/upload-artifact@v2
134+ with :
135+ name : jan-win-x64-${{ steps.version_update.outputs.new_version }}.exe.zip
136+ path : ./electron/dist/*.exe
137+
138+ build-linux-x64 :
139+ runs-on : ubuntu-latest
140+ environment : production
141+ env :
142+ SNAPCRAFT_STORE_CREDENTIALS : ${{ secrets.SNAPCRAFT_TOKEN }}
143+ permissions :
144+ contents : write
145+ steps :
146+ - name : Getting the repo
147+ uses : actions/checkout@v3
148+
149+ - name : Installing node
150+ uses : actions/setup-node@v1
151+ with :
152+ node-version : 20
153+
154+ - name : Install jq
155+ 156+
157+ - name : Update app version base on tag
158+ id : version_update
159+ run : |
160+ # Get the latest release tag from GitHub API
161+ LATEST_TAG=$(curl -s https://api.github.com/repos/janhq/jan/releases/latest | jq -r .tag_name)
162+
163+ # Remove the 'v' and append the build number to the version
164+ NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}"
165+ echo "New version: $NEW_VERSION"
166+
167+ # Update the version in electron/package.json
168+ jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
169+ mv /tmp/package.json electron/package.json
170+ echo "::set-output name=new_version::$NEW_VERSION"
171+
172+ - name : Build and publish app
173+ run : |
174+ make build
175+ env :
176+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
177+
178+ - name : Upload Artifact
179+ uses : actions/upload-artifact@v2
180+ with :
181+ name : jan-linux-amd64-${{ steps.version_update.outputs.new_version }}.deb.zip
182+ path : ./electron/dist/*.deb
183+
184+ noti-discord :
185+ needs : [build-macos, build-windows-x64, build-linux-x64]
186+ runs-on : ubuntu-latest
187+ steps :
188+ - name : Notify Discord
189+ uses : Ilshidur/action-discord@master
190+ with :
191+ args : " Nightly build artifact: https://github.com/janhq/jan/actions/runs/${GITHUB_RUN_ID}"
192+ env :
193+ DISCORD_WEBHOOK : ${{ secrets.DISCORD_WEBHOOK }}
0 commit comments