Skip to content

Commit

Permalink
Move bump logic to a PR
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM committed Nov 9, 2023
1 parent f49098d commit 3179535
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 16 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/create-bumb-version-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create bump version PR

on:
workflow_dispatch:
inputs:
version:
description: Version to change to.
required: true
type: string

jobs:
bump-version-pr:
name: Bump version PR
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main

- name: Use Node.js from nvmrc
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Bump version
run: |
npm version --commit-hooks false --git-tag-version false ${{ inputs.version }}
./build/bump-version-changelog.js
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: Bump version to ${{ inputs.version }}
branch: bump-version-to-${{ inputs.version }}
title: Bump version to ${{ inputs.version }}
53 changes: 37 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
name: Release

on:
push:
branches: [main]
workflow_dispatch:
inputs:
version:
description: Version to change to.
required: true
type: string

jobs:
release:
release-check:
name: Release
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main

- name: Use Node.js from nvmrc
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Check if version changed
id: check
uses: EndBug/version-check@v2

- name: Set Continue Flag
run: echo "run_release=${{ steps.check.outputs.changed }}" >> $GITHUB_OUTPUT

release-publish:
needs: release-check
if: ${{ needs.release-check.outputs.run_release == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -27,24 +48,24 @@ jobs:
with:
node-version-file: '.nvmrc'

- name: Bump version
run: |
npm version --commit-hooks false --git-tag-version false ${{ inputs.version }}
./build/bump-version-changelog.js
- name: Commit and push version bump with a tag
uses: stefanzweifel/git-auto-commit-action@v5
- name: Get version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1

- name: Tag commit and push
uses: mathieudutour/github-tag-action@v6.1
with:
commit_message: Bump version to ${{ inputs.version }}
tagging_message: ${{ inputs.version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.package-version.outputs.current-version }}

- name: Install
run: npm ci

- name: Prepare release
id: prepare_release
run: |
echo "version_tag=v${{ inputs.version }}" >> $GITHUB_OUTPUT
RELEASE_TYPE=$(node -e "console.log(require('semver').prerelease('${{ inputs.version }}') ? 'prerelease' : 'regular')")
echo "version_tag=v${{ steps.package-version.outputs.current-version }}" >> $GITHUB_OUTPUT
RELEASE_TYPE=$(node -e "console.log(require('semver').prerelease('${{ steps.package-version.outputs.current-version }}') ? 'prerelease' : 'regular')")
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
- name: Build
Expand Down

0 comments on commit 3179535

Please sign in to comment.