-
Notifications
You must be signed in to change notification settings - Fork 150
208 lines (179 loc) · 6.54 KB
/
release.yml
File metadata and controls
208 lines (179 loc) · 6.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
env:
APP_NAME: fetch-github-hosts
jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create.outputs.result }}
steps:
- uses: actions/checkout@v4
- name: Create draft release with auto changelog
id: create
uses: actions/github-script@v7
with:
script: |
const tagName = context.ref.replace('refs/tags/', '') || 'v4.0';
// Use GitHub's built-in release notes generator
let generatedNotes = '';
try {
const { data: notes } = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tagName,
});
generatedNotes = notes.body;
} catch (e) {
console.log('Auto-generate notes failed, using fallback:', e.message);
generatedNotes = '';
}
const downloads = `\n---\n\n**Downloads**\n\n| Platform | File | Architecture |\n|----------|------|--------------|\n| macOS | \`.dmg\` | Universal (Intel + Apple Silicon) |\n| Windows | \`.msi\` / \`.exe\` | x86_64 |\n| Linux | \`.deb\` / \`.AppImage\` | x86_64 |\n| Linux CLI | \`.tar.gz\` | amd64 / aarch64 |`;
const body = generatedNotes
? `${generatedNotes}${downloads}`
: `See the assets below to download the app for your platform.${downloads}`;
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tagName,
name: `Fetch Github Hosts ${tagName}`,
body: body,
draft: true,
prerelease: false
});
return data.id;
result-encoding: string
build-tauri:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
# macOS - Universal binary (Intel + Apple Silicon)
- platform: macos-latest
args: --target universal-apple-darwin
rust_targets: aarch64-apple-darwin,x86_64-apple-darwin
name: macos-universal
# Linux x86_64
- platform: ubuntu-22.04
args: ''
rust_targets: ''
name: linux-x86_64
# Windows
- platform: windows-latest
args: ''
rust_targets: ''
name: windows-x86_64
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'npm'
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_targets }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
- name: Install system dependencies (Linux)
if: contains(matrix.name, 'linux')
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf \
pkg-config \
libglib2.0-dev \
libgtk-3-dev \
libgdk-pixbuf2.0-dev \
libpango1.0-dev \
libatk1.0-dev \
libcairo-gobject2 \
libjavascriptcoregtk-4.1-dev
- name: Install frontend dependencies
run: npm ci
- name: Inject version from tag
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
RAW_VERSION=${GITHUB_REF#refs/tags/v}
IFS='.' read -ra parts <<< "$RAW_VERSION"
VERSION="${parts[0]:-0}.${parts[1]:-0}.${parts[2]:-0}"
echo "Injecting version: $VERSION"
sed -i.bak 's/"version": "[^"]*"/"version": "'"$VERSION"'"/' src-tauri/tauri.conf.json
sed -i.bak 's/^version = "[^"]*"/version = "'"$VERSION"'"/' src-tauri/Cargo.toml
sed -i.bak 's/"version": "[^"]*"/"version": "'"$VERSION"'"/' package.json
- name: Build static frontend
run: npx cross-env NUXT_CLI_WRAPPER=false npx nuxt generate
- name: Build Tauri app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
args: ${{ matrix.args }}
build-cli:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: ubuntu-22.04
target: x86_64-unknown-linux-musl
arch: amd64
- platform: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
arch: aarch64
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
- name: Inject version from tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
RAW_VERSION=${GITHUB_REF#refs/tags/v}
IFS='.' read -ra parts <<< "$RAW_VERSION"
VERSION="${parts[0]:-0}.${parts[1]:-0}.${parts[2]:-0}"
echo "Injecting version: $VERSION"
sed -i.bak 's/^version = "[^"]*"/version = "'"$VERSION"'"/' src-tauri/Cargo.toml
- name: Build CLI binary (fully static, no system dependencies)
working-directory: src-tauri
run: cargo build --release --no-default-features --target ${{ matrix.target }}
- name: Package standalone binary
run: |
TAR_NAME="fetch-github-hosts_linux_${{ matrix.arch }}.tar.gz"
tar -czf "$TAR_NAME" -C "src-tauri/target/${{ matrix.target }}/release" "fetch-github-hosts"
echo "TAR_NAME=$TAR_NAME" >> "$GITHUB_ENV"
- name: Upload standalone binary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
gh release upload "$TAG_NAME" "$TAR_NAME" --repo "${{ github.repository }}" --clobber