.github/workflows/release.yml

Summary

Maintainability
Test Coverage
name: Release

on:
  push:
    tags:
    - "v*"

jobs:
  dist:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        fetch-depth: 0

    - name: Determine Go version from go.mod
      run: echo "GO_VERSION=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV

    - uses: actions/setup-go@v3
      with:
        go-version: ${{ env.GO_VERSION }}

    - name: Set up QEMU
      uses: docker/setup-qemu-action@v2
    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v2

    - uses: actions/cache@v3
      with:
        path: ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-

    - name: Login to quay.io
      uses: docker/login-action@v2
      with:
        registry: quay.io
        username: ${{ secrets.QUAY_IO_USERNAME }}
        password: ${{ secrets.QUAY_IO_PASSWORD }}

    - name: Login to GHCR
      uses: docker/login-action@v2
      with:
        registry: ghcr.io
        username: ${{ github.repository_owner }}
        password: ${{ secrets.GITHUB_TOKEN }}

    - name: Build changelog from PRs with labels
      id: build_changelog
      uses: mikepenz/release-changelog-builder-action@v3
      with:
        configuration: ".github/changelog-configuration.json"
        # PreReleases still get a changelog, but the next full release gets a diff since the last full release,
        # combining possible changelogs of all previous PreReleases in between. PreReleases show a partial changelog
        # since last PreRelease.
        ignorePreReleases: "${{ !contains(github.ref, '-rc') }}"
        outputFile: .github/release-notes.md
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    - name: Publish releases
      uses: goreleaser/goreleaser-action@v4
      with:
        args: release --release-notes .github/release-notes.md
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}