|
| 1 | +# SPDX-FileCopyrightText: Copyright 2025 Stacklok, Inc. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: Release |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - "v*" |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + packages: write |
| 14 | + |
| 15 | +env: |
| 16 | + GOPRIVATE: github.com/stacklok/* |
| 17 | + GH_TOKEN: ${{ secrets.GO_MODULE_TOKEN || github.token }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + name: Build (${{ matrix.os }}-${{ matrix.arch }}) |
| 22 | + runs-on: ${{ matrix.runner }} |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - os: linux |
| 27 | + arch: amd64 |
| 28 | + runner: ubuntu-latest |
| 29 | + - os: linux |
| 30 | + arch: arm64 |
| 31 | + runner: ubuntu-24.04-arm |
| 32 | + - os: darwin |
| 33 | + arch: arm64 |
| 34 | + runner: macos-15 |
| 35 | + steps: |
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v6 |
| 38 | + |
| 39 | + - name: Set up Go |
| 40 | + uses: actions/setup-go@v6 |
| 41 | + with: |
| 42 | + go-version-file: go.mod |
| 43 | + cache: true |
| 44 | + |
| 45 | + - name: Configure Git for private modules |
| 46 | + run: | |
| 47 | + git config --global url."https://${{ github.actor }}:${{ secrets.GO_MODULE_TOKEN }}@github.com/".insteadOf "https://github.com/" |
| 48 | +
|
| 49 | + - name: Install Task |
| 50 | + uses: go-task/setup-task@v1 |
| 51 | + |
| 52 | + - name: Build bbox |
| 53 | + run: task build |
| 54 | + |
| 55 | + - name: Verify version |
| 56 | + run: | |
| 57 | + echo "Binary reports: $(./bin/bbox --version)" |
| 58 | + echo "Expected tag: ${{ github.ref_name }}" |
| 59 | +
|
| 60 | + - name: Package binary |
| 61 | + run: | |
| 62 | + mkdir -p dist |
| 63 | + tar -czf dist/bbox-${{ matrix.os }}-${{ matrix.arch }}.tar.gz -C bin bbox |
| 64 | +
|
| 65 | + - name: Upload artifact |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: bbox-${{ matrix.os }}-${{ matrix.arch }} |
| 69 | + path: dist/bbox-${{ matrix.os }}-${{ matrix.arch }}.tar.gz |
| 70 | + |
| 71 | + release: |
| 72 | + name: Create Release |
| 73 | + runs-on: ubuntu-latest |
| 74 | + needs: [build] |
| 75 | + steps: |
| 76 | + - name: Checkout repository |
| 77 | + uses: actions/checkout@v6 |
| 78 | + |
| 79 | + - name: Download all artifacts |
| 80 | + uses: actions/download-artifact@v4 |
| 81 | + with: |
| 82 | + merge-multiple: true |
| 83 | + |
| 84 | + - name: Generate checksums |
| 85 | + run: sha256sum bbox-*.tar.gz > sha256sums.txt |
| 86 | + |
| 87 | + - name: Create GitHub Release |
| 88 | + env: |
| 89 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + run: | |
| 91 | + if gh release view "${{ github.ref_name }}" >/dev/null 2>&1; then |
| 92 | + gh release upload "${{ github.ref_name }}" --clobber \ |
| 93 | + bbox-*.tar.gz sha256sums.txt |
| 94 | + else |
| 95 | + gh release create "${{ github.ref_name }}" --generate-notes \ |
| 96 | + bbox-*.tar.gz sha256sums.txt |
| 97 | + fi |
0 commit comments