|
| 1 | +name: goreleaser |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - next |
| 9 | + tags: |
| 10 | + - "*" |
| 11 | + release: |
| 12 | + types: |
| 13 | + - published |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + packages: write |
| 18 | + id-token: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + release: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 25 | + if: github.event_name == 'pull_request' |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + ref: ${{ github.event.pull_request.head.ref }} |
| 29 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 30 | + if: github.event_name != 'pull_request' |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + - name: setup-go |
| 34 | + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5 |
| 35 | + with: |
| 36 | + go-version: 1.23.x |
| 37 | + - uses: anchore/sbom-action/download-syft@df80a981bc6edbc4e220a492d3cbe9f5547a6e75 # v0.17.9 |
| 38 | + - name: setup qemu |
| 39 | + id: qemu |
| 40 | + uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3 |
| 41 | + - name: setup docker buildx |
| 42 | + id: buildx |
| 43 | + uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3 |
| 44 | + - name: Login to GitHub Container Registry |
| 45 | + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 |
| 46 | + with: |
| 47 | + registry: ghcr.io |
| 48 | + username: ${{ github.actor }} |
| 49 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + - name: install cosign |
| 51 | + uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3 |
| 52 | + - name: install quill |
| 53 | + env: |
| 54 | + QUILL_VERSION: 0.4.1 |
| 55 | + run: | |
| 56 | + curl -Lo /tmp/quill_${QUILL_VERSION}_linux_amd64.tar.gz https://github.com/anchore/quill/releases/download/v${QUILL_VERSION}/quill_${QUILL_VERSION}_linux_amd64.tar.gz |
| 57 | + tar -xvf /tmp/quill_${QUILL_VERSION}_linux_amd64.tar.gz -C /tmp |
| 58 | + mv /tmp/quill /usr/local/bin/quill |
| 59 | + chmod +x /usr/local/bin/quill |
| 60 | + - name: set goreleaser default args |
| 61 | + if: startsWith(github.ref, 'refs/tags/') == true |
| 62 | + run: | |
| 63 | + echo "GORELEASER_ARGS=" >> $GITHUB_ENV |
| 64 | + - name: set goreleaser args for branch |
| 65 | + if: startsWith(github.ref, 'refs/tags/') == false |
| 66 | + run: | |
| 67 | + echo "GORELEASER_ARGS=--snapshot" >> $GITHUB_ENV |
| 68 | + - name: set goreleaser args renovate |
| 69 | + if: startsWith(github.ref, 'refs/heads/renovate') == true |
| 70 | + run: | |
| 71 | + echo "GORELEASER_ARGS=--snapshot --skip publish --skip sign" >> $GITHUB_ENV |
| 72 | + - name: run goreleaser |
| 73 | + uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6 |
| 74 | + with: |
| 75 | + distribution: goreleaser |
| 76 | + version: latest |
| 77 | + args: release --clean ${{ env.GORELEASER_ARGS }} |
| 78 | + env: |
| 79 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + - name: push docker images (for branches) |
| 81 | + if: github.ref == 'refs/heads/main' || github.event.pull_request.base.ref == 'main' |
| 82 | + run: | |
| 83 | + docker images --format "{{.Repository}}:{{.Tag}}" | grep "${{ github.repository }}" | xargs -L1 docker push |
| 84 | + - name: upload artifacts |
| 85 | + if: github.event.pull_request.base.ref == 'main' |
| 86 | + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4 |
| 87 | + with: |
| 88 | + name: binaries |
| 89 | + path: releases/*.tar.gz |
0 commit comments