From 3d1cd30a1debced4b68449a638c09abeb1bb8b7c Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Fri, 12 May 2023 10:52:31 -0400 Subject: [PATCH] BUG: "dnscontrol version" not working (#2356) Co-authored-by: Tom Limoncelli --- .github/workflows/build.yml | 22 +++++++++++++++++++--- .github/workflows/draft_release.yml | 16 +++++++++++++++- .github/workflows/release.yml | 2 +- commands/commands.go | 8 +++++++- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 872af7f77..149426dda 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest container: - image: golang:1.18 + image: golang:1.20 env: TEST_RESULTS: "/tmp/test-results" steps: @@ -33,12 +33,28 @@ jobs: - uses: actions/upload-artifact@v3.1.2 with: path: "/tmp/test-results" + +# For some reason goreleaser isn't correctly setting the version +# string used by "dnscontrol version". Therefore, we're forcing the +# string using the GORELEASER_CURRENT_TAG feature. +# TODO(tlim): Use the native gorelease version mechanism. + - name: Retrieve version + id: version + run: | + echo "TAG_NAME=$(git config --global --add safe.directory /__w/dnscontrol/dnscontrol ; git describe)" >> $GITHUB_OUTPUT + - name: Reveal version + run: echo ${{ steps.version.outputs.TAG_NAME }} + - name: Build binaries (if tagged) if: github.ref_type == 'tag' run: goreleaser build + env: + GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.TAG_NAME }} - name: Build binaries (not tagged) if: github.ref_type != 'tag' run: goreleaser build --snapshot + env: + GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.TAG_NAME }} integration-test-providers: needs: build runs-on: ubuntu-latest @@ -70,7 +86,7 @@ jobs: needs: integration-test-providers runs-on: ubuntu-latest container: - image: golang:1.18 + image: golang:1.20 env: TEST_RESULTS: "/tmp/test-results" GOTESTSUM_FORMAT: testname @@ -171,7 +187,7 @@ jobs: if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' runs-on: ubuntu-latest container: - image: golang:1.18 + image: golang:1.20 needs: - integration-test-providers - integrtests-diff1 diff --git a/.github/workflows/draft_release.yml b/.github/workflows/draft_release.yml index e4f3c3aed..7c6c1525b 100644 --- a/.github/workflows/draft_release.yml +++ b/.github/workflows/draft_release.yml @@ -25,12 +25,26 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: ^1.15 + go-version: ^1.20 - name: Install goreleaser run: go install github.com/goreleaser/goreleaser@latest +# For some reason goreleaser isn't correctly setting the version +# string used by "dnscontrol version". Therefore, we're forcing the +# string using the GORELEASER_CURRENT_TAG feature. +# TODO(tlim): Use the native gorelease version mechanism. + + - name: Retrieve version + id: version + run: | + echo "TAG_NAME=$(git config --global --add safe.directory /__w/dnscontrol/dnscontrol ; git describe --tags)" >> $GITHUB_OUTPUT + + - name: Reveal version + run: echo ${{ steps.version.outputs.TAG_NAME }} + - name: Goreleaser release run: goreleaser release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.TAG_NAME }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cc1675954..8c81178be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: ^1.15 + go-version: ^1.20 - name: Build binaries run: go run build/build.go diff --git a/commands/commands.go b/commands/commands.go index 82043545f..e8fb933f0 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -22,7 +22,13 @@ const ( ) var commands = []*cli.Command{} -var version string + +// These are set by/for goreleaser +var ( + version = "dev" + commit = "none" + date = "unknown" +) func cmd(cat string, c *cli.Command) bool { c.Category = cat