Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
57 changes: 57 additions & 0 deletions .github/workflows/check-release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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@08eba0b27e820071cde6df949e0beb9ba4906955 # 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
87 changes: 87 additions & 0 deletions .github/workflows/create-release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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
env:
BUMP_TYPE: ${{ inputs.bump_type }}
TARGET_BRANCH: ${{ inputs.target_branch }}

steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
with:
ref: ${{ inputs.target_branch }}
fetch-depth: 0 # to generate complete release log
- uses: cashapp/activate-hermit@e49f5cb4dd64ff0b0b659d1d8df499595451155a # v1

- name: Validate input and set old version
run: |
if [[ "$BUMP_TYPE" != "minor" && "$BUMP_TYPE" != "patch" ]]; then
echo "Error: bump_type must be 'minor' or 'patch'"
exit 1
fi

Comment thread Fixed
- name: create release branch
run: |
PRIOR_VERSION=$(just get-tag-version)
if [[ "$BUMP_TYPE" == "minor" ]]; then
VERSION=$(just get-next-minor-version)
else
VERSION=$(just get-next-patch-version)
fi

echo "prior_version=$PRIOR_VERSION" >> $GITHUB_ENV
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"

Comment thread Fixed
- name: push release branch
run: |
git push origin "${{ env.branch_name }}"

- name: Create Pull Request
run: |
cat > pr_body.txt <<EOF
Release version ${{ env.version }}

Merging this PR will trigger the release of version ${{ env.version }}. Closing this PR will do nothing.

Release log:
EOF

git fetch origin --tags

git log --pretty=format:"- %s (%h)" v${{ env.prior_version }}..HEAD >> pr_body.txt

gh pr create \
-B "$TARGET_BRANCH" \
-H "${{ env.branch_name }}" \
--title "chore(release): release version ${{ env.version }} ($BUMP_TYPE)" \
--body-file pr_body.txt
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE: ${{ github.event.issue.html_url }}
Comment thread
jamadeo marked this conversation as resolved.
Outdated
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
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
if: >
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')

steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
with:
fetch-depth: 0

- name: Restore release branch and create tag
run: |
git checkout -b "$BRANCH_NAME" "$PR_HEAD_SHA"
git push origin "$BRANCH_NAME"

echo "✅ Restored branch: $BRANCH_NAME at $PR_HEAD_SHA"

RELEASE_TAG=v${BRANCH_NAME#release/}

echo "creating release tag: $RELEASE_TAG"
git tag "$RELEASE_TAG"
git push origin tag "$RELEASE_TAG"

Comment thread Fixed
Comment thread Fixed
- name: Trigger patch release
run: |
gh workflow run patch-release.yaml \
--field target_branch=$BRANCH_NAME

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)
Comment thread
jamadeo marked this conversation as resolved.
Comment thread
jamadeo marked this conversation as resolved.

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