Skip to content

Commit

Permalink
ci: adding feature branch deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-whodo committed Feb 3, 2025
1 parent 26c652a commit e1cd8d4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
53 changes: 46 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
push:
branches:
- main
- "feature/*"
- "fix/*"

permissions:
contents: write
Expand Down Expand Up @@ -99,24 +101,48 @@ jobs:
exit 0
fi
# Determine branch type and target
if [[ "${{ github.ref }}" == refs/heads/feature/* ]]; then
BASE_BRANCH="feature/$(echo ${{ github.ref_name }} | cut -d/ -f2-)"
PRERELEASE_TYPE="alpha"
elif [[ "${{ github.ref }}" == refs/heads/fix/* ]]; then
BASE_BRANCH="fix/$(echo ${{ github.ref_name }} | cut -d/ -f2-)"
PRERELEASE_TYPE="beta"
else
BASE_BRANCH="main"
PRERELEASE_TYPE=""
fi
# Create release branch
BRANCH="release-$NEW_VERSION"
git checkout -b $BRANCH
# Update version and create changelog
semantic-release version --no-commit
if [ -n "$PRERELEASE_TYPE" ]; then
semantic-release version --prerelease $PRERELEASE_TYPE --no-commit
else
semantic-release version --no-commit
fi
# Commit changes
git add .
git commit -m "chore(release): $NEW_VERSION"
git push -f origin $BRANCH
# Create PR
gh pr create \
--title "chore(release): $NEW_VERSION" \
--body "Automated release PR to update version to $NEW_VERSION" \
--base main \
--head $BRANCH
if [ -n "$PRERELEASE_TYPE" ]; then
gh pr create \
--title "chore(prerelease): $NEW_VERSION" \
--body "Automated prerelease PR to update version to $NEW_VERSION" \
--base $BASE_BRANCH \
--head $BRANCH
else
gh pr create \
--title "chore(release): $NEW_VERSION" \
--body "Automated release PR to update version to $NEW_VERSION" \
--base main \
--head $BRANCH
fi
release:
# Only run when a release PR is merged
Expand Down Expand Up @@ -170,11 +196,24 @@ jobs:
git tag -f "v${{ steps.get_version.outputs.VERSION }}" -m "Release v${{ steps.get_version.outputs.VERSION }}"
git push --force origin "v${{ steps.get_version.outputs.VERSION }}"
# Determine if this is a prerelease
if [[ "${{ github.ref }}" == refs/heads/feature/* ]]; then
IS_PRERELEASE="--prerelease"
TARGET_BRANCH="${{ github.ref_name }}"
elif [[ "${{ github.ref }}" == refs/heads/fix/* ]]; then
IS_PRERELEASE="--prerelease"
TARGET_BRANCH="${{ github.ref_name }}"
else
IS_PRERELEASE=""
TARGET_BRANCH="main"
fi
# Create GitHub release
gh release create "v${{ steps.get_version.outputs.VERSION }}" \
--title "Release v${{ steps.get_version.outputs.VERSION }}" \
--notes "See CHANGELOG.md for details" \
--target main
--target $TARGET_BRANCH \
$IS_PRERELEASE
publish:
needs: release
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,15 @@ prerelease = false
match = "release-*"
prerelease = false

[tool.semantic_release.branches.feature]
match = "feature/*"
prerelease = true
prerelease_token = "alpha"

[tool.semantic_release.branches.fix]
match = "fix/*"
prerelease = true
prerelease_token = "beta"

[tool.semantic_release.repository]
repository = "pr-diff-bot"

0 comments on commit e1cd8d4

Please sign in to comment.