|
| 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 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Build (${{ matrix.target }}) |
| 18 | + runs-on: ${{ matrix.runner }} |
| 19 | + timeout-minutes: 60 |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - target: x86_64-unknown-linux-gnu |
| 25 | + runner: ubuntu-latest |
| 26 | + cross: false |
| 27 | + - target: aarch64-unknown-linux-gnu |
| 28 | + runner: ubuntu-latest |
| 29 | + cross: true |
| 30 | + - target: x86_64-apple-darwin |
| 31 | + runner: macos-latest |
| 32 | + cross: false |
| 33 | + - target: aarch64-apple-darwin |
| 34 | + runner: macos-latest |
| 35 | + cross: false |
| 36 | + - target: x86_64-pc-windows-msvc |
| 37 | + runner: windows-latest |
| 38 | + cross: false |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v6 |
| 41 | + - uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 |
| 42 | + with: |
| 43 | + targets: ${{ matrix.target }} |
| 44 | + - name: Install cross |
| 45 | + if: matrix.cross |
| 46 | + run: cargo install cross --locked |
| 47 | + - name: Build with cross |
| 48 | + if: matrix.cross |
| 49 | + run: cross build --release --target ${{ matrix.target }} |
| 50 | + - name: Build with cargo |
| 51 | + if: "!matrix.cross" |
| 52 | + run: cargo build --release --target ${{ matrix.target }} |
| 53 | + - name: Archive (unix) |
| 54 | + if: runner.os != 'Windows' |
| 55 | + run: | |
| 56 | + cd target/${{ matrix.target }}/release |
| 57 | + tar czf ../../../typdiff-${{ matrix.target }}.tar.gz typdiff |
| 58 | + cd ../../.. |
| 59 | + - name: Archive (windows) |
| 60 | + if: runner.os == 'Windows' |
| 61 | + shell: pwsh |
| 62 | + run: | |
| 63 | + Compress-Archive -Path target/${{ matrix.target }}/release/typdiff.exe -DestinationPath typdiff-${{ matrix.target }}.zip |
| 64 | + - uses: actions/upload-artifact@v6 |
| 65 | + with: |
| 66 | + name: typdiff-${{ matrix.target }} |
| 67 | + path: typdiff-${{ matrix.target }}.* |
| 68 | + if-no-files-found: error |
| 69 | + |
| 70 | + release: |
| 71 | + name: Release |
| 72 | + needs: build |
| 73 | + runs-on: ubuntu-latest |
| 74 | + timeout-minutes: 10 |
| 75 | + steps: |
| 76 | + - uses: actions/download-artifact@v7 |
| 77 | + with: |
| 78 | + path: artifacts |
| 79 | + merge-multiple: true |
| 80 | + - name: Create GitHub Release |
| 81 | + uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 |
| 82 | + with: |
| 83 | + generate_release_notes: true |
| 84 | + files: artifacts/* |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + |
| 88 | + publish: |
| 89 | + name: Publish to crates.io |
| 90 | + needs: build |
| 91 | + runs-on: ubuntu-latest |
| 92 | + timeout-minutes: 10 |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v6 |
| 95 | + - uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 |
| 96 | + - name: Publish |
| 97 | + run: cargo publish |
| 98 | + env: |
| 99 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
0 commit comments