|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build (${{ matrix.os }}) |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - os: ubuntu-latest |
| 20 | + target: linux-x86_64 |
| 21 | + - os: macos-latest |
| 22 | + target: macos-aarch64 |
| 23 | + - os: windows-latest |
| 24 | + target: windows-x86_64 |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v5 |
| 28 | + |
| 29 | + - name: Setup Rust |
| 30 | + uses: dtolnay/rust-toolchain@v1 |
| 31 | + with: |
| 32 | + toolchain: stable |
| 33 | + |
| 34 | + - name: Cache cargo |
| 35 | + uses: Swatinem/rust-cache@v2 |
| 36 | + with: |
| 37 | + shared-key: release-${{ matrix.os }} |
| 38 | + |
| 39 | + - name: Install Linux dependencies |
| 40 | + if: matrix.os == 'ubuntu-latest' |
| 41 | + run: | |
| 42 | + sudo apt-get update |
| 43 | + sudo apt-get install -y \ |
| 44 | + pkg-config \ |
| 45 | + zip \ |
| 46 | + libx11-dev \ |
| 47 | + libxkbcommon-dev \ |
| 48 | + libwayland-dev \ |
| 49 | + libxcb1-dev \ |
| 50 | + libxrandr-dev \ |
| 51 | + libxcursor-dev \ |
| 52 | + libxi-dev \ |
| 53 | + libxinerama-dev \ |
| 54 | + libgl1-mesa-dev \ |
| 55 | + libegl1-mesa-dev \ |
| 56 | + libxcb-shape0-dev \ |
| 57 | + libxcb-xfixes0-dev |
| 58 | +
|
| 59 | + - name: Build |
| 60 | + run: cargo build --release |
| 61 | + |
| 62 | + - name: Package (Linux) |
| 63 | + if: matrix.os == 'ubuntu-latest' |
| 64 | + run: | |
| 65 | + VERSION="${{ github.ref_name }}" |
| 66 | + ARCHIVE="curve-fit-${VERSION}-${{ matrix.target }}.zip" |
| 67 | + rm -f "$ARCHIVE" |
| 68 | + if [ -f README.md ]; then |
| 69 | + zip -j "$ARCHIVE" target/release/curve-fit README.md |
| 70 | + else |
| 71 | + zip -j "$ARCHIVE" target/release/curve-fit |
| 72 | + fi |
| 73 | +
|
| 74 | + - name: Package (Windows) |
| 75 | + if: matrix.os == 'windows-latest' |
| 76 | + shell: pwsh |
| 77 | + run: | |
| 78 | + $version = "${{ github.ref_name }}" |
| 79 | + $archive = "curve-fit-$version-${{ matrix.target }}.zip" |
| 80 | + if (Test-Path $archive) { Remove-Item $archive } |
| 81 | + $files = @("target/release/curve-fit.exe") |
| 82 | + if (Test-Path "README.md") { $files += "README.md" } |
| 83 | + Compress-Archive -Path $files -DestinationPath $archive -Force |
| 84 | +
|
| 85 | + - name: Package (macOS) |
| 86 | + if: matrix.os == 'macos-latest' |
| 87 | + run: | |
| 88 | + VERSION="${{ github.ref_name }}" |
| 89 | + ARCHIVE="curve-fit-${VERSION}-${{ matrix.target }}.zip" |
| 90 | + rm -f "$ARCHIVE" |
| 91 | + if [ -f README.md ]; then |
| 92 | + zip -j "$ARCHIVE" target/release/curve-fit README.md |
| 93 | + else |
| 94 | + zip -j "$ARCHIVE" target/release/curve-fit |
| 95 | + fi |
| 96 | +
|
| 97 | + - name: Upload artifact |
| 98 | + uses: actions/upload-artifact@v6 |
| 99 | + with: |
| 100 | + name: curve-fit-${{ github.ref_name }}-${{ matrix.target }} |
| 101 | + path: curve-fit-${{ github.ref_name }}-${{ matrix.target }}.zip |
| 102 | + |
| 103 | + release: |
| 104 | + name: Publish Release |
| 105 | + runs-on: ubuntu-latest |
| 106 | + needs: build |
| 107 | + steps: |
| 108 | + - name: Download artifacts |
| 109 | + uses: actions/download-artifact@v8 |
| 110 | + with: |
| 111 | + path: dist |
| 112 | + pattern: curve-fit-* |
| 113 | + merge-multiple: true |
| 114 | + |
| 115 | + - name: Publish GitHub Release |
| 116 | + env: |
| 117 | + GH_TOKEN: ${{ github.token }} |
| 118 | + TAG_NAME: ${{ github.ref_name }} |
| 119 | + run: | |
| 120 | + if gh release view "$TAG_NAME" >/dev/null 2>&1; then |
| 121 | + gh release upload "$TAG_NAME" dist/*.zip --clobber |
| 122 | + else |
| 123 | + gh release create "$TAG_NAME" dist/*.zip --title "$TAG_NAME" --generate-notes |
| 124 | + fi |
0 commit comments