Publishes the module to Gitea Package Registry on tag push (v*). Runs vet and tests before publishing to prevent broken releases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1016 B
YAML
40 lines
1016 B
YAML
name: Publish
|
|
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.24"
|
|
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
- name: Test
|
|
run: go test -race -count=1 ./...
|
|
|
|
- name: Publish to Gitea Package Registry
|
|
run: |
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
MODULE=$(go list -m)
|
|
go mod download
|
|
GOFLAGS=-mod=mod go install golang.org/x/mod/zip@latest
|
|
zip -r module.zip . -x '.git/*' '.gitea/*'
|
|
|
|
# Gitea Go Package Registry API
|
|
curl -s -f \
|
|
-X PUT \
|
|
-H "Authorization: token ${{ secrets.PUBLISH_TOKEN }}" \
|
|
-H "Content-Type: application/zip" \
|
|
--data-binary @module.zip \
|
|
"${{ github.server_url }}/api/packages/pkg/go/upload?module=${MODULE}&version=${VERSION}"
|
|
env:
|
|
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
|