Skip to content

Commit f12d8aa

Browse files
authored
chore(release): use app token to create the release PR (#72)
1 parent 5b6c803 commit f12d8aa

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Prepare release
2+
description: |
3+
Bumps the version in package.json and creates a release PR. Once merged, the new
4+
version will be published to npm.
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: "Exact version to bump to or one of major, minor, patch"
10+
required: true
11+
default: "patch"
12+
13+
jobs:
14+
create-pr:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
18+
id: app-token
19+
with:
20+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
21+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
22+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version-file: package.json
27+
registry-url: "https://registry.npmjs.org"
28+
cache: "npm"
29+
- name: Bump version
30+
id: bump-version
31+
run: |
32+
echo "NEW_VERSION=$(npm version ${{ inputs.version }} --no-git-tag-version)" >> $GITHUB_OUTPUT
33+
- name: Create release PR
34+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # 7.0.8
35+
with:
36+
title: "Release v${{ steps.bump-version.outputs.NEW_VERSION }}"
37+
token: ${{ steps.app-token.outputs.token }}
38+
commit-message: "Bump version to v${{ steps.bump-version.outputs.NEW_VERSION }}"
39+
body: |
40+
This PR bumps the package version to v${{ steps.bump-version.outputs.NEW_VERSION }}.
41+
Once merged, the new version will be published to npm.
42+
base: main
43+
branch: release/v${{ steps.bump-version.outputs.NEW_VERSION }}
44+
author: "${{ steps.app-token.outputs.app-slug}}[bot] <${{ steps.app-token.outputs.app-email }}>"
45+
committer: "${{ steps.app-token.outputs.app-slug}}[bot] <${{ steps.app-token.outputs.app-email }}>"

.github/workflows/publish.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,8 @@ jobs:
6363
run: npm publish
6464
env:
6565
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
66-
- name: Publish git tag
67-
run: |
68-
git config --global user.name 'github-actions[bot]'
69-
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
70-
git tag ${{ needs.check.outputs.VERSION }}
71-
git push origin --tags
7266
- name: Publish git release
7367
env:
7468
GH_TOKEN: ${{ github.token }}
7569
run: |
76-
gh release create ${{ needs.check.outputs.VERSION }} --title "${{ needs.check.outputs.VERSION }}" --generate-notes
70+
gh release create ${{ needs.check.outputs.VERSION }} --title "${{ needs.check.outputs.VERSION }}" --generate-notes --target ${{ github.sha }}

0 commit comments

Comments
 (0)