Skip to content

Release

Release #24

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
tag:
default: 'latest'
required: true
description: 'Docker image tag'
push:
tags:
- 'v*'
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to the GPR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Parse Tag Name
run: |
if [ x${{ github.event.inputs.tag }} == x"" ]; then
echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
fi
- name: Build and push
uses: docker/build-push-action@v4
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1 # https://github.com/orgs/community/discussions/45969
with:
platforms: linux/amd64,linux/arm64
push: true
pull: true
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.licenses=Apache-2.0
tags: |
${{ github.repository }}:${{ env.TAG_NAME }}
ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }}
cache-from: type=gha # https://docs.docker.com/build/cache/backends/gha/
cache-to: type=gha,mode=max
goreleaser:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.tag == '' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v4
with:
cache: false
go-version-file: go.mod
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}