| 1 |
name: release |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
tags: |
| 7 |
- 'v*' |
| 8 |
pull_request: |
| 9 |
|
| 10 |
jobs: |
| 11 |
release: |
| 12 |
strategy: |
| 13 |
matrix: |
| 14 |
go-version: [1.19.x] |
| 15 |
os: [ubuntu-latest] |
| 16 |
|
| 17 |
name: Release for (${{ matrix.os}}, Go ${{ matrix.go-version }}) |
| 18 |
permissions: |
| 19 |
contents: write |
| 20 |
runs-on: ${{ matrix.os }} |
| 21 |
steps: |
| 22 |
- uses: actions/checkout@v3 |
| 23 |
with: |
| 24 |
fetch-depth: 0 |
| 25 |
- uses: actions/setup-go@v3 |
| 26 |
with: |
| 27 |
go-version: ${{ matrix.go-version }} |
| 28 |
cache: true |
| 29 |
- shell: bash |
| 30 |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 31 |
- id: cache |
| 32 |
uses: actions/cache@v3 |
| 33 |
with: |
| 34 |
path: dist/${{ matrix.os }} |
| 35 |
key: ${{ matrix.go }}-${{ env.sha_short }} |
| 36 |
- name: Build all packages |
| 37 |
run: go build -v ./... |
| 38 |
- name: Run GoReleaser |
| 39 |
uses: goreleaser/goreleaser-action@v3 |
| 40 |
if: success() && startsWith(github.ref, 'refs/tags/') && steps.cache.outputs.cache-hit != 'true' |
| 41 |
with: |
| 42 |
version: latest |
| 43 |
args: release --clean |
| 44 |
env: |
| 45 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |