Skip to content

Commit 0c256fc

Browse files
committed
fix git release pipeline v2
1 parent 850bfbe commit 0c256fc

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ jobs:
6363
release:
6464
needs: build
6565
runs-on: ubuntu-latest
66-
if: startsWith(github.ref, 'refs/tags/')
66+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
6767

6868
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
6974
- name: Download all artifacts
7075
uses: actions/download-artifact@v4
7176
with:

main.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"os/exec"
3838
"path/filepath"
3939
"regexp"
40+
"runtime/debug"
4041
"strings"
4142

4243
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
@@ -45,8 +46,18 @@ import (
4546
"github.com/spf13/cobra"
4647
)
4748

48-
// Version information (set via ldflags at build time)
49-
var version = "dev"
49+
// Version information (set via ldflags at build time, or read from build info)
50+
var version = ""
51+
52+
func init() {
53+
if version == "" {
54+
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" {
55+
version = info.Main.Version
56+
} else {
57+
version = "dev"
58+
}
59+
}
60+
}
5061

5162
var defaultAllowedDomains = []string{"visualstudio.com", "dev.azure.com"}
5263

0 commit comments

Comments
 (0)