Skip to content

Commit 1f88678

Browse files
committed
chore: release wf
1 parent 83b3df6 commit 1f88678

6 files changed

Lines changed: 210 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
include:
16+
- goos: darwin
17+
goarch: amd64
18+
ext: tar.gz
19+
- goos: darwin
20+
goarch: arm64
21+
ext: tar.gz
22+
- goos: linux
23+
goarch: amd64
24+
ext: tar.gz
25+
- goos: linux
26+
goarch: arm64
27+
ext: tar.gz
28+
- goos: windows
29+
goarch: amd64
30+
ext: zip
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- uses: actions/setup-go@v5
35+
with:
36+
go-version-file: go.mod
37+
38+
- name: Build
39+
env:
40+
GOOS: ${{ matrix.goos }}
41+
GOARCH: ${{ matrix.goarch }}
42+
CGO_ENABLED: "0"
43+
run: |
44+
TAG="${GITHUB_REF_NAME}"
45+
BINARY="odoo-work-cli"
46+
if [ "${{ matrix.goos }}" = "windows" ]; then
47+
BINARY="odoo-work-cli.exe"
48+
fi
49+
go build -ldflags "-X github.com/seletz/odoo-work-cli/internal/version.Version=${TAG}" \
50+
-o "${BINARY}" ./cmd/odoo-work-cli
51+
52+
- name: Package
53+
run: |
54+
TAG="${GITHUB_REF_NAME}"
55+
BINARY="odoo-work-cli"
56+
if [ "${{ matrix.goos }}" = "windows" ]; then
57+
BINARY="odoo-work-cli.exe"
58+
fi
59+
ARCHIVE="odoo-work-cli-${TAG}-${{ matrix.goos }}-${{ matrix.goarch }}"
60+
if [ "${{ matrix.ext }}" = "tar.gz" ]; then
61+
tar czf "${ARCHIVE}.tar.gz" "${BINARY}"
62+
else
63+
zip "${ARCHIVE}.zip" "${BINARY}"
64+
fi
65+
66+
- name: Upload artifact
67+
env:
68+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
run: |
70+
TAG="${GITHUB_REF_NAME}"
71+
ARCHIVE="odoo-work-cli-${TAG}-${{ matrix.goos }}-${{ matrix.goarch }}.${{ matrix.ext }}"
72+
gh release upload "$TAG" "$ARCHIVE" --repo "${{ github.repository }}"
73+
74+
checksums:
75+
runs-on: ubuntu-latest
76+
needs: build
77+
steps:
78+
- name: Download assets
79+
env:
80+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
run: |
82+
TAG="${GITHUB_REF_NAME}"
83+
gh release download "$TAG" --dir assets --repo "${{ github.repository }}"
84+
85+
- name: Generate checksums
86+
run: |
87+
TAG="${GITHUB_REF_NAME}"
88+
cd assets
89+
sha256sum * > "checksums-${TAG}.txt"
90+
91+
- name: Upload checksums
92+
env:
93+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
run: |
95+
TAG="${GITHUB_REF_NAME}"
96+
gh release upload "$TAG" "assets/checksums-${TAG}.txt" --repo "${{ github.repository }}"

cmd/odoo-work-cli/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/seletz/odoo-work-cli/internal/config"
1414
"github.com/seletz/odoo-work-cli/internal/odoo"
1515
"github.com/seletz/odoo-work-cli/internal/tui"
16+
"github.com/seletz/odoo-work-cli/internal/version"
1617
"github.com/spf13/cobra"
1718
)
1819

@@ -25,8 +26,9 @@ func main() {
2526
}
2627

2728
var rootCmd = &cobra.Command{
28-
Use: "odoo-work-cli",
29-
Short: "CLI for managing Odoo 17 timesheets",
29+
Use: "odoo-work-cli",
30+
Short: "CLI for managing Odoo 17 timesheets",
31+
Version: version.Version,
3032
}
3133

