Skip to content

Commit fc8f20a

Browse files
committed
Improve build.yml
1 parent d40eb33 commit fc8f20a

1 file changed

Lines changed: 143 additions & 80 deletions

File tree

.github/workflows/build.yml

Lines changed: 143 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,152 @@
11
name: App Builder
22
on:
3-
workflow_dispatch:
4-
push:
5-
tags:
6-
- 'v*'
3+
workflow_dispatch:
4+
push:
5+
tags:
6+
- 'v*'
77

88
env:
9-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10-
RUST_TOOLCHAIN_VERSION: 1.93.0
9+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10+
RUST_TOOLCHAIN_VERSION: 1.93.0
1111

1212
concurrency:
13-
group: ${{ github.workflow }}-${{ github.ref }}
14-
cancel-in-progress: true
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
1515
permissions:
16-
contents: write
16+
contents: write
1717

1818
jobs:
19-
publish-tauri:
20-
permissions:
21-
contents: write
22-
strategy:
23-
fail-fast: false
24-
matrix:
25-
include:
26-
# - platform: 'macos-latest'
27-
# args: '--target aarch64-apple-darwin'
28-
# - platform: 'macos-latest'
29-
# args: '--target x86_64-apple-darwin'
30-
- platform: 'ubuntu-22.04'
31-
args: ''
32-
- platform: 'windows-latest'
33-
args: ''
34-
runs-on: ${{ matrix.platform }}
35-
steps:
36-
- name: Checkout repository
37-
uses: actions/checkout@v4
38-
with:
39-
token: ${{ env.GITHUB_TOKEN }}
40-
41-
- name: Node.js setup (25.x)
42-
uses: actions/setup-node@v4
43-
with:
44-
node-version: 25.x
45-
46-
- name: install Rust stable
47-
uses: dtolnay/rust-toolchain@stable
48-
with:
49-
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
50-
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
51-
52-
- name: Install dependencies (ubuntu only)
53-
if: matrix.platform == 'ubuntu-22.04'
54-
run: |
55-
sudo apt-get update
56-
sudo apt-get install -y pkg-config libudev-dev javascriptcoregtk-4.1 libsoup-3.0 libwebkit2gtk-4.0-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev webkit2gtk-4.0 patchelf libsoup2.4-dev
57-
npm install -g pnpm
58-
npm install -g typescript
59-
60-
- name: install dependencies (windows only)
61-
if: matrix.platform == 'windows-latest'
62-
run: |
63-
npm install -g typescript
64-
npm install -g pnpm
65-
66-
- name: install dependencies (macos only)
67-
if: matrix.platform == 'macos-latest'
68-
run: |
69-
brew install pnpm
70-
71-
- name: Install frontend dependencies (PNPM)
72-
run: pnpm install --no-frozen-lockfile
73-
74-
- name: Generate Local Plugins (PNPM)
75-
run: pnpm run specta:gen
76-
77-
- uses: tauri-apps/tauri-action@v0.6.1
78-
id: tauri_build
79-
env:
80-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81-
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
82-
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
83-
with:
84-
tagName: v__VERSION__
85-
releaseName: 'ETVR-Firmware-Flashing-tool v__VERSION__'
86-
generateReleaseNotes: true
87-
includeUpdaterJson: true
88-
prerelease: ${{ contains(github.ref_name, 'beta') }}
89-
args: ${{ matrix.args }}
19+
create-release:
20+
permissions:
21+
contents: write
22+
runs-on: ubuntu-latest
23+
outputs:
24+
release_id: ${{ steps.create-release.outputs.result }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: create release
29+
id: create-release
30+
uses: actions/github-script@v8
31+
env:
32+
TAG_NAME: ${{ github.ref_name }}
33+
with:
34+
script: |
35+
const { data } = await github.rest.repos.createRelease({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
tag_name: process.env.TAG_NAME,
39+
name: `ETVR Firmware Flashing tool ${process.env.TAG_NAME}`,
40+
draft: true,
41+
generate_release_notes: true,
42+
prerelease: false
43+
})
44+
return data.id
45+
46+
build-tauri:
47+
needs: create-release
48+
permissions:
49+
contents: write
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
include:
54+
# - platform: 'macos-latest'
55+
# args: '--target aarch64-apple-darwin'
56+
# - platform: 'macos-latest'
57+
# args: '--target x86_64-apple-darwin'
58+
- platform: 'ubuntu-22.04'
59+
args: ''
60+
- platform: 'windows-latest'
61+
args: ''
62+
runs-on: ${{ matrix.platform }}
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
66+
with:
67+
token: ${{ env.GITHUB_TOKEN }}
68+
69+
- name: Node.js setup (25.x)
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: 25.x
73+
74+
- name: install Rust stable
75+
uses: dtolnay/rust-toolchain@stable
76+
with:
77+
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
78+
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
79+
80+
- name: Install dependencies (ubuntu only)
81+
if: matrix.platform == 'ubuntu-22.04'
82+
run: |
83+
sudo apt-get update
84+
sudo apt-get install -y pkg-config libudev-dev javascriptcoregtk-4.1 libsoup-3.0 libwebkit2gtk-4.0-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev webkit2gtk-4.0 patchelf libsoup2.4-dev
85+
npm install -g pnpm
86+
npm install -g typescript
87+
88+
- name: install dependencies (windows only)
89+
if: matrix.platform == 'windows-latest'
90+
run: |
91+
npm install -g typescript
92+
npm install -g pnpm
93+
94+
- name: install dependencies (macos only)
95+
if: matrix.platform == 'macos-latest'
96+
run: |
97+
brew install pnpm
98+
99+
- name: Install frontend dependencies (PNPM)
100+
run: pnpm install --no-frozen-lockfile
101+
102+
- name: Generate Local Plugins (PNPM)
103+
run: pnpm run specta:gen
104+
105+
- uses: tauri-apps/tauri-action@v0.6.1
106+
id: tauri_build
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
110+
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
111+
with:
112+
releaseId: ${{ needs.create-release.outputs.release_id }}
113+
includeUpdaterJson: true
114+
args: ${{ matrix.args }}
115+
116+
- name: Cleanup release after failure
117+
if: ${{ failure() }}
118+
env:
119+
release_id: ${{ needs.create-release.outputs.release_id }}
120+
uses: actions/github-script@v8
121+
with:
122+
script: |
123+
await github.rest.repos.deleteRelease({
124+
owner: context.repo.owner,
125+
repo: context.repo.repo,
126+
release_id: process.env.release_id,
127+
})
128+
129+
publish-release:
130+
permissions:
131+
contents: write
132+
runs-on: ubuntu-latest
133+
needs: [ create-release, build-tauri ]
134+
135+
steps:
136+
- name: publish release
137+
id: publish-release
138+
uses: actions/github-script@v8
139+
env:
140+
release_id: ${{ needs.create-release.outputs.release_id }}
141+
TAG_NAME: ${{ github.ref_name }}
142+
with:
143+
script: |
144+
const isPrerelease = process.env.TAG_NAME.includes('beta');
145+
146+
github.rest.repos.updateRelease({
147+
owner: context.repo.owner,
148+
repo: context.repo.repo,
149+
release_id: process.env.release_id,
150+
draft: false,
151+
prerelease: isPrerelease,
152+
})

0 commit comments

Comments
 (0)