ci: переезд на Task + GoReleaser + Release Please

- Taskfile.yml: build/test/lint/fmt/vuln/ci/tools, единая точка входа
- .goreleaser.yaml: 13 целевых платформ + Android .so + GHCR multi-arch образы
- release-please: автогенерация PR с CHANGELOG и тегов из conventional commits
- Dockerfile.goreleaser: тонкий alpine-runtime, бинарь подкладывает GoReleaser
  (старый multistage Dockerfile удалён)
- ci.yml: разнесён на lint/test/vuln/build-snapshot, версии actions запинены,
  добавлены concurrency и env-блок
- release.yml: 345 строк matrix-сборок сведены к запуску goreleaser на tag push
- golangci-lint v1.65.0 (несуществующая) → v2.12.2; путь /v2/cmd/, action
  v6.1.1 → v9.2.1
- cmd/{client,server}: var version для -ldflags -X main.version, лог версии
  при старте
- удалены: .github/workflows/issues.yml, docs/build.md (устарела после Task)
This commit is contained in:
samosvalishe committed 2026-05-23 00:25:57 +03:00
1 parent 8b2e028f99
commit 3ee9087323
16 files changed
+546 -577

No files matched your search

+82 -124
View File
@@ -1,152 +1,110 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
GO_VERSION: "1.25.0"
GOLANGCI_VERSION: v2.12.2
GOVULN_VERSION: v1.1.4
GORELEASER_VERSION: v2.5.0
TASK_VERSION: v3.40.0
jobs:
check:
name: Lint, fmt-check, and tests
lint:
name: Lint & format
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- uses: actions/checkout@v4.2.2
- name: Set up Go
uses: actions/setup-go@v6
- uses: actions/setup-go@v5.1.0
with:
go-version: 'stable'
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Cache Go modules
uses: actions/cache@v5
- uses: arduino/setup-task@v2.0.0
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
version: ${{ env.TASK_VERSION }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run gofmt (check)
run: |
echo "Checking formatting with gofmt..."
fmt_output=$(gofmt -l . || true)
if [ -n "$fmt_output" ]; then
echo "The following files need formatting:"
echo "$fmt_output"
echo "Run 'gofmt -w .' to fix."
exit 1
fi
- name: Format check
run: task fmt:check
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
- name: Vet
run: task vet
- uses: golangci/golangci-lint-action@v9.2.1
with:
version: latest
version: ${{ env.GOLANGCI_VERSION }}
args: --timeout=5m ./...
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
name: Test (race)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-go@v5.1.0
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- uses: arduino/setup-task@v2.0.0
with:
version: ${{ env.TASK_VERSION }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: |
go test -race ./... -v
build:
name: Build binaries
run: task test
vuln:
name: govulncheck
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
cgo: 0
- goos: darwin
goarch: arm64
cgo: 0
- goos: android
goarch: arm64
cgo: 1
api: 21
- goos: android
goarch: arm
cgo: 1
api: 21
# you can add more (android/arm, windows, etc.) later
steps:
- name: Check out code
uses: actions/checkout@v6
- uses: actions/checkout@v4.2.2
- uses: actions/setup-go@v5.1.0
with:
fetch-tags: true
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Set up Go
uses: actions/setup-go@v6
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@${{ env.GOVULN_VERSION }}
- run: govulncheck ./...
build-snapshot:
name: Snapshot build (all targets)
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v4.2.2
with:
go-version: 'stable'
fetch-depth: 0
# Install Android NDK for android rows and expose ndk-path output
- name: Setup Android NDK
if: matrix.goos == 'android'
id: setup-ndk
uses: nttld/setup-ndk@v1
- uses: actions/setup-go@v5.1.0
with:
ndk-version: r26d
add-to-path: false
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: ${{ matrix.cgo }}
ANDROID_API: ${{ matrix.api }}
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
echo "Building for $GOOS/$GOARCH (CGO_ENABLED=$CGO_ENABLED)"
# If this is an Android build, point CC at the NDK toolchain clang
if [ "$GOOS" = "android" ]; then
if [ -z "$ANDROID_NDK_HOME" ]; then
echo "ANDROID_NDK_HOME is not set – did setup-ndk run?"
exit 1
fi
TOOLCHAIN_BIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
if [ "$GOARCH" = "arm64" ]; then
export CC="$TOOLCHAIN_BIN/aarch64-linux-android${ANDROID_API}-clang"
elif [ "$GOARCH" = "arm" ]; then
export CC="$TOOLCHAIN_BIN/armv7a-linux-androideabi${ANDROID_API}-clang"
else
echo "Unsupported ANDROID GOARCH=$GOARCH"
exit 1
fi
echo "Using Android NDK CC=$CC"
fi
mkdir -p dist
ext=""
if [ "$GOOS" = "windows" ]; then
ext=".exe"
fi
GOOS=$GOOS GOARCH=$GOARCH \
go build -ldflags "-s -w -checklinkname=0" -trimpath \
-o "dist/client-${GOOS}-${GOARCH}${ext}" \
./cmd/client
GOOS=$GOOS GOARCH=$GOARCH \
go build -ldflags "-s -w -checklinkname=0" -trimpath \
-o "dist/server-${GOOS}-${GOARCH}${ext}" \
./cmd/server
- name: Upload artifact
uses: actions/upload-artifact@v6
- uses: goreleaser/goreleaser-action@v6.1.0
with:
name: good-turn-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/**
distribution: goreleaser
version: ${{ env.GORELEASER_VERSION }}
args: release --snapshot --clean --skip=publish,sign,docker,announce
- uses: actions/upload-artifact@v4.4.3
with:
name: snapshot-dist
path: dist/
retention-days: 7
-28
View File
@@ -1,28 +0,0 @@
name: "Close Stale Issues"
on:
schedule:
- cron: "0 0 * * 3"
workflow_dispatch:
jobs:
stale:
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: >
Привет! 👋
<br><br>
Данный issue давно не обновлялся. Если в течение недели здесь не будет больше активности, issue будет закрыт.
<br><br>
Спасибо!
close-issue-message: "Issue был закрыт из-за отсутствия активности."
days-before-stale: 120
days-before-close: 7
operations-per-run: 1000
ascending: true
enable-statistics: true
stale-issue-label: "Stale"
+23
View File
@@ -0,0 +1,23 @@
name: Release Please
on:
push:
branches: [main]
permissions:
contents: write
pull-requests: write
concurrency:
group: release-please-${{ github.ref }}
cancel-in-progress: false
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4.1.3
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
token: ${{ secrets.GITHUB_TOKEN }}
+28 -323
View File
@@ -1,345 +1,50 @@
name: Release
permissions:
contents: read
on:
push:
branches:
- main
workflow_dispatch:
tags:
- 'v*.*.*'
permissions:
contents: write
packages: write
env:
GO_VERSION: "1.25.0"
GORELEASER_VERSION: v2.5.0
jobs:
build:
name: Build binaries
goreleaser:
name: GoReleaser
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
cgo: 0
- goos: linux
goarch: arm64
cgo: 0
- goos: linux
goarch: 386
cgo: 0
- goos: linux
goarch: arm
goarm: "7"
cgo: 0
- goos: linux
goarch: mipsle
gomips: softfloat
cgo: 0
- goos: linux
goarch: mips
gomips: softfloat
cgo: 0
- goos: linux
goarch: mips64le
gomips: softfloat
cgo: 0
- goos: linux
goarch: riscv64
cgo: 0
- goos: darwin
goarch: amd64
cgo: 0
- goos: darwin
goarch: arm64
cgo: 0
- goos: windows
goarch: amd64
cgo: 0
- goos: windows
goarch: arm64
cgo: 0
- goos: windows
goarch: 386
cgo: 0
- goos: android
goarch: arm64
cgo: 1
api: 21
- goos: android
goarch: arm
cgo: 1
api: 21
- goos: freebsd
goarch: amd64
cgo: 0
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "stable"
# Install Android NDK only for android rows
- name: Setup Android NDK
if: matrix.goos == 'android'
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
ndk-version: r26d
add-to-path: false
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOMIPS: ${{ matrix.gomips }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: ${{ matrix.cgo }}
ANDROID_API: ${{ matrix.api }}
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
VERSION: ${{ github.ref_name }}
run: |
echo "Building for $GOOS/$GOARCH${GOARM:+/arm$GOARM} (CGO_ENABLED=$CGO_ENABLED)"
if [ "$GOOS" = "android" ]; then
if [ -z "$ANDROID_NDK_HOME" ]; then
echo "ANDROID_NDK_HOME is not set – did setup-ndk run?"
exit 1
fi
TOOLCHAIN_BIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
if [ "$GOARCH" = "arm64" ]; then
export CC="$TOOLCHAIN_BIN/aarch64-linux-android${ANDROID_API}-clang"
elif [ "$GOARCH" = "arm" ]; then
export CC="$TOOLCHAIN_BIN/armv7a-linux-androideabi${ANDROID_API}-clang"
else
echo "Unsupported ANDROID GOARCH=$GOARCH"
exit 1
fi
echo "Using Android NDK CC=$CC"
fi
mkdir -p dist
# Set extension for windows
if [ "${GOOS}" = "windows" ]; then
EXT=.exe
else
EXT=
fi
GOOS=$GOOS GOARCH=$GOARCH GOARM=$GOARM GOMIPS=$GOMIPS \
go build -ldflags "-s -w -checklinkname=0" -trimpath \
-o "dist/client-${GOOS}-${GOARCH}${EXT}" \
./cmd/client
GOOS=$GOOS GOARCH=$GOARCH GOARM=$GOARM GOMIPS=$GOMIPS \
go build -ldflags "-s -w -checklinkname=0" -trimpath \
-o "dist/server-${GOOS}-${GOARCH}${EXT}" \
./cmd/server
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: good-turn-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/**
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.meta.outputs.should_release }}
tag_name: ${{ steps.meta.outputs.tag_name }}
permissions:
contents: write
steps:
- name: Check out code
uses: actions/checkout@v6
- uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
fetch-tags: true
- name: Download build artifacts
uses: actions/download-artifact@v7
- uses: actions/setup-go@v5.1.0
with:
path: dist
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Prepare release metadata
id: meta
run: |
LATEST_TAG="$(git tag -l | grep -E '^(v)?[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1 || true)"
PREFIX=""
BASE_VERSION="$LATEST_TAG"
- uses: docker/setup-qemu-action@v3.2.0
if [ -z "$LATEST_TAG" ]; then
BASE_VERSION="0.0.0"
elif [ "${LATEST_TAG#v}" != "$LATEST_TAG" ]; then
PREFIX="v"
BASE_VERSION="${LATEST_TAG#v}"
fi
- uses: docker/setup-buildx-action@v3.7.1
IFS=. read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
if [ -n "$LATEST_TAG" ]; then
RANGE="$LATEST_TAG..HEAD"
else
RANGE="HEAD"
fi
COMMITS="$(git log --no-merges --format='%s' "$RANGE")"
BUMP=""
if printf '%s\n' "$COMMITS" | grep -Eiq '^break([(:! ]|$)'; then
BUMP="major"
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif printf '%s\n' "$COMMITS" | grep -Eiq '^(feat|refactor)([(:! ]|$)'; then
BUMP="minor"
MINOR=$((MINOR + 1))
PATCH=0
elif printf '%s\n' "$COMMITS" | grep -Eiq '^fix([(:! ]|$)'; then
BUMP="patch"
PATCH=$((PATCH + 1))
fi
NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}"
NEXT_TAG="${PREFIX}${NEXT_VERSION}"
{
echo "previous_tag=$LATEST_TAG"
echo "range=$RANGE"
echo "bump=$BUMP"
echo "should_release=$([ -n "$BUMP" ] && echo true || echo false)"
echo "tag_name=$NEXT_TAG"
echo "release_name=$NEXT_TAG"
echo "body_path=release-notes.md"
} >> "$GITHUB_OUTPUT"
- name: Generate release notes from commit messages
id: notes
if: steps.meta.outputs.should_release == 'true'
env:
PREVIOUS_TAG: ${{ steps.meta.outputs.previous_tag }}
NEXT_TAG: ${{ steps.meta.outputs.tag_name }}
BUMP: ${{ steps.meta.outputs.bump }}
RANGE: ${{ steps.meta.outputs.range }}
run: |
strip_prefix() {
sed -E 's/^(feat|fix|break|refactor)([(!:]|[[:space:]])+[[:space:]]*//I'
}
FEATURES="$(git log --no-merges --format='%s (%h)' "$RANGE" | grep -Ei '^feat([(:! ]|$)' | strip_prefix | LC_ALL=C sort -f || true)"
REFACTORS="$(git log --no-merges --format='%s (%h)' "$RANGE" | grep -Ei '^refactor([(:! ]|$)' | strip_prefix | LC_ALL=C sort -f || true)"
FIXES="$(git log --no-merges --format='%s (%h)' "$RANGE" | grep -Ei '^fix([(:! ]|$)' | strip_prefix | LC_ALL=C sort -f || true)"
BREAKING="$(git log --no-merges --format='%s (%h)' "$RANGE" | grep -Ei '^break([(:! ]|$)' | strip_prefix | LC_ALL=C sort -f || true)"
{
echo "body_path=release-notes.md"
} >> "$GITHUB_OUTPUT"
{
if [ -n "$BREAKING" ]; then
echo "### Breaking Changes"
echo
printf '%s\n' "$BREAKING" | sed 's/^/- /'
echo
fi
if [ -n "$FEATURES" ]; then
echo "### Features"
echo
printf '%s\n' "$FEATURES" | sed 's/^/- /'
echo
fi
if [ -n "$REFACTORS" ]; then
echo "### Refactoring"
echo
printf '%s\n' "$REFACTORS" | sed 's/^/- /'
echo
fi
if [ -n "$FIXES" ]; then
echo "### Bug Fixes"
echo
printf '%s\n' "$FIXES" | sed 's/^/- /'
echo
fi
} > release-notes.md
- name: Create Release
if: steps.meta.outputs.should_release == 'true'
uses: softprops/action-gh-release@v2
with:
# upload every file in dist/ including nested files
files: |
dist/**
tag_name: ${{ steps.meta.outputs.tag_name }}
target_commitish: ${{ github.sha }}
name: ${{ steps.meta.outputs.release_name }}
body_path: ${{ steps.meta.outputs.body_path }}
overwrite_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Skip release when no semantic commit is found
if: steps.meta.outputs.should_release != 'true'
run: |
echo "No new semantic release created."
echo "Add a commit starting with break, feat, fix, or refactor after the latest tag."
docker:
name: Publish Docker image
needs: release
if: needs.release.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Prepare image name
id: image
env:
REPOSITORY: ${{ github.repository }}
run: |
echo "name=ghcr.io/$(echo "$REPOSITORY" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
- name: Log in to GHCR
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ steps.image.outputs.name }}
tags: |
type=raw,value=latest
type=raw,value=${{ needs.release.outputs.tag_name }}
- name: Install syft (SBOM)
uses: anchore/sbom-action/download-syft@v0.17.7
- name: Build and push Docker image
uses: docker/build-push-action@v7
- uses: goreleaser/goreleaser-action@v6.1.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
distribution: goreleaser
version: ${{ env.GORELEASER_VERSION }}
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}