.github/workflows/bump.yml #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
workflow_dispatch: | |
inputs: | |
type: | |
description: Select the type of version bump | |
required: true | |
type: choice | |
default: patch | |
options: | |
- patch | |
- minor | |
- major | |
- prerelease | |
- prepatch | |
- preminor | |
- premajor | |
jobs: | |
bump: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.GH_PAT }} | |
steps: | |
- name: Set up checkout | |
uses: actions/checkout@v4 | |
- name: Set up node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: npm | |
- name: Set up cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
- name: Set up node_modules | |
run: npm ci | |
- name: Set up environment variables | |
run: | | |
echo "SHORT_SHA=${GITHUB_SHA:0:7}" >> $GITHUB_ENV | |
echo "OLD_VERSION=$(node -p "require('./lerna.json').version")" >> $GITHUB_ENV | |
- name: Set up git | |
run: | | |
git config --global user.name '루밀LuMir' | |
git config --global user.email 'rpfos@naver.com' | |
git switch -c release-${{ inputs.type }}-${{ env.SHORT_SHA }} | |
- name: Bump version(patch, minor, major) | |
if: ${{ inputs.type == 'patch' || inputs.type == 'minor' || inputs.type == 'major' }} | |
run: | | |
npx lerna version ${{ inputs.type }} -m "release(${{ inputs.type }}): %s" --no-push --no-private --yes | |
- name: Bump version(prerelease, prepatch, preminor, premajor) | |
if: ${{ inputs.type == 'prerelease' || inputs.type == 'prepatch' || inputs.type == 'preminor' || inputs.type == 'premajor' }} | |
run: | | |
npx lerna version ${{ inputs.type }} -m "release(${{ inputs.type }}): %s" --preid canary --no-push --no-private --yes | |
- name: Set up environment variables | |
run: echo "NEW_VERSION=$(node -p "require('./lerna.json').version")" >> $GITHUB_ENV | |
- name: Push | |
run: git push --set-upstream origin release-${{ inputs.type }}-${{ env.SHORT_SHA }} | |
- name: Create pull request | |
run: | | |
gh api \ | |
--method POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/repos/${{ github.repository }}/pulls \ | |
-f "title=release(${{ inputs.type }}): v${{ env.NEW_VERSION }}" \ | |
-f "body=Bump \`${{ github.repository }}\` from v${{ env.OLD_VERSION }} to v${{ env.NEW_VERSION }} :tada:" \ | |
-f "head=${{ github.repository_owner }}:release-${{ inputs.type }}-${{ env.SHORT_SHA }}" \ | |
-f "base=main" |