Skip to content

Commit f1ca3ca

Browse files
committed
Optimize workflow
1 parent 233f11a commit f1ca3ca

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

.github/actions/release.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ declare global {
1616

1717
const dirname = path.dirname(fileURLToPath(import.meta.url))
1818
const envPath = path.join(dirname, '..', '..', '.env')
19-
const tauriConfPath = path.join(dirname, '..', '..', 'src-tauri', 'tauri.conf.json')
2019
const packageJsonPath = path.join(dirname, '..', '..', 'package.json')
2120
const token = process.env.GITHUB_TOKEN
2221
const secret = process.env.CLIENT_SECRET
@@ -28,17 +27,10 @@ VITE_CLIENT_ID=${id}
2827
`
2928

3029
async function run() {
31-
const tauriConf = JSON.parse(
32-
await fs.readFile(tauriConfPath, 'utf-8'),
33-
) as typeof import('../../src-tauri/tauri.conf.json')
34-
3530
const packageJSON = JSON.parse(
3631
await fs.readFile(packageJsonPath, 'utf-8'),
3732
) as typeof import('../../package.json')
3833

39-
if (packageJSON.version !== tauriConf.package.version)
40-
throw new Error('Tauri config and Package JSON versions are not the same, update both of them!')
41-
4234
const dmgFileName = `Gitification_${packageJSON.version}_universal.dmg`
4335

4436
const dmgPath = path.join(

.github/actions/version.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import path from 'path'
2+
import { fileURLToPath } from 'url'
3+
import fs from 'fs/promises'
4+
5+
const dirname = path.dirname(fileURLToPath(import.meta.url))
6+
const tauriConfPath = path.join(dirname, '..', '..', 'src-tauri', 'tauri.conf.json')
7+
const packageJsonPath = path.join(dirname, '..', '..', 'package.json')
8+
9+
async function run() {
10+
const tauriConf = JSON.parse(
11+
await fs.readFile(tauriConfPath, 'utf-8'),
12+
) as typeof import('../../src-tauri/tauri.conf.json')
13+
14+
const packageJSON = JSON.parse(
15+
await fs.readFile(packageJsonPath, 'utf-8'),
16+
) as typeof import('../../package.json')
17+
18+
if (packageJSON.version !== tauriConf.package.version)
19+
throw new Error('Tauri config and Package JSON versions are not the same, update both of them!')
20+
}
21+
22+
run()

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ jobs:
4444
4545
- name: Install dependencies
4646
run: pnpm install
47+
48+
- name: Check version change
49+
run: pnpx tsx .github/actions/version.ts
4750

4851
- name: install Rust stable
4952
uses: dtolnay/rust-toolchain@stable

0 commit comments

Comments
 (0)