Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 53 additions & 74 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Release

# A version tag publishes a release. The manual trigger runs the same build but
# stops before publishing and keeps the archives as workflow artifacts, which is
# the safe way to check the pipeline without creating a release.
# A version tag publishes a release with GoReleaser. The manual trigger runs the
# same verification and a snapshot build, but stops before publishing.
on:
push:
tags: ['v*']
Expand All @@ -16,8 +15,8 @@ concurrency:
cancel-in-progress: false

jobs:
release:
name: build and publish
verify:
name: verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
Expand Down Expand Up @@ -53,91 +52,71 @@ jobs:
exit 1
fi

- name: build the archives
run: make release
- name: test
run: go test ./... -count=1

- name: check the GoReleaser configuration
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: '~> v2'
args: check

- name: build the archives without publishing
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: '~> v2'
args: release --snapshot --clean

- name: smoke test the linux build
shell: bash
run: |
set -e
version='${{ steps.version.outputs.value }}'
archive=$(ls dist/cli-proxy_*_linux_amd64.tar.gz | head -1)
echo "testing $archive"
tmp=$(mktemp -d)
tar -xzf "dist/cli-proxy_${version}/cli-proxy_${version}_linux_amd64.tar.gz" -C "$tmp"
got=$("$tmp/cli-proxy" -version)
echo "binary reports: $got"
if [ "$got" != "cli-proxy $version" ]; then
echo "::error::unexpected version output: $got"
exit 1
fi
"$tmp/cli-proxy" -h >/dev/null
tar -xzf "$archive" -C "$tmp"
test -f "$tmp/README.md"
test -f "$tmp/LICENSE"
"$tmp/cli-proxy" -h >/dev/null
"$tmp/cli-proxy" -version

- name: verify the checksums
shell: bash
run: |
cd "dist/cli-proxy_${{ steps.version.outputs.value }}"
sha256sum -c checksums.txt
run: cd dist && sha256sum -c checksums.txt

- name: keep the archives as workflow artifacts
- name: keep the snapshot archives
uses: actions/upload-artifact@v7
with:
name: cli-proxy-archives
path: dist/cli-proxy_*/
name: cli-proxy-snapshot
path: |
dist/cli-proxy_*.tar.gz
dist/cli-proxy_*.zip
dist/checksums.txt
if-no-files-found: error
retention-days: 14

release:
name: publish
needs: verify
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0

- uses: actions/setup-go@v7
with:
go-version-file: go.mod
check-latest: true

- name: publish the release
if: startsWith(github.ref, 'refs/tags/')
shell: bash
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
version='${{ steps.version.outputs.value }}'
dir="dist/cli-proxy_${version}"

# A short preamble, then the commits since the previous tag.
cat > /tmp/notes.md <<'PREAMBLE'
Статический бинарник без внешних зависимостей — только стандартная
библиотека Go. В каждом архиве программа, `README.md` и `LICENSE`;
контрольные суммы — в `checksums.txt`.

| Платформа | Файл |
|---|---|
| Linux x86-64 | `cli-proxy_<версия>_linux_amd64.tar.gz` |
| Linux arm64 | `cli-proxy_<версия>_linux_arm64.tar.gz` |
| macOS Apple Silicon | `cli-proxy_<версия>_darwin_arm64.tar.gz` |
| macOS Intel | `cli-proxy_<версия>_darwin_amd64.tar.gz` |
| Windows x86-64 | `cli-proxy_<версия>_windows_amd64.zip` |

```sh
tar -xzf cli-proxy_<версия>_darwin_arm64.tar.gz
./cli-proxy -install-cert # довериться корневому сертификату
./cli-proxy -system-proxy # направить системный прокси сюда
```

## Изменения
PREAMBLE

# The template uses a placeholder so the heredoc can stay quoted.
sed "s/<версия>/${version}/g" /tmp/notes.md > /tmp/notes.fixed
mv /tmp/notes.fixed /tmp/notes.md

