From 9c5331e511a09fb2a0b1e6793447034ed757e576 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Mon, 23 Jan 2023 17:48:57 -0800 Subject: [PATCH] Add job to create docker images --- .github/workflows/release.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6162c0d..9c962d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,12 @@ jobs: name: Create Release needs: ci runs-on: ubuntu-latest + env: + DOCKER_IMAGE: smallstep/step-kms-plugin + outputs: + version: ${{ steps.extract-tag.outputs.VERSION }} + is_prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }} + docker_tags: ${{ env.DOCKER_TAGS }} steps: - name: Is Pre-release id: is_prerelease @@ -24,6 +30,12 @@ jobs: OUT=$? if [ $OUT -eq 0 ]; then IS_PRERELEASE=true; else IS_PRERELEASE=false; fi echo "IS_PRERELEASE=${IS_PRERELEASE}" >> ${GITHUB_OUTPUT} + - name: Extract Tag Names + id: extract-tag + run: | + VERSION=${GITHUB_REF#refs/tags/v} + echo "VERSION=${VERSION}" >> ${GITHUB_OUTPUT} + echo "DOCKER_TAGS=${{ env.DOCKER_IMAGE }}:${VERSION}" >> ${GITHUB_ENV} - name: Create Release id: create_release uses: actions/create-release@v1 @@ -34,6 +46,10 @@ jobs: release_name: Release ${{ github.ref }} draft: false prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }} + - name: Add Latest Tag + if: steps.is_prerelease.outputs.IS_PRERELEASE == 'false' + run: | + echo "DOCKER_TAGS=${{ env.DOCKER_TAGS }},${{ env.DOCKER_IMAGE }}:latest" >> ${GITHUB_ENV} goreleaser: name: Upload Assets to Github w/ goreleaser @@ -57,3 +73,17 @@ jobs: echo 'GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}' > .release-env - name: release publish run: make release + + build_upload_docker: + name: Build & Upload Docker Images + needs: create_release + permissions: + id-token: write + contents: write + uses: smallstep/workflows/.github/workflows/docker-buildx-push.yml@main + with: + platforms: linux/amd64,linux/arm64 + tags: ${{ needs.create_release.outputs.docker_tags }} + docker_image: smallstep/step-kms-plugin + docker_file: docker/Dockerfile + secrets: inherit