Skip to content

Commit

Permalink
Add IMAGE_DIGEST output to release job
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Franssen <marco.franssen@philips.com>
  • Loading branch information
marcofranssen committed Dec 22, 2021
1 parent 33a20a0 commit 4dc7f6f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
release:
name: release
needs: [build]
outputs:
container_digest: ${{ steps.container_digest.outputs.container_digest }}
runs-on: ubuntu-20.04

steps:
Expand Down Expand Up @@ -105,6 +107,11 @@ jobs:
LDFLAGS: ${{ steps.release-vars.outputs.LDFLAGS }}
GIT_HASH: ${{ steps.release-vars.outputs.GIT_HASH }}

- name: Get container digest
id: container_digest
if: startsWith(github.ref, 'refs/tags/')
run: echo "::set-output name=container_digest::$(make container-digest GITHUB_REF=${GITHUB_REF})"

- name: Logout from Container registries
if: ${{ always() }}
run: |
Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ LDFLAGS="-X $(PKG).GitVersion=$(GIT_VERSION) -X $(PKG).gitCommit=$(GIT_HASH) -X
GO_BUILD_FLAGS := -trimpath -ldflags $(LDFLAGS)
COMMANDS := slsa-provenance

HUB_REPO := philipssoftware/slsa-provenance
GHCR_REPO := ghcr.io/philips-labs/slsa-provenance

check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
Expand Down Expand Up @@ -79,7 +82,10 @@ build: $(addprefix bin/,$(COMMANDS)) ## builds binaries
image: ## build the binary in a docker image
docker build \
-t "philipssoftware/slsa-provenance:$(GIT_TAG)" \
-t "philipssoftware/slsa-provenance:$(GIT_HASH)" .
-t "philipssoftware/slsa-provenance:$(GIT_HASH)" \
-t "ghcr.io/philips-labs/slsa-provenance:$(GIT_TAG)" \
-t "ghcr.io/philips-labs/slsa-provenance:$(GIT_HASH)" \
.

$(GO_PATH)/bin/goreleaser:
go install github.com/goreleaser/goreleaser@v0.182.1
Expand Down Expand Up @@ -119,3 +125,8 @@ gh-release: ## Creates a new release by creating a new tag and pushing it
@echo
@git stash pop

.PHONY: container-digest
container-digest: ## retrieves the container digest from the given tag
@:$(call check_defined, GITHUB_REF)
@docker inspect $(HUB_REPO):$(subst refs/tags/,,$(GITHUB_REF)) --format '{{ index .RepoDigests 0 }}' | cut -d '@' -f 2

0 comments on commit 4dc7f6f

Please sign in to comment.