Skip to content

Commit ce64e81

Browse files
committed
show version number
1 parent 40dabdd commit ce64e81

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Build
3030
run: |
3131
mkdir -p dist
32-
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/gitlab-migrator-${{ matrix.goos }}-${{ matrix.goarch }}
32+
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-X 'main.version=$(git describe --tags --abbrev=8 --dirty --always)'" -o dist/gitlab-migrator-${{ matrix.goos }}-${{ matrix.goarch }}
3333
3434
- name: Upload binaries
3535
uses: actions/upload-artifact@v4

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var (
4040
gh *github.Client
4141
gl *gitlab.Client
4242
maxConcurrency int
43+
version = "development"
4344
)
4445

4546
type Project = []string
@@ -97,13 +98,17 @@ func main() {
9798
os.Exit(1)
9899
}
99100

101+
var showVersion bool
102+
fmt.Printf(fmt.Sprintf("gitlab-migrator %s\n", version))
103+
100104
flag.BoolVar(&loop, "loop", false, "continue migrating until canceled")
101105
flag.BoolVar(&report, "report", false, "report on primitives to be migrated instead of beginning migration")
102106

103107
flag.BoolVar(&deleteExistingRepos, "delete-existing-repos", false, "whether existing repositories should be deleted before migrating")
104108
flag.BoolVar(&enablePullRequests, "migrate-pull-requests", false, "whether pull requests should be migrated")
105109
flag.BoolVar(&renameMasterToMain, "rename-master-to-main", false, "rename master branch to main and update pull requests (incompatible with -rename-trunk-branch)")
106110
flag.BoolVar(&skipInvalidMergeRequests, "skip-invalid-merge-requests", false, "when true, will log and skip invalid merge requests instead of raising an error")
111+
flag.BoolVar(&showVersion, "version", false, "output version information")
107112

108113
flag.StringVar(&githubDomain, "github-domain", defaultGithubDomain, "specifies the GitHub domain to use")
109114
flag.StringVar(&githubRepo, "github-repo", "", "the GitHub repository to migrate to")
@@ -117,6 +122,10 @@ func main() {
117122

118123
flag.Parse()
119124

125+
if showVersion {
126+
return
127+
}
128+
120129
if githubUser == "" {
121130
githubUser = os.Getenv("GITHUB_USER")
122131
}

0 commit comments

Comments
 (0)