Skip to content

chore: add release workflow #61

chore: add release workflow

chore: add release workflow #61

Workflow file for this run

name: CI
on: push
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build_and_test:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
- name: Install dependencies
run: go mod download
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
build_docker:
if: startsWith(github.event.ref, 'refs/tags/v')
name: Build and publish docker images
needs: build_and_test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=raw,value=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
push: true
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: |
GENESIS_BUILD_VERSION=${{ github.ref_name }}
GENESIS_BUILD_COMMIT=${{ github.sha }}
GENESIS_BUILD_DATE=${{ github.event.head_commit.timestamp }}
publish_release:
if: startsWith(github.event.ref, 'refs/tags/v')
name: Publish new release
needs: build_and_test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract changes
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}
- name: Publish release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.changes }}