Build infrastructure for releases
Some checks failed
release / release (push) Has been cancelled

- Makefile: cross-compile to linux/{amd64,arm64}, darwin/{amd64,arm64},
  windows/amd64 into dist/ with SHA256SUMS. Version is stamped via
  -ldflags '-X main.version=...'.
- .gitea/workflows/release.yml: on tag push (v*) the workflow runs
  `make dist`, creates a Gitea release for the tag and uploads every
  artefact from dist/ via the Gitea API.
- main.go: `rb-search version` / --version prints the stamped version.
- README: new "Готовые бинари" section with curl/Invoke-WebRequest
  install snippets and a checksum-verify hint.
This commit is contained in:
2026-05-26 13:46:16 +05:00
parent 7f9be47039
commit be3251716c
5 changed files with 125 additions and 7 deletions

View File

@@ -0,0 +1,51 @@
name: release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Build cross-platform binaries
run: make dist VERSION=${{ github.ref_name }}
- name: Create release and upload assets
env:
TOKEN: ${{ secrets.GITEA_TOKEN }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
body=$(cat <<EOF
Автоматический релиз $TAG.
Скачайте бинарь под свою ОС/архитектуру и положите на PATH.
Проверка целостности: \`sha256sum -c SHA256SUMS\`.
EOF
)
payload=$(jq -n --arg tag "$TAG" --arg body "$body" \
'{tag_name:$tag, name:$tag, body:$body, draft:false, prerelease:false}')
release_id=$(curl -fsSL -X POST \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "$payload" \
"$API/releases" | jq -r .id)
for f in dist/*; do
name=$(basename "$f")
echo "uploading $name"
curl -fsSL -X POST \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$f" \
"$API/releases/$release_id/assets?name=$name" >/dev/null
done
echo "released $TAG with $(ls dist | wc -l) assets"

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
/rb-search
/dist/
*.test
*.out

33
Makefile Normal file
View File

@@ -0,0 +1,33 @@
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
DIST := dist
PLATFORMS := \
linux/amd64 \
linux/arm64 \
darwin/amd64 \
darwin/arm64 \
windows/amd64
.PHONY: build dist clean
build:
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o rb-search .
dist:
@rm -rf $(DIST)
@mkdir -p $(DIST)
@for plat in $(PLATFORMS); do \
os=$${plat%/*}; arch=$${plat#*/}; \
ext=""; if [ "$$os" = "windows" ]; then ext=".exe"; fi; \
name=rb-search-$(VERSION)-$$os-$$arch$$ext; \
echo " build $$name"; \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch \
go build -trimpath -ldflags '$(LDFLAGS)' -o $(DIST)/$$name . || exit 1; \
done
@cd $(DIST) && sha256sum rb-search-* > SHA256SUMS
@echo "built artefacts:"
@ls -lh $(DIST)
clean:
rm -rf $(DIST) rb-search

View File

@@ -22,9 +22,36 @@
## Установка
### Готовые бинари (рекомендуется)
Собранные релизы лежат на странице
[Releases](https://git.arx.ru/shuricken/rb-search/releases) — Linux/macOS/Windows,
amd64 и arm64. Скачать соответствующий файл, проверить контрольную сумму
из `SHA256SUMS` и положить на `PATH`:
```bash
# Linux/macOS, под свою архитектуру
curl -LO https://git.arx.ru/shuricken/rb-search/releases/download/vX.Y.Z/rb-search-vX.Y.Z-linux-amd64
curl -LO https://git.arx.ru/shuricken/rb-search/releases/download/vX.Y.Z/SHA256SUMS
sha256sum --ignore-missing -c SHA256SUMS
chmod +x rb-search-*
sudo mv rb-search-* /usr/local/bin/rb-search
```
```powershell
# Windows PowerShell
Invoke-WebRequest -OutFile rb-search.exe `
https://git.arx.ru/shuricken/rb-search/releases/download/vX.Y.Z/rb-search-vX.Y.Z-windows-amd64.exe
Move-Item rb-search.exe $env:USERPROFILE\bin\
```
Проверка установки: `rb-search version` → печатает версию.
### Из исходников
Нужен Go 1.22+. Бинарь самодостаточный, без внешних зависимостей в рантайме.
### Из исходников (любая ОС)
#### Любая ОС
```bash
git clone ssh://git@git.arx.ru:2222/shuricken/rb-search.git
@@ -37,7 +64,7 @@ go build -o rb-search .
- Linux/macOS: `install -m 0755 rb-search ~/.local/bin/` или `sudo mv rb-search /usr/local/bin/`
- Windows (PowerShell): `Move-Item rb-search.exe $env:USERPROFILE\bin\`
### Через `go install`
#### Через `go install`
```bash
go install git.arx.ru/shuricken/rb-search@latest
@@ -49,14 +76,14 @@ go install git.arx.ru/shuricken/rb-search@latest
- fish: `fish_add_path (go env GOPATH)/bin`
- Windows: `setx PATH "%PATH%;%USERPROFILE%\go\bin"` (новые терминалы)
### Arch Linux
#### Arch Linux
```bash
sudo pacman -S go
go install git.arx.ru/shuricken/rb-search@latest
```
### Debian / Ubuntu
#### Debian / Ubuntu
```bash
sudo apt install golang-go
@@ -66,20 +93,20 @@ go install git.arx.ru/shuricken/rb-search@latest
Если в репозитории старый Go (< 1.22) — собрать из исходников после установки
`go` через `snap` или `gvm`.
### macOS
#### macOS
```bash
brew install go
go install git.arx.ru/shuricken/rb-search@latest
```
### Windows
#### Windows
1. Поставить Go с https://go.dev/dl/.
2. В PowerShell: `go install git.arx.ru/shuricken/rb-search@latest`.
3. Бинарь окажется в `%USERPROFILE%\go\bin\rb-search.exe`.
### Кросс-компиляция
#### Кросс-компиляция
С Linux собрать под другую платформу:

View File

@@ -11,6 +11,9 @@ import (
"time"
)
// version is overridden at build time via -ldflags '-X main.version=...'.
var version = "dev"
const usage = `rb-search — peek into a RabbitMQ queue without consuming.
Reads N=queue-depth messages with basic.get + manual ack, runs a substring
@@ -72,6 +75,9 @@ func run(args []string) error {
return cmdSetDefault(args[1:])
case "init":
return cmdInit(args[1:])
case "version", "--version", "-V":
fmt.Println(version)
return nil
case "help", "-h", "--help":
fmt.Print(usage)
return nil