|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-windows: |
| 13 | + runs-on: windows-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Rust |
| 18 | + uses: dtolnay/rust-toolchain@1.85.0 |
| 19 | + with: |
| 20 | + profile: minimal |
| 21 | + |
| 22 | + - name: Build (release) |
| 23 | + run: cargo build --release --locked |
| 24 | + |
| 25 | + - name: Package Windows zip |
| 26 | + shell: pwsh |
| 27 | + run: | |
| 28 | + $version = "${{ github.ref_name }}" |
| 29 | + New-Item -ItemType Directory -Force -Path staging |
| 30 | + Copy-Item target/release/recur.exe staging/ |
| 31 | + Copy-Item target/release/recur-git.exe staging/ |
| 32 | + Copy-Item README.md staging/ |
| 33 | + Compress-Archive -Path staging/* -DestinationPath "recur-${version}-x86_64-pc-windows-msvc.zip" |
| 34 | +
|
| 35 | + - name: Upload artifact |
| 36 | + uses: actions/upload-artifact@v4 |
| 37 | + with: |
| 38 | + name: windows-zip |
| 39 | + path: recur-*.zip |
| 40 | + |
| 41 | + build-linux: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Set up Rust |
| 47 | + uses: dtolnay/rust-toolchain@1.85.0 |
| 48 | + with: |
| 49 | + profile: minimal |
| 50 | + |
| 51 | + - name: Build (release) |
| 52 | + run: cargo build --release --locked |
| 53 | + |
| 54 | + - name: Package Linux tarball |
| 55 | + run: | |
| 56 | + VERSION="${{ github.ref_name }}" |
| 57 | + mkdir staging |
| 58 | + cp target/release/recur staging/ |
| 59 | + cp target/release/recur-git staging/ |
| 60 | + cp README.md staging/ |
| 61 | + tar czf "recur-${VERSION}-x86_64-unknown-linux-gnu.tar.gz" -C staging . |
| 62 | +
|
| 63 | + - name: Build .deb package |
| 64 | + run: | |
| 65 | + cargo install cargo-deb |
| 66 | + cargo deb --no-build |
| 67 | +
|
| 68 | + - name: Upload tarball |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: linux-tarball |
| 72 | + path: recur-*.tar.gz |
| 73 | + |
| 74 | + - name: Upload deb |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: linux-deb |
| 78 | + path: target/debian/*.deb |
| 79 | + |
| 80 | + release: |
| 81 | + needs: [build-windows, build-linux] |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + |
| 86 | + - name: Download all artifacts |
| 87 | + uses: actions/download-artifact@v4 |
| 88 | + with: |
| 89 | + path: artifacts |
| 90 | + |
| 91 | + - name: Create GitHub Release |
| 92 | + uses: softprops/action-gh-release@v2 |
| 93 | + with: |
| 94 | + generate_release_notes: true |
| 95 | + files: | |
| 96 | + artifacts/windows-zip/*.zip |
| 97 | + artifacts/linux-tarball/*.tar.gz |
| 98 | + artifacts/linux-deb/*.deb |
| 99 | +
|
| 100 | + chocolatey: |
| 101 | + needs: [release] |
| 102 | + runs-on: windows-latest |
| 103 | + if: github.event_name == 'push' |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v4 |
| 106 | + |
| 107 | + - name: Download Windows zip |
| 108 | + uses: actions/download-artifact@v4 |
| 109 | + with: |
| 110 | + name: windows-zip |
| 111 | + path: artifacts |
| 112 | + |
| 113 | + - name: Compute checksum and update install script |
| 114 | + shell: pwsh |
| 115 | + run: | |
| 116 | + $zip = Get-ChildItem artifacts/*.zip | Select-Object -First 1 |
| 117 | + $hash = (Get-FileHash $zip -Algorithm SHA256).Hash |
| 118 | + $install = Get-Content choco/tools/chocolateyInstall.ps1 -Raw |
| 119 | + $install = $install -replace '%CHECKSUM64%', $hash |
| 120 | + Set-Content choco/tools/chocolateyInstall.ps1 $install |
| 121 | +
|
| 122 | + - name: Update version in nuspec |
| 123 | + shell: pwsh |
| 124 | + run: | |
| 125 | + $version = "${{ github.ref_name }}".TrimStart('v') |
| 126 | + $nuspec = Get-Content choco/recur.nuspec -Raw |
| 127 | + $nuspec = $nuspec -replace '<version>.*</version>', "<version>$version</version>" |
| 128 | + Set-Content choco/recur.nuspec $nuspec |
| 129 | +
|
| 130 | + - name: Pack Chocolatey package |
| 131 | + run: choco pack choco/recur.nuspec --output-directory choco/ |
| 132 | + |
| 133 | + - name: Push to Chocolatey |
| 134 | + run: choco push choco/recur.*.nupkg --source https://push.chocolatey.org/ --api-key ${{ secrets.CHOCOLATEY_API_KEY }} |
0 commit comments