mirror of
https://github.com/AvdLee/Xcode-Build-Optimization-Agent-Skill.git
synced 2026-09-14 13:59:59 +08:00
430a3c5a44
The "Commit and push version bump" step hard-failed (exit 1) when plugin.json and marketplace.json already contained the target version, preventing the tag and GitHub release from being created. Treat an already-correct version as a no-op and proceed to tagging.
90 lines
2.9 KiB
YAML
90 lines
2.9 KiB
YAML
name: Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Version to release (for example 1.0.1)"
|
|
required: true
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
VERSION: ${{ inputs.version }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: main
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Validate version input
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
echo "Invalid semver version: $VERSION"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Fail if tag already exists
|
|
run: |
|
|
set -euo pipefail
|
|
if git rev-parse -q --verify "refs/tags/$VERSION" >/dev/null; then
|
|
echo "Tag $VERSION already exists."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Fail if version is not newer
|
|
run: |
|
|
set -euo pipefail
|
|
latest_tag="$(git tag -l '[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n 1)"
|
|
if [[ -z "$latest_tag" ]]; then
|
|
echo "No existing semver tags found. Proceeding."
|
|
exit 0
|
|
fi
|
|
greatest="$(printf '%s\n%s\n' "$latest_tag" "$VERSION" | sort -V | tail -n 1)"
|
|
if [[ "$greatest" != "$VERSION" || "$latest_tag" == "$VERSION" ]]; then
|
|
echo "Version $VERSION must be greater than $latest_tag."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Bump plugin manifest version
|
|
run: |
|
|
set -euo pipefail
|
|
jq --arg version "$VERSION" '.version = $version' .claude-plugin/plugin.json > .claude-plugin/plugin.json.tmp
|
|
mv .claude-plugin/plugin.json.tmp .claude-plugin/plugin.json
|
|
|
|
- name: Bump marketplace version fields
|
|
run: |
|
|
set -euo pipefail
|
|
jq --arg version "$VERSION" '.version = $version | .plugins |= map(.version = $version)' .claude-plugin/marketplace.json > .claude-plugin/marketplace.json.tmp
|
|
mv .claude-plugin/marketplace.json.tmp .claude-plugin/marketplace.json
|
|
|
|
- name: Commit and push version bump
|
|
run: |
|
|
set -euo pipefail
|
|
if git diff --quiet .claude-plugin/plugin.json .claude-plugin/marketplace.json; then
|
|
echo "Version already set to $VERSION. Skipping commit."
|
|
exit 0
|
|
fi
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add .claude-plugin/plugin.json .claude-plugin/marketplace.json
|
|
git commit -m "Bump version to $VERSION"
|
|
git push
|
|
|
|
- name: Create tag and GitHub release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ inputs.version }}
|
|
generate_release_notes: true
|