Skip to content

Merge pull request #20 from amoniacou/release/v1.3.1 #27

Merge pull request #20 from amoniacou/release/v1.3.1

Merge pull request #20 from amoniacou/release/v1.3.1 #27

Workflow file for this run

name: release-publish
on:
push:
tags:
- v*
env:
GOLANG_VERSION: "1.23.x"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
name: Build containers
permissions:
packages: write
contents: write
attestations: write
id-token: write
runs-on: ubuntu-latest
outputs:
version: ${{ steps.build-meta.outputs.version }}
digest: ${{ steps.build.outputs.digest }}
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
# To identify the commit we need the history and all the tags.
fetch-depth: 0
-
name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}
-
name: Build meta
id: build-meta
run: |
set -x
commit_sha=${{ github.sha }}
commit_date=$(git log -1 --pretty=format:'%ad' --date short "${commit_sha}")
tag="${GITHUB_REF#refs/tags/v}"
# use git describe to get the nearest tag and use that to build the version (e.g. 1.4.0+dev24 or 1.4.0)
commit_version=$(git describe --tags --match 'v*' "${commit_sha}"| sed -e 's/^v//; s/-g[0-9a-f]\+$//; s/-\([0-9]\+\)$/+dev\1/')
commit_short=$(git rev-parse --short "${commit_sha}")
echo "DATE=${commit_date}" >> $GITHUB_ENV
echo "VERSION=${commit_version}" >> $GITHUB_OUTPUT
echo "COMMIT=${commit_short}" >> $GITHUB_ENV
-
name: Set GoReleaser environment
run: |
echo GOPATH=$(go env GOPATH) >> $GITHUB_ENV
echo PWD=$(pwd) >> $GITHUB_ENV
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
DATE: ${{ env.DATE }}
COMMIT: ${{ env.COMMIT }}
VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
-
name: Detect platforms
id: docker-platforms
run: |
# Keep in mind that adding more platforms (architectures) will increase the building
# time even if we use the ghcache for the building process.
platforms="linux/amd64,linux/arm64"
echo "PLATFORMS=${platforms}" >> $GITHUB_ENV
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ env.PLATFORMS }}
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
id: push
uses: docker/build-push-action@v3.2.0
with:
platforms: ${{ env.PLATFORMS }}
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true