From 23b570272bd0582a6300ee951dd165a54978bd62 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Tue, 23 Mar 2021 18:56:19 +0000 Subject: [PATCH 1/2] Add docker image release workflow Signed-off-by: Milos Gajdos --- .github/workflows/release.yaml | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..16725135 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,60 @@ +name: Build release image and push to hub + +on: + push: + tags: + - "*" + +jobs: + publish: + name: Build and publish docker image + runs-on: ubuntu-latest + env: + DOCKER_BUILDTAGS: "include_oss include_gcs" + CGO_ENABLED: 1 + GO111MODULE: "auto" + GOPATH: ${{ github.workspace }} + GOOS: linux + COMMIT_RANGE: ${{ github.event_name == 'pull_request' && format('{0}..{1}',github.event.pull_request.base.sha, github.event.pull_request.head.sha) || format('{0}..{1}', github.event.before, github.event.after) }} + + steps: + - name: Get git tag + id: get_git_tag + run: echo ::set-output name=git_tag::${GITHUB_REF#refs/tags/} + + - name: Verify git tag + env: + GIT_TAG: ${{ steps.get_git_tag.outputs.git_tag }} + # NOTE: this is a simple Regexp, following the current versioning scheme + # In ideal world we should use this monstrosity: + # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string + run: | + [[ ${GIT_TAG} =~ ^v[0-9]+.[0-9]+.[0-9]+ ]] + + - name: Check out source code + if: ${{ success() }} + uses: actions/checkout@v2 + with: + ref: ${{ steps.get_git_tag.outputs.git_tag }} + + - name: Set image tag + env: + GIT_TAG: ${{ steps.get_git_tag.outputs.git_tag }} + id: get_image_tag + run: echo ::set-output name=docker_tag::${GIT_TAG} + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + if: ${{ success() }} + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: distribution/distribution:{{ steps.get_image_tag.outputs.docker_tag }} From a0aad5720818a039a22b0099807beb06ef2174b0 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Wed, 24 Mar 2021 11:02:25 +0000 Subject: [PATCH 2/2] Make workflow name shorter. Signed-off-by: Milos Gajdos --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 16725135..57482056 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: Build release image and push to hub +name: Release docker image on: push: