Skip to content

Commit b50a386

Browse files
Add release-please for automated releases (#435)
Replace the manual version-bump workflow and PR-triggered release flow with release-please for automated changelog generation and releases. The publish workflow now triggers on GitHub release events. Also adds a PR title linter to enforce conventional commits. Co-authored-by: Garen J. Torikian <gjtorikian@users.noreply.github.com>
1 parent b8f7796 commit b50a386

File tree

6 files changed

+63
-120
lines changed

6 files changed

+63
-120
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Lint PR Title
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
permissions:
11+
pull-requests: read
12+
13+
jobs:
14+
main:
15+
name: Validate PR title
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: amannn/action-semantic-pull-request@v5
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Generate token
17+
id: generate-token
18+
uses: actions/create-github-app-token@v2
19+
with:
20+
app-id: ${{ vars.SDK_BOT_APP_ID }}
21+
private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }}
22+
23+
- uses: googleapis/release-please-action@v4
24+
with:
25+
token: ${{ steps.generate-token.outputs.token }}

.github/workflows/release.yml

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,16 @@
11
name: Release
22

33
on:
4-
pull_request:
5-
types: [closed]
6-
branches: [main]
4+
release:
5+
types: [published]
76

87
defaults:
98
run:
109
shell: bash
1110

1211
jobs:
13-
create-release:
14-
name: Create GitHub Release
15-
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'version-bump')
16-
runs-on: ubuntu-latest
17-
permissions:
18-
contents: write
19-
outputs:
20-
version: ${{ steps.get-version.outputs.version }}
21-
steps:
22-
- name: Generate token
23-
id: generate-token
24-
uses: actions/create-github-app-token@v2
25-
with:
26-
app-id: ${{ vars.SDK_BOT_APP_ID }}
27-
private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }}
28-
29-
- name: Checkout
30-
uses: actions/checkout@v6
31-
with:
32-
token: ${{ steps.generate-token.outputs.token }}
33-
34-
- name: Get version from version.rb
35-
id: get-version
36-
run: |
37-
VERSION=$(grep "VERSION = " lib/workos/version.rb | sed "s/.*VERSION = '\(.*\)'/\1/")
38-
echo "version=$VERSION" >> $GITHUB_OUTPUT
39-
40-
- name: Create Release
41-
uses: softprops/action-gh-release@v2
42-
with:
43-
tag_name: v${{ steps.get-version.outputs.version }}
44-
name: v${{ steps.get-version.outputs.version }}
45-
generate_release_notes: true
46-
token: ${{ steps.generate-token.outputs.token }}
47-
4812
publish:
4913
name: Publish to RubyGems
50-
needs: create-release
5114
runs-on: ubuntu-latest
5215
permissions:
5316
id-token: write
@@ -72,5 +35,6 @@ jobs:
7235

7336
- name: Publish to RubyGems
7437
run: |
38+
VERSION="${GITHUB_REF_NAME#v}"
7539
bundle exec rake build
76-
gem push pkg/workos-${{ needs.create-release.outputs.version }}.gem --host https://rubygems.org
40+
gem push pkg/workos-${VERSION}.gem --host https://rubygems.org

.github/workflows/version-bump.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

.release-please-manifest.json

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

release-please-config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "ruby",
6+
"package-name": "workos",
7+
"version-file": "lib/workos/version.rb",
8+
"changelog-path": "CHANGELOG.md"
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)