| 1 | name: Build |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | tags: |
| 6 | - 'v*' |
| 7 | workflow_dispatch: |
| 8 | |
| 9 | permissions: |
| 10 | contents: write |
| 11 | |
| 12 | jobs: |
| 13 | build-windows: |
| 14 | runs-on: windows-latest |
| 15 | |
| 16 | steps: |
| 17 | - name: Checkout code |
| 18 | uses: actions/checkout@v4 |
| 19 | |
| 20 | - name: Install Rust |
| 21 | uses: dtolnay/rust-toolchain@stable |
| 22 | with: |
| 23 | toolchain: stable |
| 24 | |
| 25 | - name: Build fackr |
| 26 | run: cargo build --release |
| 27 | |
| 28 | - name: Create release archive |
| 29 | shell: pwsh |
| 30 | run: | |
| 31 | $version = (Get-Content Cargo.toml | Select-String 'version = "(.+)"' | ForEach-Object { $_.Matches.Groups[1].Value } | Select-Object -First 1) |
| 32 | New-Item -ItemType Directory -Force -Path release |
| 33 | Copy-Item target/release/fackr.exe release/ |
| 34 | Compress-Archive -Path release/* -DestinationPath "fackr-$version-windows-x86_64.zip" |
| 35 | |
| 36 | - name: Upload artifact |
| 37 | uses: actions/upload-artifact@v4 |
| 38 | with: |
| 39 | name: fackr-windows-x86_64 |
| 40 | path: fackr-*-windows-x86_64.zip |
| 41 | |
| 42 | - name: Release |
| 43 | uses: softprops/action-gh-release@v1 |
| 44 | if: startsWith(github.ref, 'refs/tags/') |
| 45 | with: |
| 46 | files: fackr-*-windows-x86_64.zip |
| 47 | env: |
| 48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | |
| 50 | build-linux: |
| 51 | runs-on: ubuntu-latest |
| 52 | |
| 53 | steps: |
| 54 | - name: Checkout code |
| 55 | uses: actions/checkout@v4 |
| 56 | |
| 57 | - name: Install Rust |
| 58 | uses: dtolnay/rust-toolchain@stable |
| 59 | with: |
| 60 | toolchain: stable |
| 61 | |
| 62 | - name: Build fackr |
| 63 | run: cargo build --release |
| 64 | |
| 65 | - name: Create release archive |
| 66 | run: | |
| 67 | VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') |
| 68 | mkdir -p release |
| 69 | cp target/release/fackr release/ |
| 70 | cd release |
| 71 | tar -czvf ../fackr-${VERSION}-linux-x86_64.tar.gz * |
| 72 | |
| 73 | - name: Upload artifact |
| 74 | uses: actions/upload-artifact@v4 |
| 75 | with: |
| 76 | name: fackr-linux-x86_64 |
| 77 | path: fackr-*-linux-x86_64.tar.gz |
| 78 | |
| 79 | - name: Release |
| 80 | uses: softprops/action-gh-release@v1 |
| 81 | if: startsWith(github.ref, 'refs/tags/') |
| 82 | with: |
| 83 | files: fackr-*-linux-x86_64.tar.gz |
| 84 | env: |
| 85 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | |
| 87 | build-macos: |
| 88 | runs-on: macos-latest |
| 89 | |
| 90 | steps: |
| 91 | - name: Checkout code |
| 92 | uses: actions/checkout@v4 |
| 93 | |
| 94 | - name: Install Rust |
| 95 | uses: dtolnay/rust-toolchain@stable |
| 96 | with: |
| 97 | toolchain: stable |
| 98 | |
| 99 | - name: Build fackr |
| 100 | run: cargo build --release |
| 101 | |
| 102 | - name: Create release archive |
| 103 | run: | |
| 104 | VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') |
| 105 | ARCH=$(uname -m) |
| 106 | mkdir -p release |
| 107 | cp target/release/fackr release/ |
| 108 | cd release |
| 109 | tar -czvf ../fackr-${VERSION}-macos-${ARCH}.tar.gz * |
| 110 | |
| 111 | - name: Upload artifact |
| 112 | uses: actions/upload-artifact@v4 |
| 113 | with: |
| 114 | name: fackr-macos |
| 115 | path: fackr-*-macos-*.tar.gz |
| 116 | |
| 117 | - name: Release |
| 118 | uses: softprops/action-gh-release@v1 |
| 119 | if: startsWith(github.ref, 'refs/tags/') |
| 120 | with: |
| 121 | files: fackr-*-macos-*.tar.gz |
| 122 | env: |
| 123 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 124 |