File tree Expand file tree Collapse file tree 4 files changed +46
-5
lines changed Expand file tree Collapse file tree 4 files changed +46
-5
lines changed Original file line number Diff line number Diff line change 3232 fi
3333
3434 - name : Build
35- run : go build -v ./...
35+ run : |
36+ VERSION="dev-$(git rev-parse --short HEAD)"
37+ LDFLAGS="-X main.version=$VERSION -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
38+ go build -ldflags="$LDFLAGS" -v ./...
Original file line number Diff line number Diff line change @@ -55,10 +55,18 @@ jobs:
5555 GOARCH : ${{ matrix.goarch }}
5656 CGO_ENABLED : 0
5757 run : |
58+ # Extract version from tag (remove 'v' prefix)
59+ VERSION=${GITHUB_REF#refs/tags/v}
60+ if [ -z "$VERSION" ] || [ "$VERSION" = "$GITHUB_REF" ]; then
61+ VERSION="dev-$(git rev-parse --short HEAD)"
62+ fi
63+
64+ LDFLAGS="-s -w -X main.version=$VERSION -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
65+
5866 if [ "${{ matrix.goos }}" = "windows" ]; then
59- go build -ldflags="-s -w " -o jh-${{ matrix.os }}-${{ matrix.arch }}.exe .
67+ go build -ldflags="$LDFLAGS " -o jh-${{ matrix.os }}-${{ matrix.arch }}.exe .
6068 else
61- go build -ldflags="-s -w " -o jh-${{ matrix.os }}-${{ matrix.arch }} .
69+ go build -ldflags="$LDFLAGS " -o jh-${{ matrix.os }}-${{ matrix.arch }} .
6270 fi
6371
6472 - name : Upload artifact
Original file line number Diff line number Diff line change @@ -204,3 +204,25 @@ go vet ./...
2042043 . Make changes with tests
2052054 . Run ` go fmt ./... ` and ` go vet ./... `
2062065 . Submit a pull request
207+
208+ ### Releasing
209+
210+ To create a new release:
211+
212+ 1 . Create and push a version tag:
213+
214+ ``` bash
215+ git tag v1.0.0
216+ git push origin v1.0.0
217+ ```
218+
219+ 2 . GitHub Actions will automatically:
220+
221+ - Build binaries for all platforms
222+ - Create a GitHub release with the binaries
223+ - Include version information in the binaries
224+
225+ 3 . Version information is embedded in binaries:
226+ ``` bash
227+ jh --version # Shows version, commit, and build date
228+ ```
Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ import (
1010 "github.com/spf13/cobra"
1111)
1212
13+ // Version information (set during build)
14+ var (
15+ version = "dev"
16+ commit = "unknown"
17+ date = "unknown"
18+ )
19+
1320func getConfigFilePath () string {
1421 homeDir , _ := os .UserHomeDir ()
1522 return filepath .Join (homeDir , ".juliahub" )
@@ -143,8 +150,9 @@ func normalizeServer(server string) string {
143150}
144151
145152var rootCmd = & cobra.Command {
146- Use : "jh" ,
147- Short : "JuliaHub CLI" ,
153+ Use : "jh" ,
154+ Short : "JuliaHub CLI" ,
155+ Version : version ,
148156 Long : `A command line interface for interacting with JuliaHub.
149157
150158JuliaHub is a platform for Julia computing that provides dataset management,
You can’t perform that action at this time.
0 commit comments