mirror of
https://github.com/kochetkov-ma/claude-brewcode.git
synced 2026-09-14 20:16:41 +08:00
89 lines
3.1 KiB
YAML
89 lines
3.1 KiB
YAML
# Creates a GitHub Release when a version tag (v*.*.*) is pushed to main.
|
|
# Extracts the matching changelog section from RELEASE-NOTES.md
|
|
# and appends installation instructions to the release body.
|
|
|
|
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Verify tag is on main
|
|
run: |
|
|
git fetch origin main
|
|
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
|
|
echo "::error::Tag $GITHUB_REF_NAME is not on the main branch. Skipping release."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Extract changelog for tag version
|
|
id: changelog
|
|
run: |
|
|
# Strip "v" prefix from tag to get version number (e.g. v2.15.4 -> 2.15.4)
|
|
TAG="${GITHUB_REF_NAME}"
|
|
VERSION="${TAG#v}"
|
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
|
|
|
RELEASE_NOTES="RELEASE-NOTES.md"
|
|
|
|
if [ ! -f "$RELEASE_NOTES" ]; then
|
|
echo "::error::${RELEASE_NOTES} not found"
|
|
exit 1
|
|
fi
|
|
|
|
# Extract the section for this version.
|
|
# Match: ## [VERSION] or ## vVERSION or ## VERSION
|
|
# Stop at the next version header or --- separator line.
|
|
BODY=$(awk -v ver="$VERSION" '
|
|
BEGIN { found=0 }
|
|
# Match header: ## [2.15.4], ## v2.15.4, or ## 2.15.4
|
|
$0 ~ "^## (\\[" ver "\\]|v?" ver ")([^0-9.]|$)" {
|
|
found=1
|
|
print
|
|
next
|
|
}
|
|
# Stop at next version header (any of the three formats) or --- separator
|
|
found && $0 ~ "^## (\\[|v?[0-9])" { exit }
|
|
found && /^---[[:space:]]*$/ { exit }
|
|
found { print }
|
|
' "$RELEASE_NOTES")
|
|
|
|
if [ -z "$BODY" ]; then
|
|
echo "::error::No changelog section found for version ${VERSION} in ${RELEASE_NOTES}"
|
|
exit 1
|
|
fi
|
|
|
|
# Write changelog to temp file
|
|
echo "$BODY" > /tmp/release-body.md
|
|
|
|
# Append install instructions
|
|
printf '\n---\n\n## Quick Install\n\n```bash\n# 1. Add marketplace (one-time)\nclaude plugin marketplace add https://github.com/kochetkov-ma/claude-brewcode\n\n# 2. Install plugins\nclaude plugin install brewcode@claude-brewcode\nclaude plugin install brewdoc@claude-brewcode\n```\n\n## Already installed? Update\n\n```bash\nclaude plugin marketplace update claude-brewcode\nclaude plugin update brewcode@claude-brewcode\nclaude plugin update brewdoc@claude-brewcode\n```\n' >> /tmp/release-body.md
|
|
|
|
echo "Release body written to /tmp/release-body.md"
|
|
echo "--- Preview (first 20 lines) ---"
|
|
head -20 /tmp/release-body.md
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ steps.changelog.outputs.tag }}
|
|
name: ${{ steps.changelog.outputs.tag }}
|
|
body_path: /tmp/release-body.md
|
|
draft: false
|
|
prerelease: false
|