tests / build-test (push) Has been cancelled
The Gitea runner is registered with the label `linux`, so `ubuntu-latest` never matched and the workflows could not start. This applies to both the test and release workflows. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
83 lines
2.6 KiB
YAML
83 lines
2.6 KiB
YAML
# Gitea Actions — Release
|
|
#
|
|
# Triggered whenever the `version` file at the repository root is bumped.
|
|
# Creates a Gitea release tagged with the new version — but ONLY if the
|
|
# version in `version` differs from the latest released tag.
|
|
#
|
|
# No secret is required: `secrets.GITEA_TOKEN` is the built-in automatic
|
|
# token provided by Gitea on every run. The `permissions: contents: write`
|
|
# block below asks for write access to contents and releases, so the release
|
|
# can be created without configuring any secret in the repository settings.
|
|
# Tests are deliberately not run here; they live in the separate `tests`
|
|
# workflow and do not gate releases.
|
|
|
|
name: release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- version
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
# Reads the new version and publishes a release + git tag when the version
|
|
# genuinely changed. Runs without any test step.
|
|
release:
|
|
runs-on: linux
|
|
steps:
|
|
- name: Checkout with full history and tags
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Read version
|
|
id: version
|
|
run: |
|
|
VERSION=$(tr -d ' \n' < version)
|
|
echo "value=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Check whether the version already has a release
|
|
id: check
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.value }}"
|
|
TAG="v${VERSION}"
|
|
if git tag --list | grep -qx "${TAG}"; then
|
|
echo "Tag ${TAG} already exists — nothing to release"
|
|
echo "new=false" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "new=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Create release
|
|
if: steps.check.outputs.new == 'true'
|
|
env:
|
|
# Built-in automatic token, no secret to configure. The
|
|
# `permissions` block at the top grants it write access to
|
|
# contents/releases for this run.
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.value }}"
|
|
TAG="v${VERSION}"
|
|
BODY=$(cat <<'EOF'
|
|
Release automatically generated by the `release` workflow when the
|
|
`version` file was bumped.
|
|
EOF
|
|
)
|
|
curl -sS -X POST "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d @- <<JSON
|
|
{
|
|
"tag_name": "${TAG}",
|
|
"target_commitish": "main",
|
|
"name": "v${VERSION}",
|
|
"body": "${BODY}"
|
|
}
|
|
JSON
|