watchtower/.github/workflows/release.yaml
2025-01-05 12:29:13 +01:00

117 lines
3.4 KiB
YAML

name: Release (Production)
on:
workflow_dispatch: {}
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- '**/v[0-9]+.[0-9]+.[0-9]+'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
- uses: dominikh/staticcheck-action@fe1dd0c3658873b46f8c9bb3291096a617310ca6 # v1.3.1
with:
version: "latest"
install-go: "false" # StaticCheck uses go v1.17 which does not support `any`
test:
name: Test
strategy:
matrix:
go-version:
- 1.23.x
platform:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
- name: Run tests
run: |
go test ./... -coverprofile coverage.out
build:
name: Build
runs-on: ubuntu-latest
needs:
- test
- lint
env:
CGO_ENABLED: 0
TAG: ${{ github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
- name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6
with:
version: v0.155.0
args: --debug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable experimental docker features
run: |
mkdir -p ~/.docker/ && \
echo '{"experimental": "enabled"}' > ~/.docker/config.json
- name: Create manifest for version
run: |
export DH_TAG=$(git tag --points-at HEAD | sed 's/^v*//')
docker manifest create \
beatkind/watchtower:$DH_TAG \
beatkind/watchtower:amd64-$DH_TAG \
beatkind/watchtower:i386-$DH_TAG \
beatkind/watchtower:armhf-$DH_TAG \
beatkind/watchtower:arm64v8-$DH_TAG
- name: Create manifest for latest
run: |
docker manifest create \
beatkind/watchtower:latest \
beatkind/watchtower:amd64-latest \
beatkind/watchtower:i386-latest \
beatkind/watchtower:armhf-latest \
beatkind/watchtower:arm64v8-latest
- name: Push manifests to Dockerhub
env:
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
docker login -u $DOCKER_USER -p $DOCKER_TOKEN && \
docker manifest push beatkind/watchtower:$(echo $TAG | sed 's/^v*//') && \
docker manifest push beatkind/watchtower:latest
renew-docs:
name: Refresh pkg.go.dev
needs: build
runs-on: ubuntu-latest
steps:
- name: Pull new module version
uses: andrewslotin/go-proxy-pull-action@89382de145eeb7a85de72f8a27f686a50727bc7a #master@2022-10-14