Skip to content

Commit

Permalink
feat: helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
fibble committed Dec 27, 2024
1 parent 7d443f0 commit 9295456
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 9 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ jobs:
with:
target-branch: ${{ github.ref_name }}

- name: Create Release Asset
if: ${{ steps.release.outputs.release_created }}
run: |
RELEASE_TAG=${{ steps.release.outputs.tag_name }}
git archive --format=zip --output="${RELEASE_TAG}.zip" HEAD
gh release upload ${RELEASE_TAG} "${RELEASE_TAG}.zip" --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Cleanup
if: always()
run: |
Expand Down
23 changes: 23 additions & 0 deletions cleanup-prerelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [[ "$CURRENT_BRANCH" == "prerelease" ]]; then
echo "Cannot delete prerelease while on prerelease branch"
echo "Please checkout another branch first"
exit 1
fi

if ! git show-ref --verify --quiet refs/heads/prerelease; then
echo "No local prerelease branch found"
exit 0
fi

git branch -D prerelease

if git ls-remote --exit-code --heads origin prerelease >/dev/null 2>&1; then
git push origin --delete prerelease
echo "Remote prerelease branch deleted"
fi

echo "Prerelease branch cleanup complete"
43 changes: 43 additions & 0 deletions create-prerelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

VERSION=$1
SOURCE_BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [ -z "$VERSION" ]; then
echo "Error: Version argument required"
echo "Usage: ./create-prerelease.sh <version>"
echo "Example: ./create-prerelease.sh 1.1.0"
echo ""
echo "This will create a prerelease branch from your current branch: $SOURCE_BRANCH"
exit 1
fi

echo "Updating current branch ($SOURCE_BRANCH)..."
git pull origin $SOURCE_BRANCH || exit 1

echo "Creating prerelease branch from $SOURCE_BRANCH..."
git checkout -b prerelease || exit 1

echo "Copying changelog..."
if [ -f "CHANGELOG.md" ]; then
cp CHANGELOG.md CHANGELOG-PRERELEASE.md || exit 1
git add CHANGELOG-PRERELEASE.md
echo "Committing changelog..."
git commit -m "chore: initialize prerelease changelog from $SOURCE_BRANCH" || exit 1
else
echo "Warning: No CHANGELOG.md found in $SOURCE_BRANCH"
touch CHANGELOG-PRERELEASE.md
git add CHANGELOG-PRERELEASE.md
git commit -m "chore: initialize empty prerelease changelog" || exit 1
fi

echo "Creating release commit..."
git commit --allow-empty -m "chore: release v${VERSION}-rc1
Release-As: v${VERSION}-rc1" || exit 1

echo "Pushing to remote..."
git push origin prerelease || exit 1

echo "Prerelease branch setup complete!"
echo "A release-please PR for v${VERSION}-rc1 should be created shortly."
echo "Source branch was: $SOURCE_BRANCH"

0 comments on commit 9295456

Please sign in to comment.