Skip to content

Commit dbdbf0e

Browse files
committed
ci(workflows): add release-chore
- replaces `release-branch` Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 569291f commit dbdbf0e

File tree

8 files changed

+100
-56
lines changed

8 files changed

+100
-56
lines changed

.commitlintrc.cts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const config: UserConfig = {
2121
scopes([
2222
'bump',
2323
'changelog',
24+
'chore',
2425
'config',
2526
'git',
2627
'grease',

.dictionary.txt

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ sortbrk
3838
sortcmt
3939
sortgrp
4040
stringafiable
41-
tohgarashi
4241
tryit
4342
tscu
4443
unstub

.github/workflows/auto-review.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
run: |
4747
GITHUB_TOKEN=
4848
49-
if [[ $GITHUB_ACTOR == flex-development[bot] ]]; then
49+
if [[ $GITHUB_ACTOR == 'flex-development[bot]' ]]; then
5050
GITHUB_TOKEN=${{ secrets.GH_REPO_TOKEN }}
5151
else
5252
GITHUB_TOKEN=${{ steps.bot-token.outputs.token }}

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
github.event.head_commit.author.name != 'dependabot[bot]'
5454
&& github.event.head_commit.author.username != 'flexdevelopment[bot]'
5555
&& !startsWith(github.event.head_commit.message, 'release:')
56+
&& !startsWith(github.event.head_commit.message, 'release(chore):')
5657
runs-on: ubuntu-latest
5758
outputs:
5859
cache-key: ${{ steps.cache-key.outputs.result }}

.github/workflows/release-branch.yml renamed to .github/workflows/release-chore.yml

+85-41
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,86 @@
1-
# Release Branch
1+
# Release Chore
22
#
3-
# Execute version bump, changelog, and pull request operations on release branch creation.
3+
# Execute branch, version bump, changelog, and pull request operations on release chore commit.
44
#
55
# References:
66
#
7-
# - https://cli.github.com/manual/gh_auth_status
87
# - https://cli.github.com/manual/gh_pr_create
98
# - https://docs.github.com/actions/learn-github-actions/contexts
109
# - https://docs.github.com/actions/learn-github-actions/expressions
11-
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#create
10+
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#push
1211
# - https://docs.github.com/actions/using-workflows/using-github-cli-in-workflows
1312
# - https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions
14-
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#create
13+
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#push
1514
# - https://github.com/actions/checkout
1615
# - https://github.com/actions/create-github-app-token
16+
# - https://github.com/flex-development/gh-commit
1717
# - https://github.com/hmarr/debug-action
1818
# - https://github.com/kaisugi/action-regex-match
19-
# - https://github.com/tohgarashi/verified-commit
2019
# - https://regex101.com/r/OwpOr2
20+
# - https://regex101.com/r/VIIVGd
2121

2222
---
23-
name: release-branch
24-
on: create
23+
name: release-chore
24+
on:
25+
push:
26+
branches:
27+
- main
2528
concurrency:
2629
cancel-in-progress: true
2730
group: ${{ github.workflow }}-${{ github.ref }}
2831
jobs:
2932
preflight:
30-
if: |
31-
github.ref_type == 'branch' &&
32-
startsWith(github.ref_name, 'release/') &&
33-
contains(vars.MAINTAINERS, github.actor)
33+
if: startsWith(github.event.head_commit.message, 'release(chore):')
3434
runs-on: ubuntu-latest
3535
outputs:
36+
branch: ${{ steps.branch.outputs.result }}
3637
message: ${{ steps.message.outputs.result }}
3738
tag: ${{ steps.tag.outputs.result }}
3839
version: ${{ steps.version.outputs.match }}
3940
steps:
4041
- id: debug
4142
name: Print environment variables and event payload
4243
uses: hmarr/[email protected]
44+
- id: fail-actor
45+
if: contains(vars.MAINTAINERS, github.actor) == false
46+
name: Fail on unauthorized actor
47+
run: |
48+
echo '**Unauthorized actor: ${{ github.actor }}**' >>$GITHUB_STEP_SUMMARY
49+
exit 1
4350
- id: checkout
4451
name: Checkout ${{ github.ref_name }}
4552
uses: actions/[email protected]
4653
with:
4754
persist-credentials: false
4855
ref: ${{ github.ref }}
56+
- id: diff-tree
57+
name: Get diff tree
58+
run: echo "result=$(git diff-tree --name-only -r ${{ github.sha }})" >>$GITHUB_OUTPUT
59+
- id: fail-diff-tree
60+
if: steps.diff-tree.outputs.result != ''
61+
name: Fail on invalid diff tree
62+
run: |
63+
ERR='**Invalid diff tree**
64+
```sh
65+
${{ steps.diff-tree.outputs.result }}
66+
```'
67+
echo "$ERR" >>$GITHUB_STEP_SUMMARY
68+
exit 1
4969
- id: version
5070
name: Get release version
5171
uses: kaisugi/[email protected]
5272
with:
53-
regex: ${{ vars.RELEASE_BRANCH_REGEX }}
54-
text: ${{ github.ref_name }}
55-
- id: version-fail
73+
regex: ${{ vars.RELEASE_CHORE_REGEX }}
74+
text: ${{ github.event.head_commit.message }}
75+
- id: fail-version
5676
if: steps.version.outputs.match == ''
5777
name: Fail on invalid release version
5878
run: |
59-
ERR='**Invalid release branch: ${{ github.ref_name }}**
60-
Branch must match [`${{ vars.RELEASE_BRANCH_REGEX }}`](https://regex101.com/r/OwpOr2)'
79+
ERR='**Invalid release chore commit**
80+
```sh
81+
${{ github.event.head_commit.message }}
82+
```
83+
Message must match [`${{ vars.RELEASE_CHORE_REGEX }}`](https://regex101.com/r/OwpOr2)'
6184
echo "$ERR" >>$GITHUB_STEP_SUMMARY
6285
exit 1
6386
- id: tag
@@ -66,10 +89,35 @@ jobs:
6689
echo "result=$(jq .tagprefix grease.config.json -r)${{ steps.version.outputs.match }}" >>$GITHUB_OUTPUT
6790
- id: message
6891
name: Get release message
92+
run: 'echo "result=release: ${{ steps.tag.outputs.result }}" >>$GITHUB_OUTPUT'
93+
- id: branch
94+
name: Get release branch name
95+
run: echo "result=release/${{ steps.version.outputs.match }}" >>$GITHUB_OUTPUT
96+
branch:
97+
needs: preflight
98+
runs-on: ubuntu-latest
99+
steps:
100+
- id: bot-token
101+
name: Get bot token
102+
uses: actions/[email protected]
103+
with:
104+
app-id: ${{ secrets.BOT_APP_ID }}
105+
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
106+
- id: checkout
107+
name: Checkout ${{ github.ref_name }}
108+
uses: actions/[email protected]
109+
with:
110+
ref: ${{ github.ref }}
111+
token: ${{ steps.bot-token.outputs.token }}
112+
- id: branch
113+
name: Create and push branch ${{ needs.preflight.outputs.branch }}
69114
run: |
70-
echo "result=release: ${{ steps.tag.outputs.result }}" >>$GITHUB_OUTPUT
115+
git branch ${{ needs.preflight.outputs.branch }}
116+
git push origin --no-verify ${{ needs.preflight.outputs.branch }}
71117
prepare:
72-
needs: preflight
118+
needs:
119+
- branch
120+
- preflight
73121
permissions:
74122
packages: read
75123
runs-on: ubuntu-latest
@@ -83,18 +131,18 @@ jobs:
83131
app-id: ${{ secrets.BOT_APP_ID }}
84132
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
85133
- id: checkout
86-
name: Checkout ${{ github.ref_name }}
134+
name: Checkout ${{ needs.preflight.outputs.branch }}
87135
uses: actions/[email protected]
88136
with:
89137
fetch-depth: 0
90138
persist-credentials: false
91-
ref: ${{ github.ref }}
139+
ref: ${{ needs.preflight.outputs.branch }}
92140
token: ${{ steps.bot-token.outputs.token }}
93141
- id: yarn
94142
name: Install dependencies
95143
env:
96144
HUSKY: 0
97-
run: yarn --immutable
145+
run: yarn
98146
- id: build
99147
name: Build project
100148
env:
@@ -111,20 +159,20 @@ jobs:
111159
echo "$(node ./dist/cli.mjs changelog)" >>$GITHUB_STEP_SUMMARY
112160
node ./dist/cli.mjs changelog -sw
113161
- id: commit
114-
name: Commit release preparation
115-
uses: tohgarashi/[email protected]
116-
env:
117-
GH_TOKEN: ${{ steps.bot-token.outputs.token }}
162+
name: Commit and push release preparation
163+
uses: flex-development/[email protected]
118164
with:
119-
commit-message: |
120-
${{ needs.preflight.outputs.message }}
121-
122-
Signed-off-by: ${{ vars.BOT_NAME }} <${{ vars.BOT_EMAIL }}>
123-
124-
detect-changed: true
125-
ref: ${{ github.ref }}
165+
message: ${{ needs.preflight.outputs.message }}
166+
ref: ${{ needs.preflight.outputs.branch }}
167+
token: ${{ steps.bot-token.outputs.token }}
168+
trailers: 'Signed-off-by: ${{ vars.BOT_NAME }} <${{ vars.BOT_EMAIL }}>'
169+
- id: commit-url
170+
name: Print commit url
171+
run: |
172+
echo ${{ format('{0}/{1}/commit/{2}', github.server_url, github.repository, steps.commit.outputs.sha) }}
126173
pr:
127174
needs:
175+
- branch
128176
- preflight
129177
- prepare
130178
runs-on: ubuntu-latest
@@ -135,21 +183,17 @@ jobs:
135183
with:
136184
app-id: ${{ secrets.BOT_APP_ID }}
137185
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
138-
- id: github-token
139-
name: Set env.GITHUB_TOKEN
140-
run: echo "GITHUB_TOKEN=${{ steps.bot-token.outputs.token }}" >>$GITHUB_ENV
141-
- id: gh-auth
142-
name: Check gh authentication state
143-
run: gh auth status
144186
- id: checkout
145-
name: Checkout ${{ github.ref_name }}
187+
name: Checkout ${{ needs.preflight.outputs.branch }}
146188
uses: actions/[email protected]
147189
with:
148190
persist-credentials: false
149-
ref: ${{ github.ref }}
191+
ref: ${{ needs.preflight.outputs.branch }}
150192
token: ${{ steps.bot-token.outputs.token }}
151193
- id: pr
152194
name: Create pull request
195+
env:
196+
GITHUB_TOKEN: ${{ steps.bot-token.outputs.token }}
153197
run: |
154198
gh pr create --title='${{ needs.preflight.outputs.message }}' --label=scope:release --assignee=${{ github.actor }} --reviewer=${{ github.actor }} --body='## Description
155199

.github/workflows/release.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ jobs:
8080
runs-on: ubuntu-latest
8181
environment:
8282
name: release
83-
url:
84-
${{ format('{0}/{1}/releases/tag/{2}', github.server_url, github.repository,
85-
needs.preflight.outputs.tag) }}
83+
url: |
84+
${{ format('{0}/{1}/releases/tag/{2}', github.server_url, github.repository, needs.preflight.outputs.tag) }}
8685
env:
8786
GITHUB_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
8887
HUSKY: 0

CONTRIBUTING.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ e.g:
348348
349349
1. Get a version bump recommendation
350350
- `yarn bump:recommend`
351-
2. Create release branch
351+
2. Create release chore commit
352352
- `yarn release <new-version>`
353353
- `yarn release major`
354354
- `yarn release minor`
@@ -357,8 +357,10 @@ e.g:
357357
- `yarn release preminor --preid <dist-tag>`
358358
- `yarn release prepatch --preid <dist-tag>`
359359
- `yarn release prerelease --preid <dist-tag>`
360-
3. Monitor workflows
361-
1. [`release-branch`](.github/workflows/release-branch.yml)
360+
3. Push release chore commit
361+
4. Monitor workflows
362+
1. [`release-chore`](.github/workflows/release-chore.yml)
363+
- create release branch
362364
- bump manifest version
363365
- add changelog entry for new release
364366
- create release pr

scripts/release.sh

+5-7
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ set -e
1111
# 5. analyze types
1212
# 6. print package size report
1313
# 7. get release version data
14-
# 8. get release branch name
15-
# 9. create release branch
16-
# 10. push release branch
17-
# 11. cleanup
14+
# 8. create release chore commit
15+
# 9. cleanup
1816
#
1917
# References:
2018
#
19+
# - https://git-scm.com/docs/git-commit
2120
# - https://github.com/arethetypeswrong/arethetypeswrong.github.io
21+
# - https://jqlang.github.io
2222

2323
yarn typecheck
2424
yarn test:cov
@@ -27,7 +27,5 @@ yarn check:types:build
2727
attw package.tgz
2828
yarn pkg-size
2929
RELEASE_VERSION=$(node ./dist/cli.mjs bump -j $@)
30-
RELEASE_BRANCH=release/$(jq .version -r <<<$RELEASE_VERSION)
31-
git branch $RELEASE_BRANCH
32-
git push origin --no-verify --set-upstream $RELEASE_BRANCH
30+
git commit --allow-empty -S -s -m "release(chore): $(jq .version -r <<<$RELEASE_VERSION)"
3331
yarn clean:pack

0 commit comments

Comments
 (0)