Skip to content
Draft
Show file tree
Hide file tree
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
22 changes: 17 additions & 5 deletions .github/workflows/go-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ on:
default: true
type: boolean
build:
description: Runs a job to build the go project and publish a Docker container.
description: Runs a job to build the go project.
required: false
default: true
type: boolean
push:
description: Part of the build job to publish a Docker container.
required: false
default: true
type: boolean


build-command:
description: The command used to build the Go binaries in case needed before building the container.
Expand Down Expand Up @@ -56,6 +60,9 @@ on:
go-build-artifacts:
description: The uploaded build artifacts in case artifact-files were provided.
value: ${{ jobs.go-build.outputs.go-build-artifacts }}
go-build-artifact-name:
description: The name for the uploaded build artifacts in case artifact-files were provided.
value: ${{ jobs.go-build.outputs.go-build-artifact-name }}

env:
tag: "" # gets set dynamically during workflow run
Expand Down Expand Up @@ -85,7 +92,7 @@ jobs:
go-test:
name: Go Test
runs-on: ubuntu-latest
if: "${{ inputs.test }}"
if: inputs.test
steps:
- name: Checkout
uses: actions/checkout@v7
Expand All @@ -105,6 +112,7 @@ jobs:
if: inputs.build
outputs:
go-build-artifacts: ${{ steps.artifact-upload-step.outputs.artifact-id }}
go-build-artifact-name: ${{ github.run_id }}-${{ github.run_number }}#${{ github.run_attempt }}
steps:
- name: Registry login
uses: docker/login-action@v4
Expand Down Expand Up @@ -134,6 +142,7 @@ jobs:

- name: Setup Buildx
uses: docker/setup-buildx-action@v4
if: inputs.push

- name: Build and push
uses: docker/build-push-action@v7
Expand All @@ -143,6 +152,7 @@ jobs:
push: true
sbom: true
tags: ${{ inputs.registry }}/${{ inputs.image-name }}:${{ env.tag }}
if: inputs.push

- name: Build and push latest
uses: docker/build-push-action@v7
Expand All @@ -151,10 +161,11 @@ jobs:
push: true
sbom: true
tags: ${{ inputs.registry }}/${{ inputs.image-name }}:latest
if: github.event_name == 'release'
if: inputs.push && github.event_name == 'release'

- name: Install Cosign
uses: sigstore/cosign-installer@v4.1.2
if: inputs.push

- name: Sign image
run: |
Expand All @@ -164,11 +175,12 @@ jobs:
env:
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
if: inputs.push

- uses: actions/upload-artifact@v7
id: artifact-upload-step
with:
name: go-build-artifact
name: ${{ github.run_id }}-${{ github.run_number }}#${{ github.run_attempt }}
path: ${{ inputs.artifact-files }}
if-no-files-found: error
retention-days: 1
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/release-assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ on:
inputs:
artifact-ids:
description: The artifact ids from the upload-artifact job.
required: true
required: false
type: string
artifact-name:
description: The artifact name from the upload-artifact job.
required: false
type: string
files:
description: A file (pattern) to publish.
Expand All @@ -22,7 +26,9 @@ jobs:
steps:
- uses: actions/download-artifact@v8
with:
artifact-ids: ${{ inputs.artifact-ids }}
name: ${{ inputs.artifact-name || '' }}
artifact-ids: ${{ inputs.artifact-ids || '' }}
merge-multiple: true

- name: Upload Release Asset
uses: softprops/action-gh-release@v3
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
lint: true
test: true
build: true
push: true
test-command: go test ./... -coverprofile=coverage.out -covermode=atomic && go tool cover -func=coverage.out
registry: ghcr.io
registry-username: ${{ github.actor }}
Expand Down