Skip to content

Commit 25fb6a0

Browse files
committed
chore: update the release process
1 parent 1762964 commit 25fb6a0

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ jobs:
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 ./...

.github/workflows/release.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,25 @@ go vet ./...
204204
3. Make changes with tests
205205
4. Run `go fmt ./...` and `go vet ./...`
206206
5. 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+
```

main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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+
1320
func getConfigFilePath() string {
1421
homeDir, _ := os.UserHomeDir()
1522
return filepath.Join(homeDir, ".juliahub")
@@ -143,8 +150,9 @@ func normalizeServer(server string) string {
143150
}
144151

145152
var 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
150158
JuliaHub is a platform for Julia computing that provides dataset management,

0 commit comments

Comments
 (0)