From 4b3608b6285069560c8a0522bdc5b4d5cb0853e0 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Sat, 18 Jun 2022 19:39:01 -0500 Subject: [PATCH] fix: run git fetch --tags --force during release (#2495) --- .github/workflows/release.yaml | 30 +++++++++++++++++++++++++++--- scripts/version.sh | 4 ++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9f79c4512d..a6e9e5612d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -27,11 +27,22 @@ env: jobs: linux-windows: runs-on: ubuntu-latest + env: + # Necessary for Docker manifest + DOCKER_CLI_EXPERIMENTAL: "enabled" steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + # If the event that triggered the build was an annotated tag (which our + # tags are supposed to be), actions/checkout has a bug where the tag in + # question is only a lightweight tag and not a full annotated tag. This + # command seems to fix it. + # https://github.com/actions/checkout/issues/290 + - name: Fetch git tags + run: git fetch --tags --force + - uses: actions/setup-go@v3 with: go-version: "~1.18" @@ -133,6 +144,14 @@ jobs: with: fetch-depth: 0 + # If the event that triggered the build was an annotated tag (which our + # tags are supposed to be), actions/checkout has a bug where the tag in + # question is only a lightweight tag and not a full annotated tag. This + # command seems to fix it. + # https://github.com/actions/checkout/issues/290 + - name: Fetch git tags + run: git fetch --tags --force + - uses: actions/setup-go@v3 with: go-version: "~1.18" @@ -210,14 +229,19 @@ jobs: needs: - linux-windows - darwin - env: - # Necessary for Docker manifest - DOCKER_CLI_EXPERIMENTAL: "enabled" steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + # If the event that triggered the build was an annotated tag (which our + # tags are supposed to be), actions/checkout has a bug where the tag in + # question is only a lightweight tag and not a full annotated tag. This + # command seems to fix it. + # https://github.com/actions/checkout/issues/290 + - name: Fetch git tags + run: git fetch --tags --force + - name: Docker Login uses: docker/login-action@v2 with: diff --git a/scripts/version.sh b/scripts/version.sh index d924117fe9..220da35328 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -28,12 +28,12 @@ if [[ "${CODER_RELEASE:-}" == *t* ]]; then if [[ "$last_tag" != "$(git describe --always)" ]]; then # make won't exit on $(shell cmd) failures, so we have to kill it :( if [[ "$(ps -o comm= "$PPID" || true)" == *make* ]]; then - log "ERROR: version.sh attemped to generate a dev version string when CODER_RELEASE was set" + log "ERROR: version.sh: the current commit is not tagged with an annotated tag" kill "$PPID" || true exit 1 fi - error "version.sh attemped to generate a dev version string when CODER_RELEASE was set" + error "version.sh: the current commit is not tagged with an annotated tag" fi else version+="-devel+$(git rev-parse --short HEAD)"