Skip to content

Commit 660bdb9

Browse files
committed
GH: Build and deploy action
With Release Tags
1 parent 73d251f commit 660bdb9

File tree

7 files changed

+193
-4
lines changed

7 files changed

+193
-4
lines changed

.github/workflows/build.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build Tauri App
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- master
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
platform: [windows-latest]
16+
17+
runs-on: ${{ matrix.platform }}
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Install Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '18'
26+
cache: 'npm'
27+
28+
- name: Install Rust stable
29+
uses: dtolnay/rust-toolchain@stable
30+
31+
- name: Rust cache
32+
uses: swatinem/rust-cache@v2
33+
with:
34+
workspaces: './src-tauri -> target'
35+
36+
- name: Install frontend dependencies
37+
run: npm ci
38+
39+
- name: Lint frontend
40+
run: npm run lint
41+
42+
- name: Build Next.js frontend
43+
run: npm run build
44+
45+
- name: Verify dist directory
46+
shell: bash
47+
run: |
48+
if [ -d "dist" ]; then
49+
echo "✅ Next.js build successful - dist directory created"
50+
echo "Contents of dist directory:"
51+
ls -la dist/
52+
else
53+
echo "❌ Next.js build failed - dist directory not found"
54+
exit 1
55+
fi
56+
57+
- name: Build Tauri app (without release)
58+
uses: tauri-apps/tauri-action@v0
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
with:
62+
includeDebug: false
63+
includeRelease: false
64+
includeUpdaterJson: false

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Release Tauri App
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
workflow_dispatch:
9+
10+
jobs:
11+
release:
12+
permissions:
13+
contents: write
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
platform: [windows-latest]
18+
19+
runs-on: ${{ matrix.platform }}
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Install Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '18'
28+
cache: 'npm'
29+
30+
- name: Install Rust stable
31+
uses: dtolnay/rust-toolchain@stable
32+
33+
- name: Rust cache
34+
uses: swatinem/rust-cache@v2
35+
with:
36+
workspaces: './src-tauri -> target'
37+
38+
- name: Install frontend dependencies
39+
run: npm ci
40+
41+
- name: Build Next.js frontend
42+
run: npm run build
43+
44+
- name: Get package version
45+
id: package-version
46+
shell: bash
47+
run: |
48+
VERSION=$(node -p "require('./package.json').version")
49+
echo "version=$VERSION" >> $GITHUB_OUTPUT
50+
echo "Package version: $VERSION"
51+
52+
- name: Check if tag exists
53+
id: check-tag
54+
shell: bash
55+
run: |
56+
if git rev-parse "v${{ steps.package-version.outputs.version }}" >/dev/null 2>&1; then
57+
echo "exists=true" >> $GITHUB_OUTPUT
58+
echo "Tag v${{ steps.package-version.outputs.version }} already exists"
59+
else
60+
echo "exists=false" >> $GITHUB_OUTPUT
61+
echo "Tag v${{ steps.package-version.outputs.version }} does not exist"
62+
fi
63+
64+
- name: Build Tauri app
65+
if: steps.check-tag.outputs.exists == 'false'
66+
uses: tauri-apps/tauri-action@v0
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
with:
70+
tagName: v${{ steps.package-version.outputs.version }}
71+
releaseName: 'Release v${{ steps.package-version.outputs.version }}'
72+
releaseBody: |
73+
## What's Changed
74+
75+
Release of version ${{ steps.package-version.outputs.version }}
76+
77+
### Features
78+
- Tauri + Next.js application
79+
- Windows executable included
80+
81+
### Installation
82+
Download the appropriate installer for your platform from the assets below.
83+
releaseDraft: false
84+
prerelease: false
85+
includeDebug: false
86+
includeRelease: true
87+
88+
- name: Skip release (tag exists)
89+
if: steps.check-tag.outputs.exists == 'true'
90+
run: |
91+
echo "Skipping release because tag v${{ steps.package-version.outputs.version }} already exists"
92+
echo "If you want to create a new release, please update the version in package.json"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ next-env.d.ts
3939
# Tauri
4040
/src-tauri/target/
4141
/src-tauri/Cargo.lock
42+
/src-tauri/gen/
4243

4344
# IDE
4445
.vscode/

next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const nextConfig = {
88
unoptimized: true,
99
},
1010
assetPrefix: process.env.NODE_ENV === 'production' ? './' : '',
11+
// Ensure static export works properly for Tauri
12+
generateEtags: false,
13+
poweredByHeader: false,
1114
experimental: {
1215
//esmExternals: 'loose',
1316
},

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
"tauri:dev": "tauri dev",
1313
"tauri:dev:feat": "tauri dev --features notifications,deep-links,clipboard,system-tray",
1414
"tauri:build": "tauri build",
15-
"tauri:info": "tauri info"
15+
"tauri:info": "tauri info",
16+
"version:patch": "npm version patch --no-git-tag-version && node scripts/sync-version.js",
17+
"version:minor": "npm version minor --no-git-tag-version && node scripts/sync-version.js",
18+
"version:major": "npm version major --no-git-tag-version && node scripts/sync-version.js",
19+
"build:release": "npm run build && npm run tauri:build"
1620
},
1721
"dependencies": {
1822
"@tauri-apps/api": "^2.0.0",

scripts/sync-version.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
6+
// Read package.json version
7+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
8+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
9+
const version = packageJson.version;
10+
11+
// Read tauri.conf.json
12+
const tauriConfigPath = path.join(__dirname, '..', 'src-tauri', 'tauri.conf.json');
13+
const tauriConfig = JSON.parse(fs.readFileSync(tauriConfigPath, 'utf8'));
14+
15+
// Update version in tauri config
16+
tauriConfig.version = version;
17+
18+
// Write back to tauri.conf.json
19+
fs.writeFileSync(tauriConfigPath, JSON.stringify(tauriConfig, null, 2) + '\n');
20+
21+
console.log(`✅ Synced version ${version} to tauri.conf.json`);

src-tauri/tauri.conf.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@
6565
"open": true
6666
},
6767
"deep-link": {
68-
"domains": ["tauri-app.com"],
69-
"schemes": ["tauri-starterkit"]
68+
"domains": [
69+
"tauri-app.com"
70+
],
71+
"schemes": [
72+
"tauri-starterkit"
73+
]
7074
}
7175
}
72-
}
76+
}

0 commit comments

Comments
 (0)