Skip to content

Commit 39bbf9b

Browse files
nirinchevaddaleax
andauthored
chore: create a release workflow (#197)
Co-authored-by: Anna Henningsen <[email protected]>
1 parent 6d44d9c commit 39bbf9b

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

.github/workflows/nodejs.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,30 @@ jobs:
4848
run: npm run compile
4949
- name: Check
5050
run: npm run check
51+
52+
package:
53+
name: Package for publishing
54+
runs-on: ubuntu-latest
55+
if: ${{ startsWith(github.head_ref, 'release/') }}
56+
steps:
57+
- uses: actions/checkout@v4
58+
59+
- name: Use Node.js 20.x
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: 20.x
63+
64+
- name: Install Dependencies
65+
run: npm ci --ignore-engines
66+
67+
- name: Compile
68+
run: npm run compile
69+
70+
- name: Pack
71+
run: npm pack
72+
73+
- name: Archive artifact
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: package
77+
path: mongodb-js-oidc-plugin-*.tgz

.github/workflows/prepare-release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_update_type:
7+
description: What type of version bump should be done
8+
type: choice
9+
options:
10+
- patch
11+
- minor
12+
- major
13+
14+
jobs:
15+
prepare:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js 20.x
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20.x
24+
25+
- name: Bump version
26+
run: |
27+
echo "new-version=$(npm version ${{ github.event.inputs.version_update_type }} --no-git-tag-version)" >> $GITHUB_OUTPUT
28+
id: version
29+
30+
- name: Create Release PR
31+
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # 7.0.5
32+
with:
33+
branch: release/${{ steps.version.outputs.new-version }}
34+
title: Prepare for ${{ steps.version.outputs.new-version }}
35+
draft: false
36+
body: An automated PR for next release.
37+
commit-message: Prepare for ${{ steps.version.outputs.new-version }}

.github/workflows/publish-release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish:
8+
name: Publish Release
9+
runs-on: ubuntu-latest
10+
environment: Production
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Use Node.js 20.x
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 20.x
18+
19+
- name: Install Dependencies
20+
run: npm ci --ignore-engines
21+
22+
- name: Compile
23+
run: npm run compile
24+
25+
- name: Publish
26+
run: npm publish
27+
env:
28+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29+
30+
- name: Read Version
31+
id: get-version
32+
run: |
33+
echo "package_version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
34+
35+
- name: Find Release PR
36+
id: find-pull-request
37+
uses: juliangruber/find-pull-request-action@48b6133aa6c826f267ebd33aa2d29470f9d9e7d0 # 1.9.0
38+
with:
39+
branch: ${{ github.ref }}
40+
41+
- name: Merge Pull Request
42+
uses: juliangruber/merge-pull-request-action@9234b8714dda9a08f3d1df5b2a6a3abd7b695353 # 1.3.1
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
number: ${{ steps.find-pull-request.outputs.number }}
46+
method: squash
47+
48+
- name: Publish Github Release
49+
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # 1.14.0
50+
with:
51+
generateReleaseNotes: true
52+
name: ${{ steps.get-version.outputs.package_version }}
53+
commit: main
54+
tag: ${{ steps.get-version.outputs.package_version }}
55+
token: ${{ secrets.GITHUB_TOKEN }}
56+
draft: false

0 commit comments

Comments
 (0)