previous=$(git describe --tags --abbrev=0 "${tag}^" 2>/dev/null || true)
if [ -n "$previous" ]; then
echo "listing commits ${previous}..${tag}" >&2
git log --no-merges --pretty='- %s' "${previous}..${tag}" >> /tmp/notes.md
else
git log --no-merges --pretty='- %s' "${tag}" >> /tmp/notes.md
fi
echo >> /tmp/notes.md

gh release create "$tag" \
--title "cli-proxy $tag" \
--notes-file /tmp/notes.md \
--verify-tag \
"${dir}"/cli-proxy_"${version}"_*.tar.gz \
"${dir}"/cli-proxy_"${version}"_*.zip \
"${dir}"/checksums.txt
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90 changes: 90 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
version: 2

project_name: cli-proxy

before:
hooks:
- go mod tidy

builds:
- id: cli-proxy
main: .
binary: cli-proxy
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
flags:
- -trimpath
ldflags:
- -s -w

archives:
- id: release
# Prebuilt archives keep the name the README documents:
# cli-proxy_<version>_<os>_<arch>.tar.gz, and .zip on Windows.
name_template: >-
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}
formats:
- tar.gz
format_overrides:
- goos: windows
formats:
- zip
files:
- README.md
- LICENSE

checksum:
name_template: checksums.txt
algorithm: sha256

snapshot:
version_template: '{{ incpatch .Version }}-snapshot'

changelog:
use: git
sort: asc
filters:
exclude:
- '^docs:'
- '^ci:'
- '^test:'
- '^chore'

release:
draft: false
prerelease: auto
name_template: 'cli-proxy {{ .Tag }}'
header: |
Статический бинарник без внешних зависимостей — только стандартная
библиотека Go. В каждом архиве программа, `README.md` и `LICENSE`;
контрольные суммы — в `checksums.txt`.

| Платформа | Файл |
|---|---|
| Linux x86-64 | `cli-proxy_{{ .Version }}_linux_amd64.tar.gz` |
| Linux arm64 | `cli-proxy_{{ .Version }}_linux_arm64.tar.gz` |
| macOS Apple Silicon | `cli-proxy_{{ .Version }}_darwin_arm64.tar.gz` |
| macOS Intel | `cli-proxy_{{ .Version }}_darwin_amd64.tar.gz` |
| Windows x86-64 | `cli-proxy_{{ .Version }}_windows_amd64.zip` |

```sh
brew install sadgoodman/tap/cli-proxy
```

