Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/check-release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Check Release PR

on:
pull_request:
types: [opened, synchronize]
branches:
- main

jobs:
check-commits:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'release/')
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Check all PR commits exist in main
run: |
git fetch origin main

CHERRY_OUTPUT=$(git cherry origin/main HEAD)

if [ -z "$CHERRY_OUTPUT" ]; then
echo "✅ All commits already exist in main"
exit 0
fi

echo "Cherry check results:"
echo "$CHERRY_OUTPUT"

MISSING_COMMITS=$(echo "$CHERRY_OUTPUT" | grep '^+' | cut -d' ' -f2)

if [ -z "$MISSING_COMMITS" ]; then
echo "✅ All commits exist in main"
exit 0
fi

COMMIT_COUNT=$(echo "$MISSING_COMMITS" | wc -l)
FIRST_COMMIT=$(git rev-list --reverse HEAD ^origin/main | head -1)

if [ "$COMMIT_COUNT" -eq 1 ] && echo "$MISSING_COMMITS" | grep -q "$FIRST_COMMIT"; then
echo "✅ Only version bump commit is unique"
git log --oneline -1 "$FIRST_COMMIT"
else
echo "❌ Found commits that should exist in main:"
for commit in $MISSING_COMMITS; do
if [ "$commit" != "$FIRST_COMMIT" ]; then
git log --oneline -1 "$commit"
fi
done
echo "Make sure commits have equivalents in main. If you've since updated main, re-run this job"
exit 1
fi
67 changes: 67 additions & 0 deletions .github/workflows/create-release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release Workflow

on:
workflow_call:
inputs:
bump_type:
description: 'Type of version bump (minor or patch)'
required: true
type: string
target_branch:
description: 'Target branch for the pull request'
required: false
type: string
default: 'main'

permissions:
contents: write
pull-requests: write

jobs:
create-release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: cashapp/activate-hermit@v1

- name: Validate bump type
run: |
if [[ "${{ inputs.bump_type }}" != "minor" && "${{ inputs.bump_type }}" != "patch" ]]; then
echo "Error: bump_type must be 'minor' or 'patch'"
exit 1
fi
- name: create release branch
run: |
if [[ "${{ inputs.bump_type }}" == "minor" ]]; then
VERSION=$(just get-next-minor-version)
else
VERSION=$(just get-next-patch-version)
fi
echo "version=$VERSION" >> $GITHUB_ENV
echo "Version: $VERSION"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
just prepare-release $VERSION
BRANCH_NAME=$(git branch --show-current)
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
echo "Branch: $BRANCH_NAME"
- name: push release branch
run: |
git push origin "${{ env.branch_name }}"
- name: Create Pull Request
run: |
gh pr create \
-B "${{ inputs.target_branch }}" \
-H "${{ env.branch_name }}" \
--title 'chore(release): release version ${{ env.version }} (${{ inputs.bump_type }})' \
--body '_Created automatically by ${{ github.workflow_ref }}_'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE: ${{ github.event.issue.html_url }}
51 changes: 51 additions & 0 deletions .github/workflows/create-release-tag-on-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Create release tag and patch release PR on merge

on:
pull_request:
types: [closed]
branches:
- main
- release/*

permissions:
actions: write
contents: write
pull-requests: write

jobs:
trigger-patch-release:
runs-on: ubuntu-latest
if: >
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Restore release branch and create tag
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
PR_HEAD_SHA="${{ github.event.pull_request.head.sha }}"
git checkout -b "$BRANCH_NAME" "$PR_HEAD_SHA"
git push origin "$BRANCH_NAME"
echo "✅ Restored branch: $BRANCH_NAME at $PR_HEAD_SHA"
RELEASE_TAG=${BRANCH_NAME#release/}
echo "creating release tag: $RELEASE_TAG"
git tag "$RELEASE_TAG"
git push origin tag "$RELEASE_TAG"
- name: Trigger patch release
run: |
gh workflow run patch-release.yaml \
--field target_branch=${{ github.event.pull_request.head.ref }}
echo "✅ Triggered patch release workflow"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/minor-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Create Minor Release PR

permissions:
contents: write
pull-requests: write

on:
schedule:
- cron: '0 0 * * 2'
workflow_dispatch:

jobs:
release:
uses: ./.github/workflows/create-release-pr.yaml
with:
bump_type: "minor"
20 changes: 20 additions & 0 deletions .github/workflows/patch-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Create Patch Release PR

permissions:
contents: write
pull-requests: write

on:
workflow_dispatch:
inputs:
target_branch:
description: 'Target branch for hotfix'
required: true
type: string

jobs:
hotfix:
uses: ./.github/workflows/create-release-pr.yaml
with:
bump_type: "patch"
target_branch: ${{ inputs.target_branch }}
6 changes: 6 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ validate version:
exit 1
fi

get-next-minor-version:
@python -c "import sys; v=sys.argv[1].split('.'); print(f'{v[0]}.{int(v[1])+1}.0')" $(just get-tag-version)

get-next-patch-version:
@python -c "import sys; v=sys.argv[1].split('.'); print(f'{v[0]}.{v[1]}.{int(v[2])+1}')" $(just get-tag-version)

# set cargo and app versions, must be semver
prepare-release version:
@just validate {{ version }} || exit 1
Expand Down
Loading