Skip to content

chore: ignore the local new-example prompt doc #46

chore: ignore the local new-example prompt doc

chore: ignore the local new-example prompt doc #46

Workflow file for this run

name: Release
on:
push:
branches: [main]
workflow_dispatch: {}
permissions:
contents: write
concurrency:
group: release
cancel-in-progress: false
jobs:
version-and-release:
name: Bump version, tag, and release
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get current version
id: current
run: |
version=$(cat VERSION | tr -d '[:space:]')
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Current version: $version"
- name: Determine bump type from commits
id: bump
run: |
last_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$last_tag" ]; then
commits=$(git log --oneline --format="%s")
else
commits=$(git log "$last_tag"..HEAD --oneline --format="%s")
fi
echo "Commits since last release:"
echo "$commits"
# Release ONLY when a commit subject since the last tag carries a release-worthy
# conventional prefix. docs/chore/ci/refactor/test/style/build/perf land WITHOUT
# cutting a release. A mixed push (docs + a real fix) still releases: the scan
# matches any release-worthy commit in the range regardless of the others.
# [skip ci] (guarded on the job) remains an optional belt-and-suspenders override.
bump="patch"
release="false"
if [ -z "$last_tag" ]; then
# Initial release: no prior tag -> cut the first release at the current VERSION.
release="true"
elif echo "$commits" | grep -qiE "^(feat|feature|fix)(\(.+\))?!:|BREAKING[ -]CHANGE"; then
bump="major"; release="true"
elif echo "$commits" | grep -qiE "^(feat|feature)(\(.+\))?:"; then
bump="minor"; release="true"
elif echo "$commits" | grep -qiE "^fix(\(.+\))?:"; then
bump="patch"; release="true"
fi
echo "bump=$bump" >> "$GITHUB_OUTPUT"
echo "release=$release" >> "$GITHUB_OUTPUT"
if [ "$release" = "true" ]; then
echo "Release decision: RELEASE (bump=$bump)"
else
echo "Release decision: SKIP - no feat:/fix:/feat!: commit since ${last_tag:-<none>}; docs/chore/ci do not cut a release"
fi
- name: Compute new version
id: new
run: |
current="${{ steps.current.outputs.version }}"
bump="${{ steps.bump.outputs.bump }}"
IFS='.' read -r major minor patch <<< "$current"
# Initial release: VERSION already at 0.1.0 with no prior tag.
# If there is no last tag and the bump type would otherwise advance
# past 0.1.0, hold the version at 0.1.0 so the first release is
# cut at the value that's already in VERSION.
last_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$last_tag" ]; then
new_version="$current"
else
case "$bump" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
esac
new_version="$major.$minor.$patch"
fi
echo "version=$new_version" >> "$GITHUB_OUTPUT"
echo "New version: $new_version"
- name: Check if tag already exists
id: check
run: |
new_version="${{ steps.new.outputs.version }}"
if git rev-parse "v$new_version" >/dev/null 2>&1; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Tag v$new_version already exists, skipping"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Update VERSION file
if: steps.check.outputs.skip == 'false' && steps.bump.outputs.release == 'true'
env:
NEW_VERSION: ${{ steps.new.outputs.version }}
run: |
echo "$NEW_VERSION" > VERSION
- name: Sync release docs
if: steps.check.outputs.skip == 'false' && steps.bump.outputs.release == 'true'
uses: TMHSDigital/Developer-Tools-Directory/.github/actions/release-doc-sync@v1
with:
plugin-version: ${{ steps.new.outputs.version }}
previous-version: ${{ steps.current.outputs.version }}
meta-repo-ref: v1.15.1
- name: Sync plugin manifest version
if: steps.check.outputs.skip == 'false' && steps.bump.outputs.release == 'true'
env:
NEW_VERSION: ${{ steps.new.outputs.version }}
run: |
python3 - << 'PYEOF'
import os
import re
path = '.cursor-plugin/plugin.json'
text = open(path).read()
text = re.sub(
r'^( "version": ")[^"]+(",)$',
rf'\g<1>{os.environ["NEW_VERSION"]}\g<2>',
text,
count=1,
flags=re.M,
)
open(path, 'w').write(text)
PYEOF
- name: Commit version bump
if: steps.check.outputs.skip == 'false' && steps.bump.outputs.release == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "chore: bump version to ${{ steps.new.outputs.version }} [skip ci]"
git push origin main
fi
- name: Create and push tag
if: steps.check.outputs.skip == 'false' && steps.bump.outputs.release == 'true'
run: |
new_version="${{ steps.new.outputs.version }}"
IFS='.' read -r major minor _patch <<< "$new_version"
git tag "v$new_version"
git tag -f "v$major"
git tag -f "v$major.$minor"
git push origin "v$new_version"
git push origin "v$major" --force
git push origin "v$major.$minor" --force
- name: Create GitHub Release
if: steps.check.outputs.skip == 'false' && steps.bump.outputs.release == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.new.outputs.version }}" \
--title "v${{ steps.new.outputs.version }}" \
--generate-notes