```sh
tar -xzf cli-proxy_{{ .Version }}_darwin_arm64.tar.gz
./cli-proxy -install-cert # довериться корневому сертификату
./cli-proxy -system-proxy # направить системный прокси сюда
```
footer: |
**Полное руководство:** [docs/guide.md](https://github.com/sadgoodman/cli-proxy/blob/master/docs/guide.md)
(есть также [русская версия](https://github.com/sadgoodman/cli-proxy/blob/master/docs/guide.ru.md)).

Установка одной командой: `brew install sadgoodman/tap/cli-proxy`.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ BINARY := cli-proxy
GOFLAGS ?=
LDFLAGS := -s -w
VERSION := $(shell sed -n 's/^const version = "\(.*\)"/\1/p' main.go)
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64
RELDIR := dist/$(BINARY)_$(VERSION)

.PHONY: all build slim test vet fmt run clean cross release
Expand Down Expand Up @@ -37,6 +37,8 @@ cross:
GOOS=windows GOARCH=amd64 go build -trimpath -ldflags="$(LDFLAGS)" -o dist/$(BINARY)-windows-amd64.exe .

# Build the archives attached to a GitHub release, plus checksums.
# CI uses GoReleaser for this; the target is kept so a release can be reproduced
# locally without installing anything.
release: clean
rm -rf $(RELDIR)
@for target in $(PLATFORMS); do \
Expand Down
4 changes: 4 additions & 0 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ estático, **sin dependencias externas** — solo la biblioteca estándar.

## Instalación

```sh
brew install sadgoodman/tap/cli-proxy
```

Descarga un archivo precompilado desde la [última versión][rel], o compílalo
desde el código fuente con Go 1.25+.

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ dependencies** — standard library only.

## Install

```sh
brew install sadgoodman/tap/cli-proxy
```

Download a prebuilt archive from the [latest release][rel], or build from
source with Go 1.25+.

Expand Down
4 changes: 4 additions & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@

## Установка

```sh
brew install sadgoodman/tap/cli-proxy
```

Скачайте готовый архив из [последнего релиза][rel] или соберите из исходников
(нужен Go 1.25+).

Expand Down
4 changes: 4 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@

## 安装

```sh
brew install sadgoodman/tap/cli-proxy
```

从[最新发布][rel]下载预编译压缩包,或使用 Go 1.25+ 从源码构建。

| 平台 | 资源文件 |
Expand Down
26 changes: 25 additions & 1 deletion docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ dependencies** — the Go standard library only.
keyboard-driven, plus the mouse: hovering highlights rows, tabs and buttons,
clicking selects. Menu items switch with `←`/`→` (or `Tab`).

## Installing

Homebrew is the shortest route:

```sh
brew install sadgoodman/tap/cli-proxy
```

Otherwise download a prebuilt archive from the [latest release][rel]:

| Platform | Asset |
|---|---|
| Linux x86-64 | `cli-proxy_<version>_linux_amd64.tar.gz` |
| Linux arm64 | `cli-proxy_<version>_linux_arm64.tar.gz` |
| macOS Apple Silicon | `cli-proxy_<version>_darwin_arm64.tar.gz` |
| macOS Intel | `cli-proxy_<version>_darwin_amd64.tar.gz` |
| Windows x86-64 | `cli-proxy_<version>_windows_amd64.zip` |

`checksums.txt` in the same release carries the SHA-256 of every archive.

The Homebrew formula updates itself: [`sadgoodman/homebrew-tap`][tap] is checked
against the latest release every hour. To pick a release up immediately, run the
**Update formulae** workflow from the Actions tab.

## Building

```sh
Expand Down Expand Up @@ -556,7 +580,7 @@ make cross # build for every supported platform

1. it checks the version in `main.go` against the tag and fails if they
disagree;
2. it builds the archives (`make release`), verifies the checksums and runs the
2. it builds the archives with GoReleaser (`goreleaser release`), verifies the checksums and runs the
built Linux binary;
3. it publishes a GitHub Release with the archives, `checksums.txt` and the
list of commits since the previous tag.
Expand Down
26 changes: 25 additions & 1 deletion docs/guide.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,30 @@
клавиатурный, плюс мышь: наведение подсвечивает строки, вкладки и кнопки,
клик выбирает. Пункты меню переключаются стрелками `←`/`→` (или `Tab`).

## Установка

Через Homebrew — короче всего:

```sh
brew install sadgoodman/tap/cli-proxy
```

Или скачайте готовый архив из [последнего релиза][rel]:

| Платформа | Файл |
|---|---|
| Linux x86-64 | `cli-proxy_<версия>_linux_amd64.tar.gz` |
| Linux arm64 | `cli-proxy_<версия>_linux_arm64.tar.gz` |
| macOS Apple Silicon | `cli-proxy_<версия>_darwin_arm64.tar.gz` |
| macOS Intel | `cli-proxy_<версия>_darwin_amd64.tar.gz` |
| Windows x86-64 | `cli-proxy_<версия>_windows_amd64.zip` |

В том же релизе лежит `checksums.txt` с SHA-256 каждого архива.

Формула Homebrew обновляется сама: репозиторий [`sadgoodman/homebrew-tap`][tap]
раз в час сверяется с последним релизом. Если нужно сразу после выпуска,
запустите workflow **Update formulae** во вкладке Actions.

## Сборка

```sh
Expand Down Expand Up @@ -541,7 +565,7 @@ make cross # собрать под все поддерживаемые пл
`.github/workflows/release.yml` реагирует на тег вида `v*`:

1. сверяет версию из `main.go` с тегом и падает, если они разошлись;
2. собирает архивы (`make release`), проверяет контрольные суммы и запускает
2. собирает архивы через GoReleaser (`goreleaser release`), проверяет контрольные суммы и запускает
собранный linux-бинарник;
3. публикует GitHub Release с архивами, `checksums.txt` и списком коммитов
с прошлого тега.
Expand Down
Loading