From 1899884ab87d7d4c636e9d9ea220f12993220d1f Mon Sep 17 00:00:00 2001 From: Gerrit Date: Fri, 17 Apr 2026 07:46:36 +0200 Subject: [PATCH] Optional push for go-builds. Try outputting artifact name. Use in download, too. merge. --- .github/workflows/go-build.yaml | 22 +++++++++++++++++----- .github/workflows/release-assets.yaml | 10 ++++++++-- README.md | 1 + 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/go-build.yaml b/.github/workflows/go-build.yaml index 2e19fac..2e0c027 100644 --- a/.github/workflows/go-build.yaml +++ b/.github/workflows/go-build.yaml @@ -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. @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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: | @@ -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 diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml index e29e91e..75aa0c8 100644 --- a/.github/workflows/release-assets.yaml +++ b/.github/workflows/release-assets.yaml @@ -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. @@ -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 diff --git a/README.md b/README.md index a741fe3..87bf7c2 100644 --- a/README.md +++ b/README.md @@ -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 }}