From 24439796020bb376706abe718f294821fd749cc4 Mon Sep 17 00:00:00 2001 From: Joris Coenen Date: Fri, 30 Apr 2021 16:12:45 +0200 Subject: [PATCH] Fix the version passed to the image Contrary to what internet resources say, ${{github.event.ref}} also contains the `ref/tags/` prefix. That is removed now. Also, setting the version with plain "-X version.Version" does not seem to work consistently. Adding the full package as a prefix fixes this. --- .github/workflows/release.yml | 5 ++++- Dockerfile | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fe0180c..9e241f5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,9 @@ jobs: tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} + - name: Get the version from tag + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -51,4 +54,4 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | - operator_version=${{ github.event.ref }} + operator_version=${{ steps.get_version.outputs.VERSION }} diff --git a/Dockerfile b/Dockerfile index ce8e25f..6af54ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ ARG operator_version=dev RUN CGO_ENABLED=0 \ GO111MODULE=on \ go build \ - -ldflags "-X version.Version=$operator_version" \ + -ldflags "-X \"github.com/1Password/onepassword-operator/version.Version=$operator_version\"" \ -mod vendor \ -a -o manager main.go