Skip to content

Update workflow #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,45 @@ name: Build, Test, & Publish
on:
push:
branches: [ main ]
paths-ignore:
- "**.md"
- "LICENSE"
pull_request:
branches: [ main ]

env:
GO_VERSION: ~1.22
paths-ignore:
- "**.md"
- "LICENSE"

jobs:
unit_tests:
name: unit tests
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
go-version-file: go.mod

- name: Unit tests
run: go test -v ./...

build_dev_image:
name: build dev image
name: Build dev image
runs-on: ubuntu-latest
needs: unit_tests
permissions:
contents: 'write'
id-token: 'write'
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
go-version-file: go.mod

- name: OCI Metadata for multi-arch image
id: meta
uses: docker/metadata-action@v5
Expand All @@ -46,28 +52,35 @@ jobs:
type=sha
type=ref,event=pr
type=semver,pattern={{version}}

- uses: docker/setup-qemu-action@v3

- uses: docker/setup-buildx-action@v3
- if: github.event_name != 'pull_request'
uses: docker/login-action@v3

- uses: docker/login-action@v3
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# We want to always build the image, and push to registry only on new tag i.e. new release
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x
push: ${{ github.event_name != 'pull_request' }}
push: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

release:
name: Release to GitHub Releases
runs-on: ubunut-latest
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: [ unit_tests, build_dev_image ]
steps:
- uses: actions/checkout@v4

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
Loading