3234
func init() {

internal/version/version.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package version
2+
3+
// Version is set at build time via ldflags.
4+
var Version = "dev"

mise.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ gh = "latest"
88

99
[tasks.build]
1010
description = "Build the CLI binary"
11-
run = "go build -o odoo-work-cli ./cmd/odoo-work-cli"
11+
run = """
12+
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
13+
go build -ldflags "-X github.com/seletz/odoo-work-cli/internal/version.Version=${VERSION}" -o odoo-work-cli ./cmd/odoo-work-cli
14+
"""
15+
16+
[tasks.release]
17+
description = "Create a new release (interactive semver bump)"
18+
run = "scripts/release.sh"
1219

1320
[tasks.test]
1421
description = "Run all tests"

readme.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,39 @@ mise run test
167167
# Lint
168168
mise run lint
169169
```
170+
171+
## Releasing
172+
173+
Releases are managed via `mise run release` and built automatically by GitHub Actions.
174+
175+
### Creating a release
176+
177+
```bash
178+
mise run release
179+
```
180+
181+
This will:
182+
183+
1. Show the current version (latest `v*` tag, or `v0.0.0` if none)
184+
2. Prompt for bump type (patch / minor / major)
185+
3. Create an annotated git tag
186+
4. Push the tag to origin
187+
5. Create a GitHub prerelease with auto-generated notes
188+
189+
### CI build
190+
191+
When a release is created, GitHub Actions automatically:
192+
193+
- Cross-compiles for macOS (amd64, arm64), Linux (amd64, arm64), and Windows (amd64)
194+
- Packages binaries as `.tar.gz` (Unix) or `.zip` (Windows)
195+
- Uploads all artifacts to the release
196+
- Generates a `checksums-<tag>.txt` with SHA-256 hashes
197+
198+
### Version embedding
199+
200+
The build injects the version via `-ldflags`:
201+
202+
```bash
203+
mise run build
204+
./odoo-work-cli --version
205+
```

scripts/release.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Get the latest version tag, default to v0.0.0
5+
LATEST=$(git tag -l 'v*' --sort=-v:refname | head -n1)
6+
if [ -z "$LATEST" ]; then
7+
LATEST="v0.0.0"
8+
fi
9+
10+
echo "Current version: $LATEST"
11+
echo ""
12+
echo "Select bump type:"
13+
echo " 1) patch"
14+
echo " 2) minor"
15+
echo " 3) major"
16+
echo ""
17+
read -rp "Choice [1/2/3]: " CHOICE
18+
19+
# Strip leading 'v' for arithmetic
20+
VERSION="${LATEST#v}"
21+
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
22+
23+
case "$CHOICE" in
24+
1|patch)
25+
PATCH=$((PATCH + 1))
26+
;;
27+
2|minor)
28+
MINOR=$((MINOR + 1))
29+
PATCH=0
30+
;;
31+
3|major)
32+
MAJOR=$((MAJOR + 1))
33+
MINOR=0
34+
PATCH=0
35+
;;
36+
*)
37+
echo "Invalid choice"
38+
exit 1
39+
;;
40+
esac
41+
42+
NEXT="v${MAJOR}.${MINOR}.${PATCH}"
43+
44+
echo ""
45+
read -rp "Create release $NEXT? [y/N]: " CONFIRM
46+
if [[ "$CONFIRM" != "y" && "$CONFIRM" != "Y" ]]; then
47+
echo "Aborted."
48+
exit 0
49+
fi
50+
51+
echo "Tagging $NEXT..."
52+
git tag -a "$NEXT" -m "Release $NEXT"
53+
54+
echo "Pushing tag to origin..."
55+
git push origin "$NEXT"
56+
57+
echo "Creating GitHub prerelease..."
58+
gh release create "$NEXT" --title "$NEXT" --generate-notes --prerelease
59+
60+
echo ""
61+
echo "Done! Release $NEXT created as prerelease."
62+
echo "GitHub Actions will build and attach artifacts."

0 commit comments

Comments
 (0)