From 1429ddd2417b2a1f8bcabf2a92df7bb150fb3f06 Mon Sep 17 00:00:00 2001 From: davida-ps Date: Mon, 9 Feb 2026 07:28:29 +0100 Subject: [PATCH] fix: improve commit handling and rollback logic in release script (#12) --- .github/workflows/skill-release.yml | 6 +++-- scripts/release-skill.sh | 41 ++++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.github/workflows/skill-release.yml b/.github/workflows/skill-release.yml index 147bb40..631c8f5 100644 --- a/.github/workflows/skill-release.yml +++ b/.github/workflows/skill-release.yml @@ -350,7 +350,8 @@ jobs: continue fi - # --- Copy root-level docs alongside the zip --- + # --- Copy skill.json and root-level docs alongside the zip --- + cp "${json_path}" "${out_assets}/skill.json" if [ -f "${skill_dir}/SKILL.md" ]; then cp "${skill_dir}/SKILL.md" "${out_assets}/SKILL.md" fi @@ -579,7 +580,8 @@ jobs: files: $files }' > "release-assets/checksums.json" - # --- Copy root-level docs alongside the zip --- + # --- Copy skill.json and root-level docs alongside the zip --- + cp "$SKILL_PATH/skill.json" release-assets/skill.json if [ -f "$SKILL_PATH/SKILL.md" ]; then cp "$SKILL_PATH/SKILL.md" release-assets/ fi diff --git a/scripts/release-skill.sh b/scripts/release-skill.sh index 7b251fd..c550773 100755 --- a/scripts/release-skill.sh +++ b/scripts/release-skill.sh @@ -205,28 +205,33 @@ for file in "${FILES_TO_STAGE[@]}"; do done # Verify staged changes before committing +MADE_COMMIT=false if git diff --cached --quiet; then - echo "Warning: No changes to commit" - exit 0 -fi - -# Commit the version bump -echo "Committing changes..." -if ! git commit -m "chore($SKILL_NAME): bump version to $VERSION"; then - echo "Error: Failed to commit changes" - exit 1 + echo "Note: Version already at $VERSION — no changes to commit" + COMMIT_SHA=$(git rev-parse HEAD) +else + # Commit the version bump + echo "Committing changes..." + if ! git commit -m "chore($SKILL_NAME): bump version to $VERSION"; then + echo "Error: Failed to commit changes" + exit 1 + fi + COMMIT_SHA=$(git rev-parse HEAD) + MADE_COMMIT=true fi # Save commit SHA for recovery -COMMIT_SHA=$(git rev-parse HEAD) echo "Committed: $COMMIT_SHA" # Create tag only on release branches (or if forced) if [[ "$IS_RELEASE_BRANCH" == "true" || "$FORCE_TAG" == "true" ]]; then # Check if tag already exists (only matters when we're creating one) if git rev-parse "$TAG" >/dev/null 2>&1; then - echo "Error: Tag $TAG already exists; rolling back last commit" - git reset --hard HEAD~1 + echo "Error: Tag $TAG already exists" + if [[ "$MADE_COMMIT" == "true" ]]; then + echo "Rolling back version-bump commit..." + git reset --hard HEAD~1 + fi exit 1 fi @@ -253,12 +258,18 @@ if [[ "$IS_RELEASE_BRANCH" == "true" || "$FORCE_TAG" == "true" ]]; then fi echo "" - echo "Done! To release, push the commit and tag:" - echo " git push origin $CURRENT_BRANCH" + echo "Done! To release, push the tag:" + if [[ "$MADE_COMMIT" == "true" ]]; then + echo " git push origin $CURRENT_BRANCH" + fi echo " git push origin $TAG" echo "" echo "Or to undo:" - echo " git reset --hard HEAD~1 && git tag -d $TAG" + if [[ "$MADE_COMMIT" == "true" ]]; then + echo " git reset --hard HEAD~1 && git tag -d $TAG" + else + echo " git tag -d $TAG" + fi else # Feature branch: skip tagging, instruct user on next steps echo ""