Skip to content

Commit ebf32c6

Browse files
committed
ci: add release-please with auto-merge, first release at 1.0.0
1 parent 8b41bea commit ebf32c6

3 files changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
actions: write
10+
contents: write
11+
pull-requests: write
12+
13+
concurrency:
14+
group: release-${{ github.ref }}
15+
cancel-in-progress: false
16+
17+
jobs:
18+
release-please:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- id: release
22+
uses: googleapis/release-please-action@v5
23+
with:
24+
config-file: release-please-config.json
25+
manifest-file: .release-please-manifest.json
26+
27+
- if: ${{ steps.release.outputs.pr }}
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
REPO: ${{ github.repository }}
31+
WORKFLOW: ${{ github.workflow }}
32+
PR_JSON: ${{ steps.release.outputs.pr }}
33+
run: |
34+
PR=$(echo "$PR_JSON" | jq -r .number)
35+
BRANCH=$(echo "$PR_JSON" | jq -r .headBranchName)
36+
# Rebase-merge works when main has advanced past the release branch's
37+
# base. When the release commit already sits directly on main HEAD,
38+
# GitHub refuses ("This branch can't be rebased") on a rebase-only
39+
# repo — fast-forward main to the release commit via the API instead.
40+
gh pr merge --rebase --auto -R "$REPO" "$PR" \
41+
|| gh pr merge --rebase -R "$REPO" "$PR" \
42+
|| gh api -X PATCH "repos/$REPO/git/refs/heads/main" \
43+
-f sha="$(gh api "repos/$REPO/git/refs/heads/$BRANCH" --jq .object.sha)"
44+
for _ in $(seq 1 30); do
45+
STATE=$(gh pr view "$PR" -R "$REPO" --json state --jq .state)
46+
[ "$STATE" = "MERGED" ] && break
47+
sleep 2
48+
done
49+
gh api -X DELETE "repos/$REPO/git/refs/heads/$BRANCH" 2>/dev/null || true
50+
gh workflow run "$WORKFLOW" -R "$REPO" --ref main
51+
52+
# When a release is actually published, redeploy from main so the live
53+
# build carries the bumped version. release-please's own version-bump
54+
# commit is pushed by GITHUB_TOKEN and does NOT trigger the on:push deploy,
55+
# so the site would otherwise stay one release behind.
56+
- if: ${{ steps.release.outputs.release_created }}
57+
env:
58+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
REPO: ${{ github.repository }}
60+
run: gh workflow run deploy.yml -R "$REPO" --ref main

.release-please-manifest.json

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

release-please-config.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "node",
6+
"package-name": "influence-sensor",
7+
"release-as": "1.0.0",
8+
"include-component-in-tag": false,
9+
"draft": false,
10+
"prerelease": false,
11+
"bump-minor-pre-major": false,
12+
"bump-patch-for-minor-pre-major": false,
13+
"changelog-sections": [
14+
{ "type": "feat", "section": "Features" },
15+
{ "type": "fix", "section": "Bug Fixes" },
16+
{ "type": "perf", "section": "Performance" },
17+
{ "type": "refactor", "section": "Refactor" },
18+
{ "type": "docs", "section": "Documentation" },
19+
{ "type": "chore", "section": "Chores" },
20+
{ "type": "style", "section": "Style", "hidden": true },
21+
{ "type": "test", "section": "Tests", "hidden": true }
22+
]
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)