From f5a9744bdedd6f0fcd048628fe279fb37f236b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:34:31 +0200 Subject: [PATCH 1/6] tools/build-version.go: Improve error verbosity --- tools/build-version.go | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tools/build-version.go b/tools/build-version.go index 8194fba6..f583e322 100644 --- a/tools/build-version.go +++ b/tools/build-version.go @@ -4,6 +4,7 @@ package main import ( "fmt" + "log" "os/exec" "strings" @@ -19,13 +20,17 @@ func getTag(match ...string) (string, *semver.PRVersion) { } else { tagParts := strings.Split(string(tag), "-") if len(tagParts) == 3 { - if ahead, err := semver.NewPRVersion(tagParts[1]); err == nil { + ahead, err := semver.NewPRVersion(tagParts[1]) + if err == nil { return tagParts[0], &ahead } + log.Printf("semver.NewPRVersion(%s): %v", tagParts[1], err) } else if len(tagParts) == 4 { - if ahead, err := semver.NewPRVersion(tagParts[2]); err == nil { + ahead, err := semver.NewPRVersion(tagParts[2]) + if err == nil { return tagParts[0] + "-" + tagParts[1], &ahead } + log.Printf("semver.NewPRVersion(%s): %v", tagParts[2], err) } return string(tag), nil @@ -33,15 +38,30 @@ func getTag(match ...string) (string, *semver.PRVersion) { } func main() { - if tags, err := exec.Command("git", "tag").Output(); err != nil || len(tags) == 0 { - // no tags found -- fetch them - exec.Command("git", "fetch", "--tags").Run() + tags, err := exec.Command("git", "tag").Output() + if err != nil { + log.Println("git tag:", err) + if e, ok := err.(*exec.ExitError); ok { + log.Print(string(e.Stderr)) + } } + if len(tags) == 0 { + // no tags found -- fetch them + err = exec.Command("git", "fetch", "--tags").Run() + if err != nil { + log.Println("git fetch --tags:", err) + if e, ok := err.(*exec.ExitError); ok { + log.Print(string(e.Stderr)) + } + } + } + // Find the last vX.X.X Tag and get how many builds we are ahead of it. versionStr, ahead := getTag("--match", "v*") version, err := semver.ParseTolerant(versionStr) if err != nil { // no version tag found so just return what ever we can find. + log.Printf("semver.ParseTolerant(%s): %v", versionStr, err) fmt.Println("0.0.0-unknown") return } @@ -66,6 +86,8 @@ func main() { if pr, err := semver.NewPRVersion(tag); err == nil { // append the tag as pre-release name version.Pre = append(version.Pre, pr) + } else { + log.Printf("semver.NewPRVersion(%s): %v", tag, err) } if ahead != nil { From d98fafd2f9b836c91bc707a458e59f869ca1f219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Thu, 20 Jun 2024 22:32:05 +0200 Subject: [PATCH 2/6] tools/build-version.go: Remove the `git fetch` step build-version.go shall only provide information and not modify the repository in which it runs. --- tools/build-version.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tools/build-version.go b/tools/build-version.go index f583e322..f0f7a8f8 100644 --- a/tools/build-version.go +++ b/tools/build-version.go @@ -38,24 +38,6 @@ func getTag(match ...string) (string, *semver.PRVersion) { } func main() { - tags, err := exec.Command("git", "tag").Output() - if err != nil { - log.Println("git tag:", err) - if e, ok := err.(*exec.ExitError); ok { - log.Print(string(e.Stderr)) - } - } - if len(tags) == 0 { - // no tags found -- fetch them - err = exec.Command("git", "fetch", "--tags").Run() - if err != nil { - log.Println("git fetch --tags:", err) - if e, ok := err.(*exec.ExitError); ok { - log.Print(string(e.Stderr)) - } - } - } - // Find the last vX.X.X Tag and get how many builds we are ahead of it. versionStr, ahead := getTag("--match", "v*") version, err := semver.ParseTolerant(versionStr) From 57375e07323896d22c5762ebd9f1775edd8a3c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:36:38 +0200 Subject: [PATCH 3/6] workflows/nightly: Allow manual trigger for better testability --- .github/workflows/nightly.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 2ca663e8..cb4c587a 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -1,7 +1,8 @@ name: Nightly builds on: + workflow_dispatch: # Allows manual trigger schedule: - - cron: '0 0 * * *' + - cron: '0 0 * * *' jobs: nightly: strategy: From f475220e67fd810def33a175d81308315f6c8927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:57:59 +0200 Subject: [PATCH 4/6] workflows/test: Bump version of `setup` & `checkout` actions This will correct the following warning: "Node.js 16 actions are deprecated." --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9b93b938..f959272b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,10 +8,10 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build run: | From c58ed0e51af8fc41b330180c3f6f5abe139dea01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:03:49 +0200 Subject: [PATCH 5/6] workflows: Perform the `setup` uncached --- .github/workflows/nightly.yaml | 1 + .github/workflows/test.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index cb4c587a..7cd4fcae 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -15,6 +15,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} + cache: false - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f959272b..634692d0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,6 +11,8 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} + cache: false + - uses: actions/checkout@v4 - name: Build From 531c7d88e256c7289b62ea27849b17e1bf22d74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Wed, 19 Jun 2024 22:03:14 +0200 Subject: [PATCH 6/6] workflow: Fetch with a `fetch-depth` of 0 and `fetch-tags` true This will allow us to read the whole history especially all the tags. --- .github/workflows/nightly.yaml | 2 ++ .github/workflows/test.yaml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 7cd4fcae..12647e65 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -21,6 +21,8 @@ jobs: uses: actions/checkout@v4 with: ref: master + fetch-depth: 0 + fetch-tags: true - name: Build run: tools/cross-compile.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 634692d0..632717f6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,6 +14,9 @@ jobs: cache: false - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true - name: Build run: |