name: Release on: push: tags: - "v*" workflow_dispatch: # Build the installers when something they depend on changes. Only a tag publishes anything. pull_request: paths: - .github/workflows/release.yml - Cargo.toml - Cargo.lock - assets/icons/** permissions: contents: read jobs: build: strategy: fail-fast: false matrix: include: - platform: macos-latest # Apple Silicon - platform: ubuntu-latest - platform: windows-latest runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v7 - name: install Linux system dependencies if: matrix.platform == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y libxkbcommon-dev libwayland-dev # rustup reads the version from rust-toolchain.toml. - name: install the Rust toolchain run: rustup show active-toolchain || rustup toolchain install - uses: Swatinem/rust-cache@v2 - name: install cargo-bundle if: matrix.platform != 'windows-latest' run: cargo install cargo-bundle --locked # Each installer gets a checksum, which the in-app updater requires. It catches a corrupt # download. It comes from the same release, so it can't catch a tampered one. - name: build the macOS disk image if: matrix.platform == 'macos-latest' run: | cargo bundle --release app="target/release/bundle/osx/Stahl Capital.app" codesign --force --deep --sign - "$app" hdiutil create -volname "Stahl Capital" -srcfolder "$app" -ov -format UDZO stahl-capital-macos-arm64.dmg shasum -a 256 stahl-capital-macos-arm64.dmg > stahl-capital-macos-arm64.dmg.sha256 - name: build the Debian package if: matrix.platform == 'ubuntu-latest' run: | cargo bundle --release --format deb cp target/release/bundle/deb/*.deb . for deb in *.deb; do sha256sum "$deb" > "$deb.sha256"; done - name: build the Windows archive if: matrix.platform == 'windows-latest' shell: pwsh run: | cargo build --release Compress-Archive -Path target/release/stahl.exe -DestinationPath stahl-capital-windows-x64.zip $hash = (Get-FileHash stahl-capital-windows-x64.zip -Algorithm SHA256).Hash.ToLower() "$hash stahl-capital-windows-x64.zip" | Out-File -Encoding ascii stahl-capital-windows-x64.zip.sha256 - uses: actions/upload-artifact@v7 with: name: installer-${{ matrix.platform }} path: | *.dmg *.deb *.zip *.sha256 if-no-files-found: error # One job after all the builds, so a failed build can't publish a release with installers missing. # It runs on PRs too, so everything but the publishing itself is tested before a tag needs it. release: needs: build runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v7 - name: check the tag matches Cargo.toml if: startsWith(github.ref, 'refs/tags/') run: | version=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2) if [ "$GITHUB_REF_NAME" != "v$version" ]; then echo "::error::tag $GITHUB_REF_NAME doesn't match version $version in Cargo.toml" exit 1 fi - uses: actions/download-artifact@v8 with: pattern: installer-* path: installers merge-multiple: true - name: check every installer is there run: | ls -l installers ls installers/*.dmg installers/*.deb installers/*.zip - uses: softprops/action-gh-release@v3 if: startsWith(github.ref, 'refs/tags/') with: name: "Stahl Capital ${{ github.ref_name }}" generate_release_notes: true fail_on_unmatched_files: true files: installers/*