Skip to content

Commit 50466f8

Browse files
committed
ci: split build-app and release-app
1 parent afcbed7 commit 50466f8

File tree

2 files changed

+189
-78
lines changed

2 files changed

+189
-78
lines changed

.github/workflows/build-app.yml

Lines changed: 55 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
name: Build App
1+
name: Build App (Manual)
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to build (leave empty to use current version with commit hash)'
8+
required: false
9+
type: string
710

811
jobs:
9-
release-app:
12+
build-app:
1013
permissions:
1114
contents: write
1215
strategy:
@@ -28,6 +31,19 @@ jobs:
2831
- name: Checkout Repository
2932
uses: actions/checkout@v4
3033

34+
- name: Set version for manual trigger
35+
run: |
36+
if [ -n "${{ github.event.inputs.version }}" ]; then
37+
VERSION="${{ github.event.inputs.version }}"
38+
else
39+
# Get current version from package.json and add commit hash
40+
CURRENT_VERSION=$(node -p "require('./package.json').version")
41+
COMMIT_HASH=$(git rev-parse --short HEAD)
42+
VERSION="${CURRENT_VERSION}-${COMMIT_HASH}"
43+
fi
44+
echo "CUSTOM_VERSION=$VERSION" >> $GITHUB_ENV
45+
echo "Custom version set to: $VERSION"
46+
3147
- name: Setup Node.js
3248
uses: actions/setup-node@v4
3349
with:
@@ -54,81 +70,42 @@ jobs:
5470
- name: Install Frontend Dependencies
5571
run: pnpm install
5672

57-
- name: Import Apple Developer Certificate
58-
if: matrix.platform == 'macos-latest'
59-
# Prevents keychain from locking automatically for 3600 seconds.
60-
env:
61-
APPLE_API_KEY_CONTENT: ${{ secrets.APPLE_API_KEY_CONTENT }}
62-
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
63-
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
64-
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
65-
run: |
66-
echo $APPLE_API_KEY_CONTENT | base64 --decode > authkey.p8
67-
68-
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
69-
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
70-
security default-keychain -s build.keychain
71-
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
72-
security set-keychain-settings -t 3600 -u build.keychain
73-
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
74-
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
75-
security find-identity -v -p codesigning build.keychain
76-
77-
- name: Verify Apple Developer Certificate
78-
if: matrix.platform == 'macos-latest'
79-
run: |
80-
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
81-
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
82-
echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
83-
echo "Certificate imported."
84-
85-
- name: Build the App
73+
- name: Build the App (without signing)
74+
id: build
8675
uses: tauri-apps/tauri-action@v0
87-
env:
88-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89-
APPLE_ID: ${{ secrets.APPLE_ID }}
90-
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
91-
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
92-
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
93-
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
94-
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
95-
96-
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
97-
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
98-
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
99-
APPLE_API_KEY_PATH: authkey.p8
100-
101-
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
102-
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
10376
with:
104-
tagName: ${{ github.ref_name || 'v__VERSION__' }} # This only works if your workflow triggers on new tags.
105-
releaseName: 'DevUtility v__VERSION__' # tauri-action replaces \_\_VERSION\_\_ with the app version.
106-
releaseBody: 'See the assets to download and install this version.'
107-
releaseDraft: true
108-
prerelease: false
10977
args: ${{ matrix.args }}
110-
111-
update-changelog:
112-
runs-on: ubuntu-latest
113-
114-
permissions:
115-
contents: write
116-
117-
env:
118-
RELEASE_TAG: ${{ github.ref_name }}
119-
120-
steps:
121-
- name: Checkout code
122-
uses: actions/checkout@v4
123-
with:
124-
fetch-depth: 0
78+
includeDebug: true
12579

