feat(release): v0.4.0 foundations — ldflags version + goreleaser + CI Go 1.24
- Move version out of cmd/root.go hardcode into an ldflags-injected var. Makefile derives from 'git describe --tags --always --dirty'; plain 'go build' / 'go run' get 'dev'. Release builds will get the tag via goreleaser. - Add .goreleaser.yaml: multi-platform (linux/darwin/windows/freebsd × amd64/arm64/arm) builds with SHA256 checksums, tar.gz/zip archives, forgejo release publishing. No GPG/S3 yet — deferred until a key is provisioned. - Add .gitea/workflows/release.yml to run goreleaser on tag push. Uses built-in GITEA_TOKEN with override via RELEASE_TOKEN secret. - Align CI Go version with go.mod (1.24). Previously CI ran 1.21, which would have silently missed any 1.22+ feature use. - Move itchyny/gojq from indirect to direct (it's used in api.go). Drop stale x/sys v0.33.0 entry from go.sum. - Ignore dist/ and bin/ in .gitignore. - CHANGELOG: document v0.3.1 fix and Unreleased development changes.
This commit is contained in:
parent
a6cf9a7096
commit
d4b5b79541
10 changed files with 188 additions and 13 deletions
|
|
@ -15,7 +15,7 @@ jobs:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: https://github.com/actions/setup-go@v5
|
uses: https://github.com/actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.21'
|
go-version: '1.24'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Install golangci-lint
|
- name: Install golangci-lint
|
||||||
|
|
@ -34,7 +34,7 @@ jobs:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: https://github.com/actions/setup-go@v5
|
uses: https://github.com/actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.21'
|
go-version: '1.24'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Build application
|
- name: Build application
|
||||||
|
|
@ -49,7 +49,7 @@ jobs:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: https://github.com/actions/setup-go@v5
|
uses: https://github.com/actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.21'
|
go-version: '1.24'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
|
|
@ -66,7 +66,7 @@ jobs:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: https://github.com/actions/setup-go@v5
|
uses: https://github.com/actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.21'
|
go-version: '1.24'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Build production binary
|
- name: Build production binary
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ jobs:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: https://github.com/actions/setup-go@v5
|
uses: https://github.com/actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.21'
|
go-version: '1.24'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Build production binary
|
- name: Build production binary
|
||||||
|
|
|
||||||
36
.gitea/workflows/release.yml
Normal file
36
.gitea/workflows/release.yml
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
goreleaser:
|
||||||
|
runs-on: codeberg-small
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Fetch tags
|
||||||
|
run: git fetch --force --tags
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: https://github.com/actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.24'
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Run GoReleaser
|
||||||
|
uses: https://github.com/goreleaser/goreleaser-action@v6
|
||||||
|
with:
|
||||||
|
distribution: goreleaser
|
||||||
|
version: "~> v2"
|
||||||
|
args: release --clean
|
||||||
|
env:
|
||||||
|
# Forgejo Actions injects GITEA_TOKEN for the workflow by default;
|
||||||
|
# override with RELEASE_TOKEN secret if a longer-lived token is needed.
|
||||||
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITEA_TOKEN }}
|
||||||
|
GORELEASER_FORCE_TOKEN: gitea
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -6,6 +6,10 @@ fgj
|
||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
|
|
||||||
|
# Goreleaser output
|
||||||
|
dist/
|
||||||
|
bin/
|
||||||
|
|
||||||
# Test binary
|
# Test binary
|
||||||
*.test
|
*.test
|
||||||
|
|
||||||
|
|
|
||||||
91
.goreleaser.yaml
Normal file
91
.goreleaser.yaml
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
project_name: fgj
|
||||||
|
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- id: fgj
|
||||||
|
binary: fgj
|
||||||
|
main: .
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X "forgejo.zerova.net/public/fgj-sid/cmd.version={{ .Version }}"
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- darwin
|
||||||
|
- windows
|
||||||
|
- freebsd
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm64
|
||||||
|
- arm
|
||||||
|
goarm:
|
||||||
|
- "6"
|
||||||
|
- "7"
|
||||||
|
ignore:
|
||||||
|
- goos: darwin
|
||||||
|
goarch: arm
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- id: default
|
||||||
|
name_template: >-
|
||||||
|
{{ .ProjectName }}-
|
||||||
|
{{- .Version }}-
|
||||||
|
{{- .Os }}-
|
||||||
|
{{- if eq .Arch "amd64" }}x86_64
|
||||||
|
{{- else if eq .Arch "386" }}i386
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
|
{{- if .Arm }}v{{ .Arm }}{{ end }}
|
||||||
|
formats: [tar.gz]
|
||||||
|
format_overrides:
|
||||||
|
- goos: windows
|
||||||
|
formats: [zip]
|
||||||
|
files:
|
||||||
|
- README.md
|
||||||
|
- LICENSE
|
||||||
|
- CHANGELOG.md
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
name_template: "checksums.txt"
|
||||||
|
algorithm: sha256
|
||||||
|
|
||||||
|
snapshot:
|
||||||
|
version_template: "{{ incpatch .Version }}-next"
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
use: git
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- "^docs:"
|
||||||
|
- "^test:"
|
||||||
|
- "^chore:"
|
||||||
|
- "^ci:"
|
||||||
|
- "Merge pull request"
|
||||||
|
- "Merge branch"
|
||||||
|
|
||||||
|
gitea_urls:
|
||||||
|
api: https://forgejo.zerova.net/api/v1
|
||||||
|
download: https://forgejo.zerova.net
|
||||||
|
|
||||||
|
release:
|
||||||
|
draft: false
|
||||||
|
prerelease: auto
|
||||||
|
mode: replace
|
||||||
|
header: |
|
||||||
|
## fgj {{ .Tag }}
|
||||||
|
|
||||||
|
Install with `go install forgejo.zerova.net/public/fgj-sid@{{ .Tag }}` or download a prebuilt binary below.
|
||||||
|
footer: |
|
||||||
|
**Full Changelog**: https://forgejo.zerova.net/public/fgj-sid/compare/{{ .PreviousTag }}...{{ .Tag }}
|
||||||
30
CHANGELOG.md
30
CHANGELOG.md
|
|
@ -5,6 +5,36 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Development
|
||||||
|
|
||||||
|
- Switched to standard semver tags (`v0.3.1`, `v0.4.0`, …); retired
|
||||||
|
letter-suffix scheme (`v0.3.0a`…`v0.3.0f`) which Go's module resolver
|
||||||
|
ignored, leaving `go install @latest` pointing at the pre-migration
|
||||||
|
`v0.3.0` tag.
|
||||||
|
- Version string is now injected at build time via `-ldflags`; the
|
||||||
|
hardcoded constant in `cmd/root.go` has been replaced with a
|
||||||
|
`var version = "dev"` fallback. `make build` derives the version from
|
||||||
|
`git describe --tags --always --dirty`.
|
||||||
|
- Added `.goreleaser.yaml` for multi-platform release builds
|
||||||
|
(linux/darwin/windows/freebsd × amd64/arm64/arm) with SHA256
|
||||||
|
checksums and auto-generated release notes.
|
||||||
|
- Added `.gitea/workflows/release.yml` that publishes release artifacts
|
||||||
|
to the Forgejo release page on tag push.
|
||||||
|
- Aligned CI Go version (`1.24`) with `go.mod`; previously CI ran on
|
||||||
|
`1.21` while `go.mod` required `1.24`.
|
||||||
|
|
||||||
|
## [0.3.1] - 2026-04-19
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `go install forgejo.zerova.net/public/fgj-sid@latest` now resolves
|
||||||
|
correctly. Previous releases used letter-suffix tags (`v0.3.0a`–`f`)
|
||||||
|
which are not valid Go module versions and were ignored by the
|
||||||
|
module resolver, leaving `@latest` pinned to `v0.3.0` — a commit
|
||||||
|
that predates the module-path migration from `codeberg.org/romaintb/fgj`.
|
||||||
|
|
||||||
## [0.3.0c] - 2026-03-21
|
## [0.3.0c] - 2026-03-21
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
20
Makefile
20
Makefile
|
|
@ -1,17 +1,23 @@
|
||||||
.PHONY: help build run test clean lint lint-fix install
|
.PHONY: help build run test clean lint lint-fix install release-snapshot release-check
|
||||||
|
|
||||||
|
# Version derived from git tags; falls back to short SHA; appends -dirty if tree is modified.
|
||||||
|
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
||||||
|
LDFLAGS := -X 'forgejo.zerova.net/public/fgj-sid/cmd.version=$(VERSION)'
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Available commands:"
|
@echo "Available commands:"
|
||||||
@echo " make build - Build the application"
|
@echo " make build - Build the application (version: $(VERSION))"
|
||||||
@echo " make install - Install the binary to /usr/bin"
|
@echo " make install - Install the binary to /usr/bin"
|
||||||
@echo " make run - Run the application"
|
@echo " make run - Run the application"
|
||||||
@echo " make test - Run tests"
|
@echo " make test - Run tests"
|
||||||
@echo " make lint - Run golangci-lint"
|
@echo " make lint - Run golangci-lint"
|
||||||
@echo " make lint-fix - Run golangci-lint with auto-fix"
|
@echo " make lint-fix - Run golangci-lint with auto-fix"
|
||||||
@echo " make clean - Clean build artifacts"
|
@echo " make clean - Clean build artifacts"
|
||||||
|
@echo " make release-snapshot - Build snapshot release artifacts via goreleaser"
|
||||||
|
@echo " make release-check - Validate .goreleaser.yaml"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -o bin/fgj .
|
go build -ldflags "$(LDFLAGS)" -o bin/fgj .
|
||||||
|
|
||||||
install: build
|
install: build
|
||||||
install -Dm755 bin/fgj /usr/bin/fgj
|
install -Dm755 bin/fgj /usr/bin/fgj
|
||||||
|
|
@ -29,5 +35,11 @@ lint-fix:
|
||||||
golangci-lint run --fix ./...
|
golangci-lint run --fix ./...
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf bin/
|
rm -rf bin/ dist/
|
||||||
go clean
|
go clean
|
||||||
|
|
||||||
|
release-snapshot:
|
||||||
|
goreleaser release --snapshot --clean --skip=publish
|
||||||
|
|
||||||
|
release-check:
|
||||||
|
goreleaser check
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,16 @@ import (
|
||||||
var cfgFile string
|
var cfgFile string
|
||||||
var jsonErrors bool
|
var jsonErrors bool
|
||||||
|
|
||||||
|
// version is set at build time via -ldflags "-X .../cmd.version=...".
|
||||||
|
// Defaults to "dev" for plain `go build` / `go run`.
|
||||||
|
var version = "dev"
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "fgj",
|
Use: "fgj",
|
||||||
Short: "Forgejo CLI tool - work seamlessly with Forgejo from the command line",
|
Short: "Forgejo CLI tool - work seamlessly with Forgejo from the command line",
|
||||||
Long: `fgj is a command line tool for Forgejo instances (including Codeberg).
|
Long: `fgj is a command line tool for Forgejo instances (including Codeberg).
|
||||||
It brings pull requests, issues, and other Forgejo concepts to the terminal.`,
|
It brings pull requests, issues, and other Forgejo concepts to the terminal.`,
|
||||||
Version: "0.3.1",
|
Version: version,
|
||||||
SilenceErrors: true,
|
SilenceErrors: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -4,6 +4,7 @@ go 1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.gitea.io/sdk/gitea v0.22.1
|
code.gitea.io/sdk/gitea v0.22.1
|
||||||
|
github.com/itchyny/gojq v0.12.18
|
||||||
github.com/spf13/cobra v1.8.1
|
github.com/spf13/cobra v1.8.1
|
||||||
github.com/spf13/viper v1.19.0
|
github.com/spf13/viper v1.19.0
|
||||||
golang.org/x/term v0.32.0
|
golang.org/x/term v0.32.0
|
||||||
|
|
@ -19,7 +20,6 @@ require (
|
||||||
github.com/hashicorp/go-version v1.7.0 // indirect
|
github.com/hashicorp/go-version v1.7.0 // indirect
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/itchyny/gojq v0.12.18 // indirect
|
|
||||||
github.com/itchyny/timefmt-go v0.1.7 // indirect
|
github.com/itchyny/timefmt-go v0.1.7 // indirect
|
||||||
github.com/magiconair/properties v1.8.7 // indirect
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
|
|
|
||||||
2
go.sum
2
go.sum
|
|
@ -90,8 +90,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
|
||||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
|
||||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue