ci: add release workflow to build and push Docker image on tag
Triggers on v* tags, builds multi-arch images (amd64+arm64), pushes to codeberg.org/towerops-agent/towerops-agent with :latest and :<version> tags.
This commit is contained in:
parent
3babeb8391
commit
1040353b93
1 changed files with 53 additions and 0 deletions
53
.forgejo/workflows/release.yml
Normal file
53
.forgejo/workflows/release.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: https://code.forgejo.org/actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: https://github.com/docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: https://github.com/docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Codeberg Container Registry
|
||||
uses: https://github.com/docker/login-action@v3
|
||||
with:
|
||||
registry: codeberg.org
|
||||
username: ${{ secrets.CODEBERG_USER }}
|
||||
password: ${{ secrets.CODEBERG_TOKEN }}
|
||||
|
||||
- name: Extract version from tag
|
||||
id: version
|
||||
run: echo "tag=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: https://github.com/docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
build-args: |
|
||||
VERSION=${{ steps.version.outputs.tag }}
|
||||
tags: |
|
||||
codeberg.org/towerops-agent/towerops-agent:latest
|
||||
codeberg.org/towerops-agent/towerops-agent:${{ steps.version.outputs.tag }}
|
||||
|
||||
- name: Run tests
|
||||
run: go test -race -v -count=1 -timeout 60s ./...
|
||||
|
||||
- name: Vet
|
||||
run: go vet ./...
|
||||
Loading…
Add table
Reference in a new issue