Skip to content

v0.1.2

v0.1.2 #61

name: Build and Publish
on:
pull_request:
types: ["opened", "synchronize"]
release:
types: ["published"]
jobs:
build-binary:
name: Build ${{matrix.os}}/${{matrix.arch}} binary
runs-on: ubuntu-latest
strategy:
matrix:
os: ["linux"]
arch: ["amd64", "arm64"]
env:
CGO_ENABLED: 0
GOOS: "${{matrix.os}}"
GOARCH: "${{matrix.arch}}"
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
- name: Setup Golang caches
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{runner.os}}-golang-${{matrix.os}}_${{matrix.arch}}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{runner.os}}-golang-${{matrix.os}}_${{matrix.arch}}-
- name: Vet
run: go vet -v ./...
- name: Test
run: go test -v ./...
- name: Build
run: go build -v -o 'bin/semver-tagger_${{matrix.os}}_${{matrix.arch}}' main.go
- uses: actions/upload-artifact@v3
with:
name: bin
path: bin/
publish-binaries:
name: Publish binaries to release
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: build-binary
steps:
- uses: actions/download-artifact@v3
with:
name: bin
path: bin
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bin/*
file_glob: true
overwrite: true
build-and-push-image:
name: Build image and push to repository
runs-on: ubuntu-latest
needs: build-binary
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: bin
path: bin
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/vflaux/semver-tagger
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build image
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}