Files
a.gritsenkoandClaude Opus 5.5 661a862f8d
build / build (push) Successful in 1m1s
Revert automatic releases on every push to main
Releases are published only for manually pushed v* tags again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 10:33:35 +03:00

73 lines
2.0 KiB
YAML

name: build
on:
push:
branches: ["**"]
tags: ["v*"]
pull_request:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: https://gitea.com/actions/checkout@v4
- uses: https://gitea.com/actions/setup-go@v5
with:
go-version: "1.22"
- name: vet & test
run: |
go vet ./...
go test ./...
- name: install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
- name: build packages
run: |
export PATH="$PATH:$(go env GOPATH)/bin"
./build.sh
# upload-artifact@v4 needs the newer Actions Results API, which Gitea
# doesn't implement yet ("GHESNotSupportedError") - v3 works.
- uses: https://gitea.com/actions/upload-artifact@v3
with:
name: nasmon-packages
path: |
dist/*.deb
dist/*.rpm
- name: publish release
if: startsWith(github.ref, 'refs/tags/')
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
API: ${{ github.api_url }}/repos/${{ github.repository }}
run: |
set -euo pipefail
tag="${GITHUB_REF#refs/tags/}"
release_id=$(curl -sf -X POST "$API/releases" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$tag\",\"name\":\"$tag\"}" \
| grep -oP '"id":\s*\K[0-9]+' | head -1) || \
release_id=$(curl -sf "$API/releases/tags/$tag" \
-H "Authorization: token $GITEA_TOKEN" \
| grep -oP '"id":\s*\K[0-9]+' | head -1)
if [ -z "$release_id" ]; then
echo "could not create or find a release for tag $tag" >&2
exit 1
fi
for f in dist/*.deb dist/*.rpm; do
[ -e "$f" ] || continue
curl -sf -X POST "$API/releases/$release_id/assets?name=$(basename "$f")" \
-H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@${f}"
done