126-
- uses: orhun/git-cliff-action@v4
127-
id: git-cliff
128-
with:
129-
args: --latest --strip header
130-
131-
- uses: softprops/action-gh-release@v1
80+
- name: Upload build artifacts (macOS/Linux)
81+
if: matrix.platform != 'windows-latest'
82+
run: |
83+
mkdir -p artifacts
84+
paths=$(echo '${{ steps.build.outputs.artifactPaths }}' | jq -c '.[]' | sed 's/"//g')
85+
for fn in $paths; do
86+
if [[ -f $fn ]]; then
87+
echo "Copying $fn to artifacts/"
88+
cp "$fn" artifacts/
89+
fi
90+
done
91+
92+
- name: Upload build artifacts (Windows)
93+
if: matrix.platform == 'windows-latest'
94+
shell: pwsh
95+
run: |
96+
New-Item -ItemType Directory -Force -Path artifacts
97+
$jsonString = '${{ steps.build.outputs.artifactPaths }}'
98+
$filePaths = ConvertFrom-Json $jsonString
99+
foreach ($path in $filePaths) {
100+
if (Test-Path $path -PathType Leaf) {
101+
Write-Host "Copying $path to artifacts/"
102+
Copy-Item $path artifacts/
103+
}
104+
}
105+
106+
- name: Upload artifacts
107+
uses: actions/upload-artifact@v4
132108
with:
133-
body: ${{ steps.git-cliff.outputs.content }}
134-
tag_name: ${{ env.RELEASE_TAG }}
109+
name: build-artifacts-${{ matrix.platform }}-${{ env.CUSTOM_VERSION }}
110+
path: artifacts/
111+
retention-days: 30

.github/workflows/release-app.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Release App
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build-app:
10+
permissions:
11+
contents: write
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- platform: 'macos-latest' # for Arm based macs (M1 and above).
17+
args: '--target aarch64-apple-darwin'
18+
- platform: 'macos-latest' # for Intel based macs.
19+
args: '--target x86_64-apple-darwin'
20+
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
21+
args: ''
22+
- platform: 'windows-latest'
23+
args: ''
24+
25+
runs-on: ${{ matrix.platform }}
26+
27+
steps:
28+
- name: Checkout Repository
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: lts/*
35+
36+
- name: Install Rust Stable
37+
uses: dtolnay/rust-toolchain@stable
38+
with:
39+
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
40+
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
41+
42+
- uses: pnpm/action-setup@v4
43+
with:
44+
version: 10
45+
46+
- name: Install Dependencies (Ubuntu only)
47+
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
51+
# webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
52+
# You can remove the one that doesn't apply to your app to speed up the workflow a bit.
53+
54+
- name: Install Frontend Dependencies
55+
run: pnpm install
56+
57+
- name: Import Apple Developer Certificate
58+
if: matrix.platform == 'macos-latest'
59+
# Prevents keychain from locking automatically for 3600 seconds.
60+
env:
61+
APPLE_API_KEY_CONTENT: ${{ secrets.APPLE_API_KEY_CONTENT }}
62+
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
63+
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
64+
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
65+
run: |
66+
echo $APPLE_API_KEY_CONTENT | base64 --decode > authkey.p8
67+
68+
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
69+
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
70+
security default-keychain -s build.keychain
71+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
72+
security set-keychain-settings -t 3600 -u build.keychain
73+
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
74+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
75+
security find-identity -v -p codesigning build.keychain
76+
77+
- name: Verify Apple Developer Certificate
78+
if: matrix.platform == 'macos-latest'
79+
run: |
80+
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
81+
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
82+
echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
83+
echo "Certificate imported."
84+
85+
- name: Build the App
86+
uses: tauri-apps/tauri-action@v0
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
APPLE_ID: ${{ secrets.APPLE_ID }}
90+
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
91+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
92+
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
93+
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
94+
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
95+
96+
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
97+
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
98+
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
99+
APPLE_API_KEY_PATH: authkey.p8
100+
101+
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
102+
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
103+
with:
104+
tagName: ${{ github.ref_name || 'v__VERSION__' }} # This only works if your workflow triggers on new tags.
105+
releaseName: 'DevUtility v__VERSION__' # tauri-action replaces \_\_VERSION\_\_ with the app version.
106+
releaseBody: 'See the assets to download and install this version.'
107+
releaseDraft: true
108+
prerelease: false
109+
args: ${{ matrix.args }}
110+
111+
update-changelog:
112+
runs-on: ubuntu-latest
113+
114+
permissions:
115+
contents: write
116+
117+
env:
118+
RELEASE_TAG: ${{ github.ref_name }}
119+
120+
steps:
121+
- name: Checkout code
122+
uses: actions/checkout@v4
123+
with:
124+
fetch-depth: 0
125+
126+
- uses: orhun/git-cliff-action@v4
127+
id: git-cliff
128+
with:
129+
args: --latest --strip header
130+
131+
- uses: softprops/action-gh-release@v1
132+
with:
133+
body: ${{ steps.git-cliff.outputs.content }}
134+
tag_name: ${{ env.RELEASE_TAG }}

0 commit comments

Comments
 (0)