This commit is contained in:
@@ -0,0 +1,58 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
# Fires when a version tag is pushed (e.g. `git tag v0.1.0 && git push --tags`).
|
||||||
|
# Runs the test suite as a release gate, builds static Linux binaries
|
||||||
|
# for amd64 + arm64, and attaches them to a Gitea release named after
|
||||||
|
# the tag.
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.23'
|
||||||
|
check-latest: true
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -race ./...
|
||||||
|
|
||||||
|
- name: Build binaries
|
||||||
|
env:
|
||||||
|
CGO_ENABLED: '0'
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
VERSION="${GITHUB_REF_NAME}"
|
||||||
|
mkdir -p dist
|
||||||
|
for arch in amd64 arm64; do
|
||||||
|
out="dist/qu-${VERSION}-linux-${arch}"
|
||||||
|
echo "building ${out}"
|
||||||
|
GOOS=linux GOARCH="${arch}" \
|
||||||
|
go build \
|
||||||
|
-trimpath \
|
||||||
|
-ldflags "-s -w -X main.version=${VERSION}" \
|
||||||
|
-o "${out}" \
|
||||||
|
./cmd/qu
|
||||||
|
done
|
||||||
|
(cd dist && sha256sum qu-* > SHA256SUMS)
|
||||||
|
ls -lh dist
|
||||||
|
|
||||||
|
- name: Publish release
|
||||||
|
uses: https://gitea.com/actions/release-action@main
|
||||||
|
with:
|
||||||
|
files: |-
|
||||||
|
dist/qu-*
|
||||||
|
dist/SHA256SUMS
|
||||||
|
api_key: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
@@ -52,6 +52,25 @@ Requires Go 1.23 or newer.
|
|||||||
go build -o qu ./cmd/qu
|
go build -o qu ./cmd/qu
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To stamp the version into the binary:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go build -ldflags "-X main.version=v0.1.0" -o qu ./cmd/qu
|
||||||
|
qu --version
|
||||||
|
```
|
||||||
|
|
||||||
|
## Releases
|
||||||
|
|
||||||
|
Pushing a tag matching `v*` triggers `.gitea/workflows/release.yaml`,
|
||||||
|
which runs the test suite, cross-compiles static Linux binaries for
|
||||||
|
amd64 and arm64, and publishes them as a Gitea release with a
|
||||||
|
`SHA256SUMS` file alongside.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git tag v0.1.0
|
||||||
|
git push --tags
|
||||||
|
```
|
||||||
|
|
||||||
## Set up a 3-node cluster
|
## Set up a 3-node cluster
|
||||||
|
|
||||||
On each host:
|
On each host:
|
||||||
|
|||||||
+5
-1
@@ -13,8 +13,12 @@ import (
|
|||||||
"git.cer.sh/axodouble/quptime/internal/cli"
|
"git.cer.sh/axodouble/quptime/internal/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// version is stamped at link time via `-ldflags "-X main.version=..."`.
|
||||||
|
// Falls back to "dev" for unreleased builds.
|
||||||
|
var version = "dev"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := cli.NewRootCommand().Execute(); err != nil {
|
if err := cli.NewRootCommand(version).Execute(); err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "error:", err)
|
fmt.Fprintln(os.Stderr, "error:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -8,11 +8,13 @@ package cli
|
|||||||
|
|
||||||
import "github.com/spf13/cobra"
|
import "github.com/spf13/cobra"
|
||||||
|
|
||||||
// NewRootCommand returns the full cobra tree.
|
// NewRootCommand returns the full cobra tree. version is the build
|
||||||
func NewRootCommand() *cobra.Command {
|
// stamp surfaced via `qu --version`; pass "dev" when unset.
|
||||||
|
func NewRootCommand(version string) *cobra.Command {
|
||||||
root := &cobra.Command{
|
root := &cobra.Command{
|
||||||
Use: "qu",
|
Use: "qu",
|
||||||
Short: "Quorum-based uptime monitor",
|
Short: "Quorum-based uptime monitor",
|
||||||
|
Version: version,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
SilenceErrors: true,
|
SilenceErrors: true,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user