master
1name: Release
2on:
3 push:
4 tags:
5 - "*"
6 # pull_request: # debug
7permissions:
8 contents: write
9 id-token: write
10 attestations: write
11jobs:
12 release-binary:
13 strategy:
14 # fail-fast: false # debug
15 matrix:
16 os: [linux, darwin, windows]
17 arch: [amd64, arm64, arm32]
18 exclude:
19 - os: darwin
20 arch: arm32
21 - os: windows
22 arch: arm32
23 - os: windows
24 arch: arm64
25 runs-on: ${{ (matrix.os != 'darwin' && 'ubuntu-latest') || 'macos-latest' }}
26 steps:
27 - name: Checkout
28 uses: actions/checkout@v6
29 with:
30 fetch-depth: 0
31 # --------- setup cross compilers ---------
32 - name: Install cross-compilers
33 run: |
34 if [ "${{ matrix.os }}" == "linux" ]; then
35 sudo apt update
36 sudo apt-get install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf
37 elif [ "${{ matrix.os }}" == "windows" ]; then
38 sudo apt update
39 sudo apt-get install gcc-mingw-w64-x86-64
40 fi
41 # --------- setup rust ---------
42 - name: Setup Rust
43 uses: actions-rust-lang/setup-rust-toolchain@v1
44 with:
45 toolchain: stable
46 cache: true
47 cache-workspaces: ./lib/system
48 cache-key: ${{ runner.os }}
49 - name: Add Rust targets
50 run: |
51 if [ "${{ matrix.os }}" == "linux" ]; then
52 rustup target add armv7-unknown-linux-gnueabihf
53 rustup target add aarch64-unknown-linux-gnu
54 elif [ "${{ matrix.os }}" == "darwin" ]; then
55 rustup target add x86_64-apple-darwin
56 rustup target add aarch64-apple-darwin
57 elif [ "${{ matrix.os }}" == "windows" ]; then
58 rustup target add x86_64-pc-windows-gnu
59 fi
60 - name: Setup cross toolchain
61 run: cargo install cross
62 # --------- setup go ---------
63 - name: Set up Go
64 uses: actions/setup-go@v6
65 with:
66 go-version: stable
67 # --------- goreleaser ---------
68 - name: Release
69 uses: goreleaser/goreleaser-action@v7
70 with:
71 distribution: goreleaser
72 version: "~> v2"
73 args: release --clean --config .goreleaser-${{ matrix.os }}-${{ matrix.arch }}.yaml
74 # args: build --skip validate --clean --config .goreleaser-${{ matrix.os }}-${{ matrix.arch }}.yaml # debug
75 env:
76 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77 attestation:
78 runs-on: ubuntu-latest
79 needs: release-binary
80 steps:
81 - name: Set tag name
82 id: name
83 run: |
84 TAG_NAME="${{ github.ref_name }}"
85 # TAG_NAME="v0.8.0" # debug
86 echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
87 # --------- attestation ---------
88 - uses: robinraju/release-downloader@v1
89 with:
90 tag: ${{ steps.name.outputs.TAG_NAME }}
91 fileName: "*"
92 - name: Generate artifact attestation
93 uses: actions/attest-build-provenance@v3
94 with:
95 subject-path: .