Files
opencode-command-window/.gitea/workflows/release.yml
T
deepseek Botandopencode v2.3.0 2a54e69e87
mirror / mirror (push) Successful in 6s
refactor: use gitea-release-action for Gitea releases
Replace the hand-written release API calls with the community
gitea-release-action, which already handles the get-then-create-or-update
flow. The prepare step still validates the tag against package.json and
writes the commit list that the action reads through body_path.

Co-authored-by: opencode v2.3.0
2026-11-15 07:52:33 +08:00

94 lines
2.7 KiB
YAML

name: release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: Existing tag to create the release for
required: true
permissions:
contents: read
releases: write
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
runs-on: host
steps:
- name: Prepare the release
id: prepare
shell: bash
env:
REPOSITORY: ${{ gitea.repository }}
REF_NAME: ${{ gitea.ref_name }}
INPUT_TAG: ${{ inputs.tag }}
BODY_PATH: ${{ gitea.workspace }}/release-body.md
run: |
set -euo pipefail
tag="${INPUT_TAG:-$REF_NAME}"
if [[ ! "$tag" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)([-+][0-9A-Za-z.+-]+)?$ ]]; then
echo "not a version tag: $tag" >&2
exit 1
fi
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
git clone --quiet --no-checkout "${GITHUB_SERVER_URL}/${REPOSITORY}.git" "$work/repo"
cd "$work/repo"
if ! git rev-parse --verify --quiet "refs/tags/$tag" >/dev/null; then
echo "tag not found: $tag" >&2
exit 1
fi
version="$(git show "$tag:package.json" | node -e '
let input = "";
process.stdin.on("data", (chunk) => { input += chunk; });
process.stdin.on("end", () => { process.stdout.write(JSON.parse(input).version); });
')"
if [ "v$version" != "$tag" ]; then
echo "tag $tag does not match package version $version" >&2
exit 1
fi
previous="$(git describe --tags --abbrev=0 --match 'v[0-9]*' "$tag^" 2>/dev/null || true)"
if [ -n "$previous" ]; then
range="$previous..$tag"
else
range="$tag"
fi
body="$(git log --no-merges --pretty=format:'- %s (%h)' "$range")"
if [ -z "$body" ]; then
body="- No changes recorded."
fi
prerelease=false
case "${tag%%+*}" in
*-*) prerelease=true ;;
esac
printf '%s\n' "$body" > "$BODY_PATH"
{
echo "tag=$tag"
echo "prerelease=$prerelease"
} >> "$GITHUB_OUTPUT"
- name: Create or update the Gitea release
uses: https://gitea.com/actions/gitea-release-action@v1
with:
server_url: ${{ gitea.server_url }}
token: ${{ secrets.GITEA_TOKEN }}
tag_name: ${{ steps.prepare.outputs.tag }}
name: ${{ steps.prepare.outputs.tag }}
body_path: ${{ gitea.workspace }}/release-body.md
prerelease: ${{ steps.prepare.outputs.prerelease }}
draft: false