Files
nocobase/.github/workflows/v3-github-release.yml

111 lines
3.6 KiB
YAML

name: V3 GitHub Release
# Create a GitHub Release for a release-beta/* or release/* aggregate tag.
# Package tags on the same commit identify the packages that were actually published.
# Reading those tags is repeatable and lets failed GitHub Release creation be retried.
#
# The release workflows call this explicitly after publication. It does not depend on tag events or commit-message
# CI skipping, and a manual dispatch can recover a failed GitHub Release without republishing packages.
on:
workflow_call:
inputs:
tag:
description: 'Aggregate release tag'
type: string
required: true
secrets:
NOCOBASE_APP_PRIVATE_KEY:
required: true
workflow_dispatch:
inputs:
tag:
description: 'Aggregate release tag, e.g. release-beta/2026-08-26.5'
type: string
required: true
permissions:
contents: read
jobs:
publish:
name: Publish the GitHub Release
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
# Release notes read changelogs at the tagged commit, so fetch complete history.
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Render the release notes
env:
TAG: ${{ inputs.tag }}
run: |
git fetch origin --tags --force
if ! git rev-parse --verify --quiet "refs/tags/${TAG}^{commit}" > /dev/null; then
echo "::error::Tag $TAG does not exist"
exit 1
fi
node scripts/release-notes.mjs "$TAG" > /tmp/release-notes.md
cat /tmp/release-notes.md
- name: Create a NocoBase release token
id: release_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.NOCOBASE_APP_ID }}
private-key: ${{ secrets.NOCOBASE_APP_PRIVATE_KEY }}
owner: nocobase
repositories: nocobase
permission-contents: write
# Keep the main repository's Latest release unchanged for both v3 channels.
# Existing releases are updated so this job can be retried independently.
- name: Create or update the GitHub Release
env:
GH_TOKEN: ${{ steps.release_token.outputs.token }}
TAG: ${{ inputs.tag }}
run: |
case "$TAG" in
release-beta/*) FLAGS=(--prerelease --latest=false) ;;
release/*) FLAGS=(--latest=false) ;;
*)
echo "::error::$TAG is not an aggregate release tag"
exit 1
;;
esac
TITLE="${TAG##*/}"
if gh release view "$TAG" > /dev/null 2>&1; then
gh release edit "$TAG" \
--title "$TITLE" \
--notes-file /tmp/release-notes.md \
"${FLAGS[@]}"
echo "Updated GitHub Release $TAG"
else
gh release create "$TAG" \
--verify-tag \
--title "$TITLE" \
--notes-file /tmp/release-notes.md \
"${FLAGS[@]}"
echo "Created GitHub Release $TAG"
fi
- name: Link the release in the job summary
env:
TAG: ${{ inputs.tag }}
run: |
{
echo "### GitHub Release"
echo
echo "[$TAG](${{ github.server_url }}/${{ github.repository }}/releases/tag/$(node -e 'console.log(encodeURIComponent(process.argv[1]))' "$TAG"))"
} >> "$GITHUB_STEP_SUMMARY"