Files
kmsvc-sdk/.gitea/workflows/release.yaml
T

72 lines
2.1 KiB
YAML

name: release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
jobs:
release:
runs-on: docker
container:
image: golang:1.25
env:
GOPRIVATE: forgejo.riotpiao.com
steps:
- name: install node + curl + jq (required by JS-based actions / release API call)
run: apt-get update && apt-get install -y --no-install-recommends nodejs ca-certificates git curl jq
- uses: actions/checkout@v4
- name: configure git auth for private module fetch
run: |
git config --global url."https://oauth2:${FORGEJO_PAT}@forgejo.riotpiao.com".insteadOf "https://forgejo.riotpiao.com"
env:
FORGEJO_PAT: ${{ secrets.FORGEJO_PAT }}
# A tag is the public contract for `go get [email protected]` — re-run the full
# gate before publishing a release, never trust that main was green.
- name: go vet
run: go vet ./...
- name: go build
run: go build ./...
- name: go test
run: go test ./... -race
- name: extract changelog section
id: changelog
run: |
tag="${GITHUB_REF_NAME}"
version="${tag#v}"
notes="$(awk -v ver="$version" '
$0 ~ "^## v"ver"([^.0-9]|$)" { found=1; next }
found && /^## / { exit }
found { print }
' CHANGELOG.md)"
if [ -z "$notes" ]; then
notes="(no changelog entry found for $tag)"
fi
{
echo "notes<<EOF"
echo "$notes"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: create forgejo release
run: |
curl -fsSL -X POST \
-H "Authorization: token ${FORGEJO_TOKEN}" \
-H "Content-Type: application/json" \
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases" \
-d "$(jq -n \
--arg tag "$GITHUB_REF_NAME" \
--arg body "${{ steps.changelog.outputs.notes }}" \
'{tag_name: $tag, name: $tag, body: $body, draft: false, prerelease: false}')"
env:
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}