Skip to content

Commit efabbab

Browse files
committed
chore: add release automation workflows and configuration files
1 parent 52c7112 commit efabbab

4 files changed

Lines changed: 113 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: release-please
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: googleapis/release-please-action@v4
17+
with:
18+
config-file: release-please-config.json
19+
manifest-file: .release-please-manifest.json
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Sync Release-As from release PR title
2+
3+
on:
4+
pull_request:
5+
types: [edited]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
sync:
12+
if: >-
13+
github.event.pull_request.base.ref == 'master' &&
14+
startsWith(github.event.pull_request.head.ref, 'release-please--') &&
15+
github.event.changes.title != null
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Extract versions from old and new title
19+
id: parse
20+
env:
21+
NEW_TITLE: ${{ github.event.pull_request.title }}
22+
OLD_TITLE: ${{ github.event.changes.title.from }}
23+
run: |
24+
# Anchored on pull-request-title-pattern "release: ${version}" from release-please-config.json.
25+
extract() {
26+
echo "$1" | grep -oE '^release:[[:space:]]+v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?' \
27+
| sed -E 's/^release:[[:space:]]+v?//'
28+
}
29+
NEW_VERSION=$(extract "$NEW_TITLE")
30+
OLD_VERSION=$(extract "$OLD_TITLE")
31+
echo "old=$OLD_VERSION"
32+
echo "new=$NEW_VERSION"
33+
if [ -z "$NEW_VERSION" ]; then
34+
echo "::notice::No semver in new title; nothing to do."
35+
echo "skip=true" >> "$GITHUB_OUTPUT"
36+
exit 0
37+
fi
38+
if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then
39+
echo "::notice::Version unchanged ($NEW_VERSION); not pushing."
40+
echo "skip=true" >> "$GITHUB_OUTPUT"
41+
exit 0
42+
fi
43+
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
44+
45+
- name: Check out master
46+
if: steps.parse.outputs.skip != 'true'
47+
uses: actions/checkout@v6
48+
with:
49+
ref: master
50+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
51+
fetch-depth: 1
52+
53+
- name: Push empty Release-As commit
54+
if: steps.parse.outputs.skip != 'true'
55+
env:
56+
VERSION: ${{ steps.parse.outputs.version }}
57+
run: |
58+
git config user.name "release-as-bot"
59+
git config user.email "release-as-bot@users.noreply.github.com"
60+
git commit --allow-empty -m "chore: pin next release
61+
62+
Release-As: ${VERSION}"
63+
git push origin master

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "5.4.0"
3+
}

release-please-config.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "node",
6+
"package-name": "@imagekit/javascript"
7+
}
8+
},
9+
"include-v-in-tag": true,
10+
"include-component-in-tag": false,
11+
"bump-minor-pre-major": true,
12+
"bump-patch-for-minor-pre-major": false,
13+
"pull-request-header": "Automated Release PR",
14+
"pull-request-title-pattern": "release: ${version}",
15+
"changelog-sections": [
16+
{ "type": "feat", "section": "Features" },
17+
{ "type": "fix", "section": "Bug Fixes" },
18+
{ "type": "perf", "section": "Performance Improvements" },
19+
{ "type": "revert", "section": "Reverts" },
20+
{ "type": "chore", "section": "Chores" },
21+
{ "type": "docs", "section": "Documentation" },
22+
{ "type": "style", "section": "Styles" },
23+
{ "type": "refactor", "section": "Refactors" },
24+
{ "type": "test", "section": "Tests", "hidden": true },
25+
{ "type": "build", "section": "Build System" },
26+
{ "type": "ci", "section": "Continuous Integration", "hidden": true }
27+
]
28+
}

0 commit comments

Comments
 (0)