Skip to content

Commit a7fc4b5

Browse files
committed
chore: setup release-please (#1211)
1 parent a0ee9eb commit a7fc4b5

File tree

4 files changed

+85
-66
lines changed

4 files changed

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

.github/release-header.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:sparkling_heart: I maintain **Cabin** in my spare time. Buy me a coffee on [GitHub Sponsors](https://github.com/sponsors/ken-matsui) so I can keep shipping features!
2+
3+
## Installation
4+
5+
### Ubuntu/Debian
6+
7+
```bash
8+
wget https://github.com/cabinpkg/cabin/releases/download/${TAG}/cabin_${TAG}_amd64.deb
9+
sudo dpkg -i cabin_${TAG}_amd64.deb
10+
```
11+
12+
### RHEL/CentOS/Fedora
13+
14+
```bash
15+
wget https://github.com/cabinpkg/cabin/releases/download/${TAG}/cabin-${TAG}-1.x86_64.rpm
16+
sudo rpm -i cabin-${TAG}-1.x86_64.rpm
17+
```

.github/release-please-config.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"release-type": "simple",
4+
"bump-minor-pre-major": true,
5+
"bump-patch-for-minor-pre-major": true,
6+
"skip-changelog": true,
7+
"packages": {
8+
".": {
9+
"extra-files": [
10+
{
11+
"type": "toml",
12+
"path": "cabin.toml",
13+
"jsonpath": "$.package.version"
14+
}
15+
]
16+
}
17+
}
18+
}

.github/workflows/release.yml

Lines changed: 47 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,38 @@
11
name: Release
22

33
on:
4-
workflow_dispatch:
4+
push:
5+
branches: [main]
56

67
permissions:
78
contents: write
9+
pull-requests: write
810

911
env:
1012
CXX: g++-14
1113

1214
jobs:
13-
changelog:
15+
bump:
1416
runs-on: ubuntu-24.04
1517
outputs:
16-
skipped: ${{ steps.changelog.outputs.skipped }}
17-
tag: ${{ steps.changelog.outputs.tag }}
18-
clean_changelog: ${{ steps.changelog.outputs.clean_changelog }}
18+
release_created: ${{ steps.rp.outputs.release_created }}
19+
tag: ${{ steps.rp.outputs.tag_name }}
1920
steps:
20-
- uses: actions/checkout@v4
21-
with:
22-
fetch-depth: 0 # Ensure we have all tags
23-
24-
- name: Generate Conventional ChangeLog
25-
uses: TriPSs/conventional-changelog-action@v6
26-
id: changelog
21+
- uses: googleapis/release-please-action@v4
22+
id: rp
2723
with:
28-
preset: "conventionalcommits"
29-
tag-prefix: ""
30-
output-file: "false"
31-
version-file: "cabin.toml"
32-
version-path: "package.version"
33-
skip-git-pull: "true"
24+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
25+
config-file: .github/release-please-config.json
26+
manifest-file: .github/.release-please-manifest.json
3427

3528
build:
36-
needs: changelog
29+
needs: bump
30+
if: needs.bump.outputs.release_created == 'true'
3731
runs-on: ubuntu-24.04
3832
steps:
3933
- uses: actions/checkout@v4
4034
with:
41-
ref: ${{ needs.changelog.outputs.tag }}
35+
ref: ${{ needs.bump.outputs.tag }}
4236

4337
- name: Setup Ubuntu dependencies
4438
uses: ./.github/actions/setup-ubuntu-deps
@@ -53,12 +47,13 @@ jobs:
5347
path: build/cabin
5448

5549
package:
56-
needs: [changelog, build]
50+
needs: [bump, build]
51+
if: needs.bump.outputs.release_created == 'true'
5752
runs-on: ubuntu-24.04
5853
steps:
5954
- uses: actions/checkout@v4
6055
with:
61-
ref: ${{ needs.changelog.outputs.tag }}
56+
ref: ${{ needs.bump.outputs.tag }}
6257

6358
- name: Download build artifact
6459
uses: actions/download-artifact@v4
@@ -78,28 +73,29 @@ jobs:
7873
- name: Create DEB package
7974
run: nfpm pkg --packager deb
8075
env:
81-
CABIN_VERSION: ${{ needs.changelog.outputs.tag }}
76+
CABIN_VERSION: ${{ needs.bump.outputs.tag }}
8277

8378
- name: Create RPM package
8479
run: nfpm pkg --packager rpm
8580
env:
86-
CABIN_VERSION: ${{ needs.changelog.outputs.tag }}
81+
CABIN_VERSION: ${{ needs.bump.outputs.tag }}
8782

8883
- name: Upload package artifacts
8984
uses: actions/upload-artifact@v4
9085
with:
91-
name: packages
86+
name: rel-packages
9287
path: |
9388
*.deb
9489
*.rpm
9590
9691
demo:
97-
needs: [changelog, build]
92+
needs: [bump, build]
93+
if: needs.bump.outputs.release_created == 'true'
9894
runs-on: ubuntu-24.04
9995
steps:
10096
- uses: actions/checkout@v4
10197
with:
102-
ref: ${{ needs.changelog.outputs.tag }}
98+
ref: ${{ needs.bump.outputs.tag }}
10399

104100
- name: Download build artifact
105101
uses: actions/download-artifact@v4
@@ -165,54 +161,39 @@ jobs:
165161
- name: Upload demo artifact
166162
uses: actions/upload-artifact@v4
167163
with:
168-
name: demo-gif
164+
name: rel-demo
169165
path: ${{ runner.temp }}/demo.gif
170166

171167
release:
172-
needs: [changelog, package, demo]
168+
needs: [bump, package, demo]
169+
if: needs.bump.outputs.release_created == 'true'
173170
runs-on: ubuntu-24.04
174171
steps:
175172
- uses: actions/checkout@v4
176173
with:
177-
ref: ${{ needs.changelog.outputs.tag }}
174+
ref: ${{ needs.bump.outputs.tag }}
178175

179-
- name: Download package artifacts
180-
uses: actions/download-artifact@v4
176+
- name: Prepend header to RP notes
177+
uses: actions/github-script@v7
181178
with:
182-
name: packages
183-
184-
- name: Download demo artifact
179+
script: |
180+
const tag = '${{ needs.bump.outputs.tag }}';
181+
const { owner, repo } = context.repo;
182+
const { data: rel } = await github.rest.repos.getReleaseByTag({ owner, repo, tag });
183+
const fs = require('fs');
184+
let header = fs.readFileSync('.github/release-header.md', 'utf8');
185+
header = header.replace(/\$\{TAG\}/g, tag);
186+
await github.rest.repos.updateRelease({
187+
owner, repo, release_id: rel.id,
188+
body: `${header}\n\n${rel.body ?? ''}`
189+
});
190+
191+
- name: Download release artifacts
185192
uses: actions/download-artifact@v4
186193
with:
187-
name: demo-gif
188-
189-
- name: Release
190-
uses: softprops/action-gh-release@v2
191-
with:
192-
tag_name: ${{ needs.changelog.outputs.tag }}
193-
draft: false
194-
generate_release_notes: ${{ needs.changelog.outputs.skipped }}
195-
files: |
196-
*.deb
197-
*.rpm
198-
demo.gif
199-
body: |
200-
:sparkling_heart: I maintain **Cabin** in my spare time. Buy me a coffee on [GitHub Sponsors](https://github.com/sponsors/ken-matsui) so I can keep shipping features!
201-
202-
## Installation
203-
204-
### Ubuntu/Debian
205-
206-
```bash
207-
wget https://github.com/cabinpkg/cabin/releases/download/${{ needs.changelog.outputs.tag }}/cabin_${{ needs.changelog.outputs.tag }}_amd64.deb
208-
sudo dpkg -i cabin_${{ needs.changelog.outputs.tag }}_amd64.deb
209-
```
210-
211-
### RHEL/CentOS/Fedora
212-
213-
```bash
214-
wget https://github.com/cabinpkg/cabin/releases/download/${{ needs.changelog.outputs.tag }}/cabin-${{ needs.changelog.outputs.tag }}-1.x86_64.rpm
215-
sudo rpm -i cabin-${{ needs.changelog.outputs.tag }}-1.x86_64.rpm
216-
```
194+
pattern: rel-*
195+
path: artifacts/
196+
merge-multiple: true
217197

218-
${{ needs.changelog.outputs.clean_changelog }}
198+
- name: Upload release artifacts
199+
run: gh release upload '${{ needs.bump.outputs.tag }}' artifacts/* --clobber

0 commit comments

Comments
 (0)