-
Notifications
You must be signed in to change notification settings - Fork 20
127 lines (112 loc) · 4.73 KB
/
release-please.yml
File metadata and controls
127 lines (112 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Release Please
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
pr: ${{ steps.release.outputs.pr }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
release-type: go
config-file: .github/release-please-config.json
manifest-file: .github/.release-please-manifest.json
# Customize the changelog sections
changelog-types: >
[
{"type": "feat", "section": "Features", "hidden": false},
{"type": "fix", "section": "Bug Fixes", "hidden": false},
{"type": "perf", "section": "Performance Improvements", "hidden": false},
{"type": "revert", "section": "Reverts", "hidden": false},
{"type": "docs", "section": "Documentation", "hidden": false},
{"type": "chore", "section": "Miscellaneous", "hidden": true},
{"type": "style", "section": "Styles", "hidden": true},
{"type": "refactor", "section": "Code Refactoring", "hidden": true},
{"type": "test", "section": "Tests", "hidden": true},
{"type": "build", "section": "Build System", "hidden": true},
{"type": "ci", "section": "CI", "hidden": true}
]
# Smart auto-merge: only auto-merge release PRs with user-facing changes
auto-merge-release:
needs: release-please
if: ${{ needs.release-please.outputs.pr }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check if PR should auto-merge
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ fromJson(needs.release-please.outputs.pr).number }}
run: |
echo "Checking release PR #$PR_NUMBER for auto-merge eligibility..."
# Get PR body (contains changelog)
PR_BODY=$(gh pr view "$PR_NUMBER" --json body --jq '.body')
SHOULD_RELEASE=false
# Check changelog sections for user-facing changes
# These are generated from conventional commit prefixes:
# feat:, fix:, perf:, revert:, hotfix:, bugfix:, patch:, feature:
if echo "$PR_BODY" | grep -qE "^### (Features|Bug Fixes|Performance Improvements|Reverts)"; then
echo "Found user-facing changes in changelog (Features/Bug Fixes/Perf/Reverts)"
SHOULD_RELEASE=true
fi
# Also check for commit prefixes directly in the PR body
# This catches non-standard prefixes that might be included
if [ "$SHOULD_RELEASE" = "false" ]; then
if echo "$PR_BODY" | grep -qiE "\* (feat|fix|hotfix|bugfix|patch|feature|perf|revert)(\(.+\))?:"; then
echo "Found release-worthy commit prefix in changelog"
SHOULD_RELEASE=true
fi
fi
if [ "$SHOULD_RELEASE" = "true" ]; then
echo "should_merge=true" >> $GITHUB_OUTPUT
echo "✅ PR qualifies for auto-merge"
else
echo "should_merge=false" >> $GITHUB_OUTPUT
echo "⏸️ PR contains only internal changes (chore/docs/refactor/etc), skipping auto-merge"
echo " Release PR will stay open until a feat/fix/hotfix commit is added"
fi
- name: Enable auto-merge
if: steps.check.outputs.should_merge == 'true'
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}
PR_NUMBER: ${{ fromJson(needs.release-please.outputs.pr).number }}
run: |
echo "Enabling auto-merge for PR #$PR_NUMBER..."
gh pr merge "$PR_NUMBER" --auto --squash
echo "✅ Auto-merge enabled - PR will merge when CI passes"
build-release:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.21'
- name: Build release binaries
run: make release VERSION=${{ needs.release-please.outputs.tag_name }}
- name: Upload release assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ needs.release-please.outputs.tag_name }}
run: |
gh release upload $TAG_NAME \
dist/ez-darwin-amd64.tar.gz \
dist/ez-darwin-arm64.tar.gz \
dist/ez-linux-amd64.tar.gz \
dist/ez-linux-arm64.tar.gz \
dist/ez-windows-amd64.zip \
dist/checksums.txt