|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + name: Build & Release |
| 14 | + runs-on: windows-latest |
| 15 | + if: github.repository_owner == 'LeagueToolkit' |
| 16 | + permissions: |
| 17 | + contents: write |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Extract version from tag |
| 25 | + id: version |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + TAG="${GITHUB_REF#refs/tags/}" |
| 29 | + VERSION="${TAG#v}" |
| 30 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
| 31 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 32 | +
|
| 33 | + if [[ "$VERSION" == *-* ]]; then |
| 34 | + echo "prerelease=true" >> "$GITHUB_OUTPUT" |
| 35 | + else |
| 36 | + echo "prerelease=false" >> "$GITHUB_OUTPUT" |
| 37 | + fi |
| 38 | +
|
| 39 | + - name: Validate version consistency |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + CARGO_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' src-tauri/Cargo.toml | head -1) |
| 43 | + if [ "$CARGO_VERSION" != "${{ steps.version.outputs.version }}" ]; then |
| 44 | + echo "::error::Tag version (${{ steps.version.outputs.version }}) does not match Cargo.toml version ($CARGO_VERSION)" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | +
|
| 48 | + - name: Generate changelog |
| 49 | + id: changelog |
| 50 | + uses: orhun/git-cliff-action@v4 |
| 51 | + with: |
| 52 | + config: cliff.toml |
| 53 | + args: --latest --strip header |
| 54 | + |
| 55 | + - name: Setup Node.js |
| 56 | + uses: actions/setup-node@v4 |
| 57 | + with: |
| 58 | + node-version: "22" |
| 59 | + |
| 60 | + - uses: pnpm/action-setup@v4 |
| 61 | + |
| 62 | + - name: Install Rust toolchain |
| 63 | + uses: dtolnay/rust-toolchain@stable |
| 64 | + with: |
| 65 | + targets: x86_64-pc-windows-msvc |
| 66 | + |
| 67 | + - uses: Swatinem/rust-cache@v2 |
| 68 | + |
| 69 | + - name: Install frontend dependencies |
| 70 | + run: pnpm install --frozen-lockfile |
| 71 | + |
| 72 | + - name: Patch tauri.conf.json |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + cd src-tauri |
| 76 | + # Set version from tag |
| 77 | + CONF=$(cat tauri.conf.json) |
| 78 | + CONF=$(echo "$CONF" | jq --arg v "${{ steps.version.outputs.version }}" '.version = $v') |
| 79 | +
|
| 80 | + # For pre-releases, restrict to NSIS only (MSI doesn't support non-numeric pre-release identifiers) |
| 81 | + if [ "${{ steps.version.outputs.prerelease }}" = "true" ]; then |
| 82 | + CONF=$(echo "$CONF" | jq '.bundle.targets = ["nsis"]') |
| 83 | + fi |
| 84 | +
|
| 85 | + echo "$CONF" > tauri.conf.json |
| 86 | +
|
| 87 | + - name: Build and release |
| 88 | + uses: tauri-apps/tauri-action@v0 |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} |
| 92 | + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} |
| 93 | + with: |
| 94 | + tagName: ${{ steps.version.outputs.tag }} |
| 95 | + releaseName: "LTK Manager v${{ steps.version.outputs.version }}" |
| 96 | + releaseBody: ${{ steps.changelog.outputs.content }} |
| 97 | + releaseDraft: false |
| 98 | + prerelease: ${{ steps.version.outputs.prerelease }} |
| 99 | + updaterJsonPreferNsis: true |
| 100 | + |
| 101 | + - name: Update updater release |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + TAG="${{ steps.version.outputs.tag }}" |
| 105 | +
|
| 106 | + # Download latest.json from the release we just created |
| 107 | + gh release download "$TAG" --pattern "latest.json" --dir . --clobber |
| 108 | +
|
| 109 | + # Upload to the pinned "updater" release |
| 110 | + if gh release view updater &>/dev/null; then |
| 111 | + gh release upload updater latest.json --clobber |
| 112 | + else |
| 113 | + gh release create updater latest.json \ |
| 114 | + --title "Updater" \ |
| 115 | + --notes "Auto-updated by CI. Contains the latest updater manifest for in-app updates." \ |
| 116 | + --latest=false |
| 117 | + fi |
| 118 | + env: |
| 119 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments