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