Skip to content

Commit 3acfb97

Browse files
authored
feat: simplify release workflow by removing PR creation step (#9)
- Rename create-release-pr.yml to create-release.yml - Remove all PR creation and github-script dependencies - Implement direct tag creation and push for immediate releases - Simplify release.yml to only handle tag pushes (remove PR triggers) - Update README to reflect streamlined "Create Release" workflow This eliminates GitHub Actions permission issues with PR creation and provides a faster, more direct release process. The workflow now creates releases immediately without requiring PR review. Fixes permission error: "GitHub Actions is not permitted to create or approve pull requests"
1 parent 32b8ebd commit 3acfb97

4 files changed

Lines changed: 172 additions & 144 deletions

File tree

Lines changed: 21 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create Release PR
1+
name: Create Release
22

33
on:
44
workflow_dispatch:
@@ -21,18 +21,16 @@ on:
2121

2222
permissions:
2323
contents: write
24-
pull-requests: write
2524

2625
jobs:
27-
create-release-pr:
26+
create-release:
2827
runs-on: ubuntu-latest
2928

3029
steps:
3130
- name: Checkout code
3231
uses: actions/checkout@v4
3332
with:
3433
fetch-depth: 0
35-
token: ${{ secrets.GITHUB_TOKEN }}
3634

3735
- name: Set up Ruby
3836
uses: ruby/setup-ruby@v1
@@ -97,140 +95,51 @@ jobs:
9795
echo "=== CHANGELOG PREVIEW ==="
9896
bundle exec rake release:changelog[${{ steps.next_version.outputs.NEXT_VERSION }}] || true
9997
100-
- name: Create release branch
101-
if: ${{ github.event.inputs.dry_run != 'true' }}
102-
run: |
103-
BRANCH_NAME="release/v${{ steps.next_version.outputs.NEXT_VERSION }}"
104-
git checkout -b "$BRANCH_NAME"
105-
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
106-
10798
- name: Run tests before release
10899
if: ${{ github.event.inputs.dry_run != 'true' }}
109100
run: bundle exec rake ci
110101

111-
- name: Create release
102+
- name: Create release and tag
112103
if: ${{ github.event.inputs.dry_run != 'true' }}
113104
run: |
105+
echo "🚀 Creating ${{ steps.release_type.outputs.RELEASE_TYPE }} release..."
114106
bundle exec rake release:create[${{ steps.release_type.outputs.RELEASE_TYPE }}]
115107
116-
- name: Push release branch
108+
- name: Push changes and tag
117109
if: ${{ github.event.inputs.dry_run != 'true' }}
118110
run: |
119-
git push origin "$BRANCH_NAME"
120-
121-
- name: Create Pull Request
122-
if: ${{ github.event.inputs.dry_run != 'true' }}
123-
id: create_pr
124-
uses: actions/github-script@v7
125-
with:
126-
script: |
127-
const { data: pr } = await github.rest.pulls.create({
128-
owner: context.repo.owner,
129-
repo: context.repo.repo,
130-
title: `Release v${{ steps.next_version.outputs.NEXT_VERSION }}`,
131-
head: process.env.BRANCH_NAME,
132-
base: 'main',
133-
body: `## Release v${{ steps.next_version.outputs.NEXT_VERSION }}
134-
135-
This is an automated release PR created by GitHub Actions.
136-
137-
### Release Type: ${{ steps.release_type.outputs.RELEASE_TYPE }}
138-
139-
### Changes
140-
141-
This PR includes:
142-
- 📝 Updated CHANGELOG.md with new version
143-
- 🏷️ Version tag v${{ steps.next_version.outputs.NEXT_VERSION }}
144-
- ✅ All tests passing
145-
146-
### What happens when merged?
147-
148-
When this PR is merged to main:
149-
1. 🚀 GitHub Actions will automatically create a GitHub release
150-
2. 📦 Release artifacts will be built and attached
151-
3. 🌐 Release will be published
152-
153-
### Review Checklist
154-
155-
- [ ] Review the changelog entries
156-
- [ ] Verify the version bump is appropriate
157-
- [ ] Confirm all tests are passing
158-
- [ ] Check that no sensitive information is included
159-
160-
---
161-
162-
*This PR was created automatically by the [Create Release PR workflow](.github/workflows/create-release-pr.yml)*`,
163-
draft: false
164-
});
165-
166-
// Add labels
167-
await github.rest.issues.addLabels({
168-
owner: context.repo.owner,
169-
repo: context.repo.repo,
170-
issue_number: pr.number,
171-
labels: ['release', '${{ steps.release_type.outputs.RELEASE_TYPE }}']
172-
});
173-
174-
console.log(`Created PR #${pr.number}: ${pr.html_url}`);
175-
176-
// Set outputs
177-
core.setOutput('pr_number', pr.number);
178-
core.setOutput('pr_url', pr.html_url);
179-
180-
return {
181-
pr_number: pr.number,
182-
pr_url: pr.html_url
183-
};
184-
185-
- name: Comment on PR with details
186-
if: ${{ github.event.inputs.dry_run != 'true' }}
187-
uses: actions/github-script@v7
188-
with:
189-
script: |
190-
const prNumber = ${{ steps.create_pr.outputs.pr_number }};
191-
192-
await github.rest.issues.createComment({
193-
owner: context.repo.owner,
194-
repo: context.repo.repo,
195-
issue_number: prNumber,
196-
body: `### 🚀 Release Summary
197-
198-
| Item | Value |
199-
|------|-------|
200-
| **Current Version** | ${{ steps.current_version.outputs.CURRENT_VERSION }} |
201-
| **New Version** | ${{ steps.next_version.outputs.NEXT_VERSION }} |
202-
| **Release Type** | ${{ steps.release_type.outputs.RELEASE_TYPE }} |
203-
| **Branch** | \`${process.env.BRANCH_NAME}\` |
111+
VERSION_TAG="v${{ steps.next_version.outputs.NEXT_VERSION }}"
112+
echo "📤 Pushing changes and tag $VERSION_TAG to GitHub..."
204113
205-
### 📋 Next Steps
114+
# Push any changelog changes
115+
git push origin main
206116
207-
1. **Review** the changes in this PR
208-
2. **Merge** this PR to trigger the release
209-
3. **Monitor** the release workflow in the Actions tab
117+
# Push the version tag (this will trigger the release.yml workflow)
118+
git push origin "$VERSION_TAG"
210119
211-
The release will be automatically created when this PR is merged! 🎉`
212-
});
120+
echo "✅ Successfully pushed tag $VERSION_TAG"
121+
echo "🎯 The release.yml workflow will now create the GitHub release automatically"
213122
214123
- name: Output summary
215124
if: ${{ github.event.inputs.dry_run != 'true' }}
216125
run: |
217-
echo "## Release PR Created! 🎉" >> $GITHUB_STEP_SUMMARY
126+
echo "## Release Created! 🎉" >> $GITHUB_STEP_SUMMARY
218127
echo "" >> $GITHUB_STEP_SUMMARY
219-
echo "- **Version**: ${{ steps.next_version.outputs.NEXT_VERSION }}" >> $GITHUB_STEP_SUMMARY
128+
echo "- **Version**: v${{ steps.next_version.outputs.NEXT_VERSION }}" >> $GITHUB_STEP_SUMMARY
220129
echo "- **Type**: ${{ steps.release_type.outputs.RELEASE_TYPE }}" >> $GITHUB_STEP_SUMMARY
221-
echo "- **Branch**: $BRANCH_NAME" >> $GITHUB_STEP_SUMMARY
222-
echo "- **PR**: ${{ steps.create_pr.outputs.pr_url }}" >> $GITHUB_STEP_SUMMARY
130+
echo "- **Tag**: v${{ steps.next_version.outputs.NEXT_VERSION }}" >> $GITHUB_STEP_SUMMARY
223131
echo "" >> $GITHUB_STEP_SUMMARY
224-
echo "### What's Next?" >> $GITHUB_STEP_SUMMARY
225-
echo "1. Review and merge the PR" >> $GITHUB_STEP_SUMMARY
226-
echo "2. The release will be automatically created" >> $GITHUB_STEP_SUMMARY
132+
echo "### What happens next?" >> $GITHUB_STEP_SUMMARY
133+
echo "1. 🚀 The release.yml workflow is now running" >> $GITHUB_STEP_SUMMARY
134+
echo "2. 📦 GitHub release will be created automatically" >> $GITHUB_STEP_SUMMARY
135+
echo "3. 🌐 Monitor progress at: https://github.com/${{ github.repository }}/actions" >> $GITHUB_STEP_SUMMARY
227136
228137
- name: Output dry run summary
229138
if: ${{ github.event.inputs.dry_run == 'true' }}
230139
run: |
231140
echo "## Dry Run Complete! 👀" >> $GITHUB_STEP_SUMMARY
232141
echo "" >> $GITHUB_STEP_SUMMARY
233-
echo "- **Would create version**: ${{ steps.next_version.outputs.NEXT_VERSION }}" >> $GITHUB_STEP_SUMMARY
142+
echo "- **Would create version**: v${{ steps.next_version.outputs.NEXT_VERSION }}" >> $GITHUB_STEP_SUMMARY
234143
echo "- **Release type**: ${{ steps.release_type.outputs.RELEASE_TYPE }}" >> $GITHUB_STEP_SUMMARY
235144
echo "" >> $GITHUB_STEP_SUMMARY
236145
echo "To create the actual release, run this workflow again without dry run mode." >> $GITHUB_STEP_SUMMARY
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: 'Type of release'
8+
required: true
9+
default: 'auto'
10+
type: choice
11+
options:
12+
- auto
13+
- major
14+
- minor
15+
- patch
16+
dry_run:
17+
description: 'Dry run (preview only)'
18+
required: false
19+
default: false
20+
type: boolean
21+
22+
permissions:
23+
contents: write
24+
25+
jobs:
26+
create-release:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Set up Ruby
36+
uses: ruby/setup-ruby@v1
37+
with:
38+
ruby-version: '3.2'
39+
bundler-cache: true
40+
41+
- name: Configure Git
42+
run: |
43+
git config --local user.email "action@github.com"
44+
git config --local user.name "GitHub Action"
45+
46+
- name: Determine release type
47+
id: release_type
48+
run: |
49+
if [ "${{ github.event.inputs.release_type }}" = "auto" ]; then
50+
# Run preview to get suggested release type
51+
PREVIEW_OUTPUT=$(bundle exec rake release:preview)
52+
echo "$PREVIEW_OUTPUT"
53+
54+
# Extract suggested release type from output
55+
SUGGESTED_TYPE=$(echo "$PREVIEW_OUTPUT" | grep "Suggested release type:" | awk '{print $NF}')
56+
57+
if [ -z "$SUGGESTED_TYPE" ]; then
58+
echo "Could not determine release type automatically, defaulting to patch"
59+
RELEASE_TYPE="patch"
60+
else
61+
RELEASE_TYPE="$SUGGESTED_TYPE"
62+
fi
63+
else
64+
RELEASE_TYPE="${{ github.event.inputs.release_type }}"
65+
fi
66+
67+
echo "RELEASE_TYPE=$RELEASE_TYPE" >> $GITHUB_OUTPUT
68+
echo "Selected release type: $RELEASE_TYPE"
69+
70+
- name: Get current version
71+
id: current_version
72+
run: |
73+
CURRENT=$(ruby scripts/version.rb current)
74+
echo "CURRENT_VERSION=$CURRENT" >> $GITHUB_OUTPUT
75+
76+
- name: Calculate next version
77+
id: next_version
78+
run: |
79+
RELEASE_TYPE=${{ steps.release_type.outputs.RELEASE_TYPE }}
80+
NEXT_VERSION=$(ruby scripts/version.rb next "$RELEASE_TYPE")
81+
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT
82+
echo "Next version will be: $NEXT_VERSION"
83+
84+
- name: Preview release (dry run)
85+
if: ${{ github.event.inputs.dry_run == 'true' }}
86+
run: |
87+
echo "=== DRY RUN MODE ==="
88+
echo "Current version: ${{ steps.current_version.outputs.CURRENT_VERSION }}"
89+
echo "Release type: ${{ steps.release_type.outputs.RELEASE_TYPE }}"
90+
echo "Next version: ${{ steps.next_version.outputs.NEXT_VERSION }}"
91+
echo
92+
echo "=== COMMIT PREVIEW ==="
93+
bundle exec rake release:preview
94+
echo
95+
echo "=== CHANGELOG PREVIEW ==="
96+
bundle exec rake release:changelog[${{ steps.next_version.outputs.NEXT_VERSION }}] || true
97+
98+
- name: Run tests before release
99+
if: ${{ github.event.inputs.dry_run != 'true' }}
100+
run: bundle exec rake ci
101+
102+
- name: Create release and tag
103+
if: ${{ github.event.inputs.dry_run != 'true' }}
104+
run: |
105+
echo "🚀 Creating ${{ steps.release_type.outputs.RELEASE_TYPE }} release..."
106+
bundle exec rake release:create[${{ steps.release_type.outputs.RELEASE_TYPE }}]
107+
108+
- name: Push changes and tag
109+
if: ${{ github.event.inputs.dry_run != 'true' }}
110+
run: |
111+
VERSION_TAG="v${{ steps.next_version.outputs.NEXT_VERSION }}"
112+
echo "📤 Pushing changes and tag $VERSION_TAG to GitHub..."
113+
114+
# Push any changelog changes
115+
git push origin main
116+
117+
# Push the version tag (this will trigger the release.yml workflow)
118+
git push origin "$VERSION_TAG"
119+
120+
echo "✅ Successfully pushed tag $VERSION_TAG"
121+
echo "🎯 The release.yml workflow will now create the GitHub release automatically"
122+
123+
- name: Output summary
124+
if: ${{ github.event.inputs.dry_run != 'true' }}
125+
run: |
126+
echo "## Release Created! 🎉" >> $GITHUB_STEP_SUMMARY
127+
echo "" >> $GITHUB_STEP_SUMMARY
128+
echo "- **Version**: v${{ steps.next_version.outputs.NEXT_VERSION }}" >> $GITHUB_STEP_SUMMARY
129+
echo "- **Type**: ${{ steps.release_type.outputs.RELEASE_TYPE }}" >> $GITHUB_STEP_SUMMARY
130+
echo "- **Tag**: v${{ steps.next_version.outputs.NEXT_VERSION }}" >> $GITHUB_STEP_SUMMARY
131+
echo "" >> $GITHUB_STEP_SUMMARY
132+
echo "### What happens next?" >> $GITHUB_STEP_SUMMARY
133+
echo "1. 🚀 The release.yml workflow is now running" >> $GITHUB_STEP_SUMMARY
134+
echo "2. 📦 GitHub release will be created automatically" >> $GITHUB_STEP_SUMMARY
135+
echo "3. 🌐 Monitor progress at: https://github.com/${{ github.repository }}/actions" >> $GITHUB_STEP_SUMMARY
136+
137+
- name: Output dry run summary
138+
if: ${{ github.event.inputs.dry_run == 'true' }}
139+
run: |
140+
echo "## Dry Run Complete! 👀" >> $GITHUB_STEP_SUMMARY
141+
echo "" >> $GITHUB_STEP_SUMMARY
142+
echo "- **Would create version**: v${{ steps.next_version.outputs.NEXT_VERSION }}" >> $GITHUB_STEP_SUMMARY
143+
echo "- **Release type**: ${{ steps.release_type.outputs.RELEASE_TYPE }}" >> $GITHUB_STEP_SUMMARY
144+
echo "" >> $GITHUB_STEP_SUMMARY
145+
echo "To create the actual release, run this workflow again without dry run mode." >> $GITHUB_STEP_SUMMARY

.github/workflows/release.yml

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
push:
55
tags:
66
- 'v*'
7-
pull_request:
8-
types: [closed]
9-
branches: [main]
107

118
env:
129
VERSION_REGEX: 'v[0-9]+\.[0-9]+\.[0-9]+'
@@ -17,12 +14,6 @@ permissions:
1714
jobs:
1815
release:
1916
runs-on: ubuntu-latest
20-
# Only run if it's a merged PR with release label, or a version tag push
21-
if: |
22-
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
23-
(github.event_name == 'pull_request' &&
24-
github.event.pull_request.merged == true &&
25-
contains(github.event.pull_request.labels.*.name, 'release'))
2617

2718
steps:
2819
- name: Checkout code
@@ -42,31 +33,14 @@ jobs:
4233
bundle exec rake rubocop
4334
bundle exec rake test
4435
45-
- name: Extract version from tag or PR
36+
- name: Extract version from tag
4637
id: version
4738
run: |
48-
if [ "${{ github.event_name }}" = "push" ]; then
49-
# Extract from tag
50-
VERSION=${GITHUB_REF#refs/tags/v}
51-
else
52-
# Extract from PR title (should be "Release vX.Y.Z")
53-
VERSION=$(echo "${{ github.event.pull_request.title }}" | grep -oE "$VERSION_REGEX" | sed 's/^v//')
54-
if [ -z "$VERSION" ]; then
55-
echo "Could not extract version from PR title: ${{ github.event.pull_request.title }}"
56-
exit 1
57-
fi
58-
fi
39+
# Extract version from tag (refs/tags/v1.2.3 -> 1.2.3)
40+
VERSION=${GITHUB_REF#refs/tags/v}
5941
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
6042
echo "Extracted version: $VERSION"
6143
62-
- name: Create tag if from PR
63-
if: github.event_name == 'pull_request'
64-
run: |
65-
git config --local user.email "action@github.com"
66-
git config --local user.name "GitHub Action"
67-
git tag -a "v${{ steps.version.outputs.VERSION }}" -m "Release version ${{ steps.version.outputs.VERSION }}"
68-
git push origin "v${{ steps.version.outputs.VERSION }}"
69-
7044
- name: Extract changelog for version
7145
id: changelog
7246
run: |

0 commit comments

Comments
 (0)