-
Notifications
You must be signed in to change notification settings - Fork 32
222 lines (193 loc) · 8.64 KB
/
Copy pathrelease.yml
File metadata and controls
222 lines (193 loc) · 8.64 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. 0.1.0). Leave empty to use version from tauri.conf.json"
required: false
default: ""
permissions:
contents: write
jobs:
# Determine the version and tag name to use for the release
prepare:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.get_version.outputs.tag_name }}
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get version
id: get_version
run: |
if [ "${{ github.event_name }}" = "push" ]; then
TAG="${GITHUB_REF#refs/tags/}"
VERSION="${TAG#v}"
elif [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
TAG="v${VERSION}"
else
VERSION=$(grep -oP '"version":\s*"\K[^"]+' client/src-tauri/tauri.conf.json)
TAG="v${VERSION}"
fi
echo "tag_name=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Resolved version: ${VERSION}, tag: ${TAG}"
release:
needs: prepare
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-22.04, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Install dependencies (Ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf unzip
- name: Install frontend dependencies
run: npm install
working-directory: ./client
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Build dnstt-client
shell: bash
run: |
git clone https://www.bamsoftware.com/git/dnstt.git
cd dnstt/dnstt-client
if [ "${{ matrix.platform }}" == "windows-latest" ]; then
go build -ldflags="-s -w" -o ../../dnstt-client.exe
else
go build -ldflags="-s -w" -o ../../dnstt-client
fi
- name: Download extra tools
shell: bash
run: |
mkdir -p extra-tools
# Fetch latest versions from GitHub API
XRAY_VERSION=$(curl -sf https://api.github.com/repos/XTLS/Xray-core/releases/latest | grep '"tag_name":' | head -n 1 | cut -d'"' -f4)
SING_VERSION=$(curl -sf https://api.github.com/repos/SagerNet/sing-box/releases/latest | grep '"tag_name":' | head -n 1 | cut -d'"' -f4 | sed 's/^v//')
echo "Xray version: $XRAY_VERSION"
echo "Sing-box version: $SING_VERSION"
# Platform/arch mapping
PLATFORM="${{ matrix.platform }}"
if [ "$PLATFORM" == "windows-latest" ]; then
XRAY_OS="windows-64"
SING_OS="windows-amd64"
SING_EXT="zip"
BIN_SUFFIX=".exe"
elif [ "$PLATFORM" == "ubuntu-22.04" ]; then
XRAY_OS="linux-64"
SING_OS="linux-amd64"
SING_EXT="tar.gz"
BIN_SUFFIX=""
else
# macOS — runners are now ARM (M1), fall back to amd64 if arm64 not available
XRAY_OS="macos-64"
SING_OS="darwin-arm64"
SING_EXT="tar.gz"
BIN_SUFFIX=""
fi
# ── Download Xray ──────────────────────────────────────────────────────────
echo "Downloading Xray $XRAY_VERSION for $XRAY_OS"
XRAY_URL="https://github.com/XTLS/Xray-core/releases/download/${XRAY_VERSION}/Xray-${XRAY_OS}.zip"
curl -fSL "$XRAY_URL" -o xray.zip
mkdir -p extra-tools/xray
unzip -q xray.zip -d extra-tools/xray
# ── Download Sing-box ──────────────────────────────────────────────────────
echo "Downloading Sing-box $SING_VERSION for $SING_OS"
SING_ARCHIVE="sing-box-${SING_VERSION}-${SING_OS}.${SING_EXT}"
SING_URL="https://github.com/SagerNet/sing-box/releases/download/v${SING_VERSION}/${SING_ARCHIVE}"
curl -fSL "$SING_URL" -o "sing-box.${SING_EXT}"
mkdir -p sing-box-temp extra-tools/sing-box
if [ "$SING_EXT" == "zip" ]; then
unzip -q "sing-box.${SING_EXT}" -d sing-box-temp
else
tar -xzf "sing-box.${SING_EXT}" -C sing-box-temp
fi
# The archive extracts to a folder named sing-box-<version>-<os>/
# The binary (and LICENSE etc.) sit directly inside that folder.
SING_INNER=$(find sing-box-temp -mindepth 1 -maxdepth 1 -type d | head -n 1)
if [ -n "$SING_INNER" ]; then
cp "$SING_INNER/sing-box${BIN_SUFFIX}" extra-tools/sing-box/
else
# Flat archive — binary is at root of extracted dir
cp "sing-box-temp/sing-box${BIN_SUFFIX}" extra-tools/sing-box/ 2>/dev/null || true
fi
rm -rf sing-box-temp
# ── OpenVPN (Windows only) ─────────────────────────────────────────────────
if [ "$PLATFORM" == "windows-latest" ]; then
echo "Installing OpenVPN via Chocolatey..."
choco install openvpn -y --no-progress
mkdir -p extra-tools/openvpn
cp "C:/Program Files/OpenVPN/bin/openvpn.exe" extra-tools/openvpn/ || true
cp "C:/Program Files/OpenVPN/bin/openssl.exe" extra-tools/openvpn/ || true
fi
# ── dnstt-client ───────────────────────────────────────────────────────────
if [ "$PLATFORM" == "windows-latest" ]; then
cp dnstt-client.exe extra-tools/
else
cp dnstt-client extra-tools/
fi
# ── Cleanup ────────────────────────────────────────────────────────────────
rm -f xray.zip "sing-box.${SING_EXT}"
echo "extra-tools contents:"
find extra-tools -type f
- name: Build Tauri app (macOS universal)
if: matrix.platform == 'macos-latest'
run: npm run tauri build -- --target universal-apple-darwin
working-directory: ./client
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Tauri app (Linux / Windows)
if: matrix.platform != 'macos-latest'
run: npm run tauri build -- --no-bundle
working-directory: ./client
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Package release zip
shell: bash
run: |
mkdir -p bundle
if [ "${{ matrix.platform }}" == "windows-latest" ]; then
APP_BIN="client/src-tauri/target/release/candy-connect.exe"
ZIP_NAME="CandyConnect-${{ needs.prepare.outputs.tag_name }}-windows-x64.zip"
elif [ "${{ matrix.platform }}" == "macos-latest" ]; then
APP_BIN="client/src-tauri/target/universal-apple-darwin/release/candy-connect"
ZIP_NAME="CandyConnect-${{ needs.prepare.outputs.tag_name }}-macos-universal.zip"
else
APP_BIN="client/src-tauri/target/release/candy-connect"
ZIP_NAME="CandyConnect-${{ needs.prepare.outputs.tag_name }}-linux-x64.zip"
fi
cp "$APP_BIN" bundle/
cp -r extra-tools/* bundle/
if [ "${{ matrix.platform }}" == "windows-latest" ]; then
7z a "$ZIP_NAME" ./bundle/*
else
cd bundle && zip -r "../$ZIP_NAME" . && cd ..
fi
echo "ZIP_NAME=$ZIP_NAME" >> "$GITHUB_ENV"
- name: Upload release asset
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.tag_name }}
files: ${{ env.ZIP_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}