|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +env: |
| 13 | + CARGO_TERM_COLOR: always |
| 14 | + BIN_NAME: rustickers |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-upload: |
| 18 | + name: Build (${{ matrix.artifact_suffix }}) |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - os: windows-latest |
| 25 | + target: x86_64-pc-windows-msvc |
| 26 | + artifact_suffix: windows-x86_64 |
| 27 | + binary_ext: ".exe" |
| 28 | + - os: ubuntu-latest |
| 29 | + target: x86_64-unknown-linux-gnu |
| 30 | + artifact_suffix: linux-x86_64 |
| 31 | + binary_ext: "" |
| 32 | + - os: macos-13 |
| 33 | + target: x86_64-apple-darwin |
| 34 | + artifact_suffix: macos-x86_64 |
| 35 | + binary_ext: "" |
| 36 | + - os: macos-14 |
| 37 | + target: aarch64-apple-darwin |
| 38 | + artifact_suffix: macos-aarch64 |
| 39 | + binary_ext: "" |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout |
| 43 | + uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Install Rust |
| 46 | + uses: dtolnay/rust-toolchain@stable |
| 47 | + with: |
| 48 | + targets: ${{ matrix.target }} |
| 49 | + |
| 50 | + - name: Rust cache |
| 51 | + uses: Swatinem/rust-cache@v2 |
| 52 | + with: |
| 53 | + shared-key: release-${{ matrix.target }} |
| 54 | + |
| 55 | + - name: Install Linux build dependencies |
| 56 | + if: runner.os == 'Linux' |
| 57 | + run: | |
| 58 | + sudo apt-get update |
| 59 | + sudo apt-get install -y --no-install-recommends \ |
| 60 | + zip \ |
| 61 | + pkg-config \ |
| 62 | + libx11-dev \ |
| 63 | + libxcursor-dev \ |
| 64 | + libxrandr-dev \ |
| 65 | + libxi-dev \ |
| 66 | + libxkbcommon-dev \ |
| 67 | + libwayland-dev \ |
| 68 | + libfontconfig1-dev \ |
| 69 | + libfreetype6-dev \ |
| 70 | + libegl1-mesa-dev \ |
| 71 | + libgl1-mesa-dev |
| 72 | +
|
| 73 | + - name: Build (release) |
| 74 | + run: cargo build --release --locked --target ${{ matrix.target }} |
| 75 | + |
| 76 | + - name: Package (Windows) |
| 77 | + if: runner.os == 'Windows' |
| 78 | + shell: pwsh |
| 79 | + run: | |
| 80 | + $ErrorActionPreference = 'Stop' |
| 81 | +
|
| 82 | + $bin = "${env:BIN_NAME}${{ matrix.binary_ext }}" |
| 83 | + $src = "target\\${{ matrix.target }}\\release\\$bin" |
| 84 | + if (-not (Test-Path $src)) { |
| 85 | + throw "Binary not found at $src" |
| 86 | + } |
| 87 | +
|
| 88 | + New-Item -ItemType Directory -Force -Path dist | Out-Null |
| 89 | + Copy-Item $src -Destination dist\ -Force |
| 90 | +
|
| 91 | + # Include common docs if present |
| 92 | + Get-ChildItem -Path . -Filter "README*" -File -ErrorAction SilentlyContinue | ForEach-Object { Copy-Item $_.FullName -Destination dist\ -Force } |
| 93 | + if (Test-Path "LICENSE") { Copy-Item "LICENSE" -Destination dist\ -Force } |
| 94 | +
|
| 95 | + $zip = "${env:BIN_NAME}-${env:GITHUB_REF_NAME}-${{ matrix.artifact_suffix }}.zip" |
| 96 | + if (Test-Path $zip) { Remove-Item $zip -Force } |
| 97 | + Compress-Archive -Path "dist\\*" -DestinationPath $zip -Force |
| 98 | +
|
| 99 | + - name: Package (Linux/macOS) |
| 100 | + if: runner.os != 'Windows' |
| 101 | + shell: bash |
| 102 | + run: | |
| 103 | + set -euo pipefail |
| 104 | +
|
| 105 | + bin="${BIN_NAME}${{ matrix.binary_ext }}" |
| 106 | + src="target/${{ matrix.target }}/release/${BIN_NAME}" |
| 107 | + if [[ ! -f "$src" ]]; then |
| 108 | + echo "Binary not found at $src" >&2 |
| 109 | + exit 1 |
| 110 | + fi |
| 111 | +
|
| 112 | + rm -rf dist |
| 113 | + mkdir -p dist |
| 114 | + cp "$src" "dist/$bin" |
| 115 | +
|
| 116 | + if [[ -f "README.md" ]]; then cp README.md dist/; fi |
| 117 | + if [[ -f "README" ]]; then cp README dist/; fi |
| 118 | + if [[ -f "LICENSE" ]]; then cp LICENSE dist/; fi |
| 119 | +
|
| 120 | + zip_name="${BIN_NAME}-${GITHUB_REF_NAME}-${{ matrix.artifact_suffix }}.zip" |
| 121 | + (cd dist && zip -r "../$zip_name" .) |
| 122 | +
|
| 123 | + - name: Upload to GitHub Release |
| 124 | + uses: softprops/action-gh-release@v2 |
| 125 | + with: |
| 126 | + files: "${{ env.BIN_NAME }}-${{ github.ref_name }}-${{ matrix.artifact_suffix }}.zip" |
| 127 | + fail_on_unmatched_files: true |
0 commit comments