Release #1
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: | |
| create_release: | |
| description: "Create a draft GitHub Release from build artifacts" | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: "0" | |
| RUST_BACKTRACE: "1" | |
| jobs: | |
| build: | |
| name: ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 180 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: macOS aarch64 | |
| os: macos-14 | |
| target: aarch64-apple-darwin | |
| artifact: terry-macos-aarch64 | |
| package: macos | |
| - name: macOS x86_64 | |
| os: macos-13 | |
| target: x86_64-apple-darwin | |
| artifact: terry-macos-x86_64 | |
| package: macos | |
| - name: Linux x86_64 | |
| os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| artifact: terry-linux-x86_64 | |
| package: linux | |
| - name: Windows x86_64 | |
| os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact: terry-windows-x86_64 | |
| package: windows | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Linux dependencies | |
| if: matrix.package == 'linux' | |
| run: | | |
| sudo apt-get update | |
| sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
| build-essential \ | |
| clang \ | |
| cmake \ | |
| curl \ | |
| git \ | |
| jq \ | |
| libasound2-dev \ | |
| libfontconfig-dev \ | |
| libsqlite3-dev \ | |
| libssl-dev \ | |
| libwayland-dev \ | |
| libx11-dev \ | |
| libxcb-xfixes0-dev \ | |
| libxkbcommon-dev \ | |
| libxkbcommon-x11-dev \ | |
| libzstd-dev \ | |
| libvulkan-dev \ | |
| pkg-config | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: "1.95.0" | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: release-${{ matrix.target }} | |
| cache-targets: true | |
| - name: Resolve version | |
| id: version | |
| shell: bash | |
| run: | | |
| if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| else | |
| VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" | |
| VERSION="${VERSION:-0.0.0}+${GITHUB_SHA::7}" | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
| - name: Package macOS | |
| if: matrix.package == 'macos' | |
| shell: bash | |
| run: | | |
| chmod +x script/package-macos.sh | |
| script/package-macos.sh "${{ matrix.target }}" | |
| mkdir -p dist | |
| cp -f target/release/Terry-*-macos-*.zip dist/ | |
| - name: Package Linux | |
| if: matrix.package == 'linux' | |
| shell: bash | |
| run: | | |
| chmod +x script/package-linux.sh | |
| script/package-linux.sh "${{ matrix.target }}" | |
| mkdir -p dist | |
| cp -f target/release/Terry-*-linux-*.tar.gz dist/ | |
| - name: Package Windows | |
| if: matrix.package == 'windows' | |
| shell: pwsh | |
| run: | | |
| $zip = & script/package-windows.ps1 -Target "${{ matrix.target }}" -Version $env:VERSION | |
| New-Item -ItemType Directory -Force -Path dist | Out-Null | |
| Copy-Item -Force $zip dist/ | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact }} | |
| path: dist/* | |
| if-no-files-found: error | |
| retention-days: 14 | |
| release: | |
| name: Publish GitHub Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: | | |
| always() && | |
| needs.build.result == 'success' && | |
| ( | |
| (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || | |
| (github.event_name == 'workflow_dispatch' && inputs.create_release == true) | |
| ) | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: List artifacts | |
| run: find artifacts -type f | sort | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || format('build-{0}', github.run_id) }} | |
| name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || format('Terry build {0}', github.run_id) }} | |
| draft: ${{ !startsWith(github.ref, 'refs/tags/v') }} | |
| generate_release_notes: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| files: artifacts/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |