From 8f7740963822c671544adc7977cdd24cae570d99 Mon Sep 17 00:00:00 2001 From: vmsharoshkin Date: Mon, 5 Oct 2026 09:08:56 +0300 Subject: [PATCH] go releaser --- .github/workflows/ci.yml | 11 +++++--- .github/workflows/release.yml | 20 ++++++------- .goreleaser.yaml | 53 +++++++++++++++++++++++++++++++++++ CLAUDE.md | 4 +-- CONTRIBUTING.md | 2 +- Makefile | 37 ++++++++---------------- README.md | 32 ++++++++++++++++++++- go.mod | 2 +- 8 files changed, 115 insertions(+), 46 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb983e5..8caa613 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,13 +13,13 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: "1.26.6" + go-version: "1.27.1" cache: true - name: golangci-lint uses: golangci/golangci-lint-action@v9 with: - version: v2.12.2 + version: v2.14.0 - name: test run: make test @@ -27,5 +27,8 @@ jobs: - name: build run: make build - - name: build-all (cross-compile matrix) - run: make build-all + - name: validate GoReleaser config + uses: goreleaser/goreleaser-action@v6 + with: + version: "~> v2" + args: check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4785575..7ae6af8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,20 +13,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: actions/setup-go@v5 with: - go-version: "1.26.6" + go-version: "1.27.1" cache: true - - name: build release artifacts - run: make release - - - name: publish GitHub release + - name: GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: "~> v2" + args: release --clean env: - GH_TOKEN: ${{ github.token }} - run: | - gh release create "${{ github.ref_name }}" \ - dist/eds-* dist/checksums.txt \ - --title "${{ github.ref_name }}" \ - --generate-notes + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..21af655 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,53 @@ +version: 2 + +project_name: eds + +before: + hooks: + - go mod tidy + +builds: + - id: eds + binary: eds + main: ./cmd/eds + env: + - CGO_ENABLED=0 + flags: + - -trimpath + ldflags: + - -s -w -X main.version={{.Version}} + goos: + - darwin + - linux + - windows + goarch: + - amd64 + - arm64 + +archives: + - id: eds + name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}" + formats: + - binary + files: + # Only the binary; no README, LICENSE, etc. + - none* + +checksum: + name_template: "checksums.txt" + algorithm: sha256 + +snapshot: + version_template: "{{ .Version }}-{{ .ShortCommit }}" + +release: + draft: true + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + - "^ci:" + - "^chore:" diff --git a/CLAUDE.md b/CLAUDE.md index 7d90901..cef8f99 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -175,8 +175,8 @@ the API client and printer. stderr by `cmd.Execute()` (root sets `SilenceUsage`/`SilenceErrors`) — keep error messages one line and actionable (see `requireAPIKey`'s message as the template). -- Target platforms are Linux + macOS only (`DEFAULT_OSES := darwin linux` in - the Makefile); don't add Windows-specific code paths without updating that. +- Target platforms are Linux + macOS + Windows (`DEFAULT_OSES := darwin linux windows` in + the Makefile). - If you ever scaffold a `Dockerfile` for a Workflow Studio deploy test (fixtures, examples, docs), it must run as non-root with a read-only-ish root filesystem -- that's what the Container Apps runtime enforces. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1e088b..75a4aac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ cd evolution-devservices-cli make build # ./bin/eds ``` -Go 1.22+ is required. Target platforms are Linux + macOS only. +Go 1.27+ is required. Target platforms are Linux + macOS + Windows. Useful targets: diff --git a/Makefile b/Makefile index 298c7cd..28c62ca 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,3 @@ -# Makefile for the Evolution DevServices CLI (eds). -# -# Targets: -# make build - build for the current GOOS/GOARCH into ./bin/eds -# make build-all - cross-compile the default matrix into ./dist/ -# make build-one - helper invoked by build-all (GOOS=... GOARCH=...) -# make clean - remove ./bin and ./dist -# make test - run `go test ./...` -# make tidy - run `go mod tidy` -# make install - `go install` into $GOBIN -# make release - build-all + sha256 sums -# make upload - build-all + publish to S3-compatible storage -# make upload-latest - only update the `latest` pointer in the bucket -# make help - print the list of targets -# -# GitHub Releases (primary distribution channel) are cut manually or via CI -# with `gh release create dist/* --generate-notes` after `make release`. -# `make upload`/`make upload-latest` are for an optional secondary mirror on -# S3-compatible storage. -# -# Overrides: -# make build-all OSES="linux darwin" ARCHS="amd64 arm64" -# make build VERSION=v0.2.0 -# make upload BUCKET=my-bucket PREFIX=evolution-devservices-cli VERSION=v0.2.0 - BINARY := eds PKG := github.com/cloud-ru/evolution-devservices-cli BUILD_DIR := bin @@ -149,6 +124,14 @@ upload-latest: rm -f $(DIST_DIR)/.latest && \ echo " ✔ latest -> $(VERSION)" +.PHONY: goreleaser-build +goreleaser-build: clean + goreleaser build --snapshot --clean + +.PHONY: goreleaser-release +goreleaser-release: clean + goreleaser release --clean + .PHONY: install install: CGO_ENABLED=$(CGO_ENABLED) go install $(GOFLAGS) \ @@ -172,7 +155,9 @@ help: @echo " build build for the current platform into ./bin/" @echo " build-all cross-compile darwin/linux/windows × amd64/arm64 into ./dist/" @echo " build-one helper for build-all (GOOS=... GOARCH=...)" - @echo " release build-all + sha256 checksums" + @echo " goreleaser-build local snapshot build via GoReleaser (into ./dist/)" + @echo " goreleaser-release full release via GoReleaser (requires a git tag)" + @echo " release build-all + sha256 checksums (legacy)" @echo " upload build-all + publish to S3 (BUCKET=... VERSION=...)" @echo " upload-latest only update the 'latest' pointer in the bucket" @echo " install go install into \$$GOBIN" diff --git a/README.md b/README.md index 626f3be..d10dc41 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,12 @@ go install github.com/cloud-ru/evolution-devservices-cli/cmd/eds@latest # or make build # ./bin/eds make build-all # cross-compile darwin/linux/windows × amd64/arm64 into ./dist/ +# or, with GoReleaser (https://goreleaser.com) +make goreleaser-build # snapshot build into ./dist/ ``` > Target platforms: **Linux + macOS + Windows** (developers locally + CI). -> Override the matrix if you ever need to: `make build-all OSES="linux darwin windows" ARCHS="amd64 arm64"`. +> Override the matrix if you ever need to: `make build-all OSES="linux darwin" ARCHS="amd64 arm64"`. ## Configuration @@ -264,6 +266,8 @@ ambient SSH setup the environment provides. Releases are published on [GitHub Releases](https://github.com/cloud-ru/evolution-devservices-cli/releases). +### Manual release (Makefile) + ```bash # cross-compile everything into ./dist/ + sha256 checksums make release @@ -273,6 +277,31 @@ git tag v0.2.0 && git push origin v0.2.0 gh release create v0.2.0 dist/* --generate-notes ``` +### GoReleaser release (recommended) + +This project includes a [GoReleaser](https://goreleaser.com) configuration +(`.goreleaser.yaml`) that mirrors the Makefile build matrix and produces the +same artifacts: + +```bash +# Local snapshot build (no tag required, produces ./dist/) +make goreleaser-build + +# Full release — requires a git tag; builds, checksums, and uploads to GitHub +# (draft release; publish manually or enable auto-publish in .goreleaser.yaml) +git tag v0.2.0 && git push origin v0.2.0 +make goreleaser-release +``` + +GoReleaser requires the `goreleaser` CLI to be installed: + +```bash +# macOS / Linux +brew install goreleaser +# or via Go +go install github.com/goreleaser/goreleaser/v2@latest +``` + `scripts/install.sh` downloads from the latest GitHub Release by default. The `Makefile` also has `make upload`/`make upload-latest` targets for optionally mirroring builds to an S3-compatible bucket (e.g. for internal @@ -300,6 +329,7 @@ make lint make test # go test ./... make build # current platform into ./bin/ make build-all # full matrix into ./dist/ +make goreleaser-build # snapshot build via GoReleaser into ./dist/ make clean # remove ./bin and ./dist make help # list targets ``` diff --git a/go.mod b/go.mod index b702175..72e0961 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cloud-ru/evolution-devservices-cli -go 1.26.6 +go 1.27.1 require ( github.com/google/uuid v1.6.0