Skip to content

Commit b94a1b1

Browse files
authored
Add dynamic version injection (#4)
* Add dynamic version injection * Add release doc * Remove v prefix It is now injected by goreleaser
1 parent e56e302 commit b94a1b1

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

.goreleaser.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ builds:
2424
- darwin
2525
main: ./cmd/tsgrok
2626
binary: tsgrok
27+
ldflags:
28+
- -s -w
29+
- -X {{.ModulePath}}/internal/util.ProgramVersion={{.Version}}
30+
- -X {{.ModulePath}}/internal/util.Commit={{.Commit}}
31+
- -X {{.ModulePath}}/internal/util.Date={{.Date}}
2732

2833
archives:
2934
- formats: [tar.gz]

docs/release.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Release Process for tsgrok
2+
3+
This document outlines the steps to create a new release for the `tsgrok` project using GoReleaser.
4+
5+
## Prerequisites
6+
7+
1. Ensure `goreleaser` is installed and configured correctly.
8+
2. Ensure you have rights to push to the repository and create releases on GitHub.
9+
3. Make sure your GPG key is configured for signing.
10+
11+
## Steps to Create a Release
12+
13+
14+
1. **Determine the New Version:**
15+
* Decide on the new version number (e.g., `v0.1.0`, `v1.2.3`).
16+
17+
2. **Create an Annotated Git Tag:**
18+
* Create an annotated and GPG-signed tag for the new version. Replace `vX.Y.Z` with your chosen version number and provide a meaningful tag message.
19+
```bash
20+
git tag -a vX.Y.Z -m "Release version vX.Y.Z"
21+
```
22+
3. **Push Changes and Tag to GitHub:**
23+
* Push your commits and the new tag to the remote repository:
24+
```bash
25+
git push origin main # Or your primary branch
26+
git push origin vX.Y.Z
27+
```
28+
(Replace `vX.Y.Z` with your actual tag)
29+
Alternatively, to push all tags:
30+
```bash
31+
git push --tags
32+
```
33+
34+
4. **Run GoReleaser:**
35+
* Execute the `goreleaser release` command. This will build the project, create the release on GitHub, and upload the artifacts.
36+
```bash
37+
goreleaser release --clean
38+
```
39+
* The `--clean` flag ensures that the `dist` directory is cleaned before building, which is good practice.
40+
* If you have a CI/CD pipeline set up, this step might be triggered automatically when a new tag is pushed.
41+
42+
5. **Verify Release:**
43+
* Go to the releases page on GitHub for the project and verify that the new release is present with all artifacts and release notes (if `goreleaser` is configured to generate them from your changelog).

internal/tui/tui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ func (m model) viewDetailView(availableHeight int) string {
10561056

10571057
// footerView renders the footer/status bar
10581058
func (m model) footerView() string {
1059-
footerText := fmt.Sprintf("%s v%s", util.ProgramName, util.ProgramVersion)
1059+
footerText := fmt.Sprintf("%s %s", util.ProgramName, util.ProgramVersion)
10601060

10611061
// Define core help keys for each view
10621062
var coreHelp string

internal/util/constants.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package util
22

33
const ProgramName = "tsgrok"
4-
const ProgramVersion = "0.0.1"
4+
5+
var ProgramVersion = "dev" // Will be overwritten by goreleaser
6+
var Commit = "none" // Will be overwritten by goreleaser
7+
var Date = "unknown" // Will be overwritten by goreleaser
8+
59
const DefaultPort = 4141
610

711
const AuthKeyEnvVar = "TSGROK_AUTHKEY" // env var for auth key

0 commit comments

Comments
 (0)