diff --git a/.gitea/workflows/windows-desktop-client.yml b/.gitea/workflows/windows-desktop-client.yml index 5f6dbf3..5e6864c 100644 --- a/.gitea/workflows/windows-desktop-client.yml +++ b/.gitea/workflows/windows-desktop-client.yml @@ -2,6 +2,11 @@ name: Build Windows Desktop Client on: workflow_dispatch: + inputs: + app_version: + description: "Optional app version for this build, e.g. 0.1.3" + required: false + default: "" jobs: build-windows-client: @@ -55,6 +60,42 @@ jobs: - name: Install desktop client dependencies run: npm install + - name: Apply requested app version + if: ${{ github.event.inputs.app_version != '' }} + run: | + set -euo pipefail + VERSION="${{ github.event.inputs.app_version }}" + export VERSION + + case "${VERSION}" in + *[!0-9A-Za-z.+-]*|'') + echo "Invalid app_version: ${VERSION}" + exit 1 + ;; + esac + + node -e ' + const fs = require("fs"); + const version = process.env.VERSION; + const pkgPath = "package.json"; + const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")); + pkg.version = version; + fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n"); + ' + + node -e ' + const fs = require("fs"); + const version = process.env.VERSION; + const configPath = "src-tauri/tauri.conf.json"; + const config = JSON.parse(fs.readFileSync(configPath, "utf8")); + config.version = version; + fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n"); + ' + + perl -0pi -e 's/^version = ".*?"$/version = "'"${VERSION}"'"/m' src-tauri/Cargo.toml + + echo "Using app version ${VERSION}" + - name: Build bundled Windows tunnel helper run: npm run helper:windows-x64 @@ -85,6 +126,16 @@ jobs: - name: Build Windows installer run: npm run tauri:build:windows-x64:linux + - name: Prepare artifact names + run: | + set -euo pipefail + VERSION="${{ github.event.inputs.app_version }}" + if [ -n "${VERSION}" ]; then + echo "ARTIFACT_SUFFIX=-${VERSION}" >> "${GITHUB_ENV}" + else + echo "ARTIFACT_SUFFIX=" >> "${GITHUB_ENV}" + fi + - name: Sign Windows desktop executable and installer if: ${{ secrets.WINDOWS_SIGN_PFX_B64 != '' && secrets.WINDOWS_SIGN_PFX_PASSWORD != '' }} run: | @@ -121,7 +172,7 @@ jobs: - name: Upload Windows installer uses: christopherhx/gitea-upload-artifact@v4 with: - name: NexaVPN-windows-installer + name: NexaVPN-windows-installer${{ env.ARTIFACT_SUFFIX }} path: | desktop-client/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe desktop-client/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.msi @@ -130,7 +181,7 @@ jobs: - name: Upload raw Windows build outputs uses: christopherhx/gitea-upload-artifact@v4 with: - name: NexaVPN-windows-raw-build + name: NexaVPN-windows-raw-build${{ env.ARTIFACT_SUFFIX }} path: | desktop-client/src-tauri/target/x86_64-pc-windows-msvc/release/nexavpn-desktop.exe desktop-client/src-tauri/bundled/windows-x64/nexavpn-tunnel-helper.exe