Release #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| mkdir -p extra-tools | |
| PLATFORM="${{ matrix.platform }}" | |
| # ── Resolve latest versions (authenticated to avoid rate-limits) ─────────── | |
| echo "Fetching latest Xray version..." | |
| XRAY_VERSION=$(curl -sf -H "Authorization: Bearer ${GH_TOKEN}" \ | |
| https://api.github.com/repos/XTLS/Xray-core/releases/latest \ | |
| | grep '"tag_name":' | head -n 1 | cut -d'"' -f4) | |
| if [ -z "$XRAY_VERSION" ]; then | |
| echo "WARNING: Could not fetch Xray version from API, using fallback" | |
| XRAY_VERSION="v25.1.1" | |
| fi | |
| echo "Fetching latest Sing-box version..." | |
| SING_VERSION=$(curl -sf -H "Authorization: Bearer ${GH_TOKEN}" \ | |
| https://api.github.com/repos/SagerNet/sing-box/releases/latest \ | |
| | grep '"tag_name":' | head -n 1 | cut -d'"' -f4 | sed 's/^v//') | |
| if [ -z "$SING_VERSION" ]; then | |
| echo "WARNING: Could not fetch Sing-box version from API, using fallback" | |
| SING_VERSION="1.11.0" | |
| fi | |
| echo "Xray version : $XRAY_VERSION" | |
| echo "Sing-box version: $SING_VERSION" | |
| # ── Platform/arch mapping ────────────────────────────────────────────────── | |
| 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 runner — try arm64 first (M1/M2 runners), fall back to amd64 | |
| 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" | |
| echo "URL: $XRAY_URL" | |
| if curl -fSL --retry 3 --retry-delay 5 "$XRAY_URL" -o xray.zip; then | |
| mkdir -p extra-tools/xray | |
| unzip -q xray.zip -d extra-tools/xray | |
| echo "Xray downloaded OK" | |
| else | |
| echo "ERROR: Failed to download Xray from $XRAY_URL" | |
| exit 1 | |
| fi | |
| # ── 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}" | |
| echo "URL: $SING_URL" | |
| # On macOS try arm64 first, fall back to amd64 | |
| if ! curl -fSL --retry 3 --retry-delay 5 "$SING_URL" -o "sing-box.${SING_EXT}" 2>/dev/null; then | |
| if [ "$PLATFORM" == "macos-latest" ]; then | |
| echo "arm64 not found, trying amd64..." | |
| SING_OS="darwin-amd64" | |
| 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 --retry 3 --retry-delay 5 "$SING_URL" -o "sing-box.${SING_EXT}" | |
| else | |
| echo "ERROR: Failed to download Sing-box from $SING_URL" | |
| exit 1 | |
| fi | |
| fi | |
| 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 | |
| # Archive extracts to: sing-box-<version>-<os>/ with binary directly inside | |
| SING_INNER=$(find sing-box-temp -mindepth 1 -maxdepth 1 -type d | head -n 1) | |
| if [ -n "$SING_INNER" ]; then | |
| echo "Extracting from inner dir: $SING_INNER" | |
| cp "$SING_INNER/sing-box${BIN_SUFFIX}" extra-tools/sing-box/ | |
| else | |
| echo "Flat archive, copying from root of extracted dir" | |
| cp "sing-box-temp/sing-box${BIN_SUFFIX}" extra-tools/sing-box/ 2>/dev/null || { | |
| echo "ERROR: Could not find sing-box binary in archive" | |
| find sing-box-temp | |
| exit 1 | |
| } | |
| fi | |
| rm -rf sing-box-temp | |
| echo "Sing-box downloaded OK" | |
| # ── 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 & summary ────────────────────────────────────────────────────── | |
| 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 }} |