Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: create a release workflow #197

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,30 @@ jobs:
run: npm run compile
- name: Check
run: npm run check

package:
name: Package for publishing
runs-on: ubuntu-latest
if: ${{ startsWith(github.head_ref, 'release/') }}
steps:
- uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install Dependencies
run: npm ci --ignore-engines

- name: Compile
run: npm run compile

- name: Pack
run: npm pack

- name: Archive artifact
uses: actions/upload-artifact@v4
with:
name: package
path: mongodb-js-oidc-plugin-*.tgz
37 changes: 37 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Prepare Release

on:
workflow_dispatch:
inputs:
version_update_type:
description: What type of version bump should be done
type: choice
options:
- patch
- minor
- major

jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Bump version
run: |
echo "new-version=$(npm version ${{ github.event.inputs.version_update_type }} --no-git-tag-version)" >> $GITHUB_OUTPUT
id: version

- name: Create Release PR
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # 7.0.5
with:
branch: release/${{ steps.version.outputs.new-version }}
title: Prepare for ${{ steps.version.outputs.new-version }}
draft: false
body: An automated PR for next release.
commit-message: Prepare for ${{ steps.version.outputs.new-version }}
56 changes: 56 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish Release

on:
workflow_dispatch:

jobs:
publish:
name: Publish Release
runs-on: ubuntu-latest
environment: Production
steps:
- uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install Dependencies
run: npm ci --ignore-engines

- name: Compile
run: npm run compile

- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Read Version
id: get-version
run: |
echo "package_version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT

- name: Find Release PR
id: find-pull-request
uses: juliangruber/find-pull-request-action@48b6133aa6c826f267ebd33aa2d29470f9d9e7d0 # 1.9.0
with:
branch: ${{ github.ref }}

- name: Merge Pull Request
uses: juliangruber/merge-pull-request-action@9234b8714dda9a08f3d1df5b2a6a3abd7b695353 # 1.3.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.find-pull-request.outputs.number }}
method: squash

- name: Publish Github Release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # 1.14.0
with:
generateReleaseNotes: true
name: ${{ steps.get-version.outputs.package_version }}
commit: main
tag: ${{ steps.get-version.outputs.package_version }}
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
Loading