mirror of
https://github.com/codex-team/editor.js
synced 2024-06-20 14:45:07 +02:00
Feature: add bump version action (#1561)
* Update create-a-release-draft.yml * Create bump-version-on-merge-next.yml * Update releases.md
This commit is contained in:
parent
c4a57c16a9
commit
cd6378c160
76
.github/workflows/bump-version-on-merge-next.yml
vendored
Normal file
76
.github/workflows/bump-version-on-merge-next.yml
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
name: Bump version on merge
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- next
|
||||
types: [closed]
|
||||
|
||||
jobs:
|
||||
# If pull request was merged then we should check for a package version update
|
||||
check-version-changing:
|
||||
if: github.event.pull_request.merged == true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Checkout to target branch
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Get package new version name
|
||||
- name: Get package info
|
||||
id: packageNew
|
||||
uses: codex-team/action-nodejs-package-info@v1
|
||||
|
||||
# Checkout to the base commit before merge
|
||||
- name: Checkout to the base commit before merge
|
||||
run: git checkout ${{ github.event.pull_request.base.sha }}
|
||||
|
||||
# Get package old version name
|
||||
- name: Get package info
|
||||
id: packageOld
|
||||
uses: codex-team/action-nodejs-package-info@v1
|
||||
|
||||
# Stop workflow and do not bump version if it was changed already
|
||||
- name: Stop workflow and do not bump version if it was changed already
|
||||
uses: actions/github-script@v3
|
||||
if: steps.packageOld.outputs.version != steps.packageNew.outputs.version
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Version was changed! ${{ steps.packageOld.outputs.version }} -> ${{ steps.packageNew.outputs.version }}')
|
||||
|
||||
bump-version:
|
||||
needs: check-version-changing
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Checkout to target branch
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# Setup node environment
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 15
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
# Bump version to the next prerelease (patch) with rc suffix
|
||||
- name: Suggest the new version
|
||||
run: yarn version --prerelease --preid rc --no-git-tag-version
|
||||
|
||||
# Get package new version name
|
||||
- name: Get package info
|
||||
id: package
|
||||
uses: codex-team/action-nodejs-package-info@v1
|
||||
|
||||
# Create pull request with changes
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
commit-message: Bump version
|
||||
committer: GitHub <noreply@github.com>
|
||||
author: GitHub <noreply@github.com>
|
||||
branch: auto-bump-version
|
||||
delete-branch: true
|
||||
title: "Bump version up to ${{ steps.package.outputs.version }}"
|
||||
body: |
|
||||
Auto-generated bump version suggestion because of PR:
|
||||
**${{ github.event.pull_request.title }}** #${{ github.event.pull_request.number }}
|
37
.github/workflows/create-a-release-draft.yml
vendored
37
.github/workflows/create-a-release-draft.yml
vendored
|
@ -15,21 +15,29 @@ jobs:
|
|||
# Checkout to target branch
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
# Pull submodules
|
||||
submodules: 'recursive'
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check if version has been updated
|
||||
id: check
|
||||
uses: EndBug/version-check@v1
|
||||
with:
|
||||
diff-search: true
|
||||
# Get package new version name
|
||||
- name: Get package info
|
||||
id: packageNew
|
||||
uses: codex-team/action-nodejs-package-info@v1
|
||||
|
||||
- name: Throw an error and stop workflow if no version changes
|
||||
# Checkout to the base commit before merge
|
||||
- name: Checkout to the base commit before merge
|
||||
run: git checkout ${{ github.event.pull_request.base.sha }}
|
||||
|
||||
# Get package old version name
|
||||
- name: Get package info
|
||||
id: packageOld
|
||||
uses: codex-team/action-nodejs-package-info@v1
|
||||
|
||||
# Stop workflow if version was not changed
|
||||
- name: Stop workflow if version was not changed
|
||||
uses: actions/github-script@v3
|
||||
if: steps.check.outputs.changed != 'true'
|
||||
if: steps.packageOld.outputs.version == steps.packageNew.outputs.version
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('No version changes')
|
||||
core.setFailed('No version changes. ${{ steps.packageOld.outputs.version }}')
|
||||
|
||||
# Create a new draft release
|
||||
release-draft:
|
||||
|
@ -89,3 +97,12 @@ jobs:
|
|||
asset_path: dist/editor.js
|
||||
asset_name: editor.js
|
||||
asset_content_type: application/javascript
|
||||
|
||||
# Send a notification message
|
||||
- name: Send a message
|
||||
uses: codex-team/action-codexbot-notify@v1
|
||||
with:
|
||||
webhook: ${{ secrets.CODEX_BOT_WEBHOOK_FRONTEND }}
|
||||
message: '🦥 [Draft release v${{ steps.package.outputs.version }}](${{ steps.create_release.outputs.html_url }}) for package [${{ steps.package.outputs.name }}](${{ steps.package.outputs.npmjs-link }}) has been created. Add changelog and publish it!'
|
||||
parse_mode: 'markdown'
|
||||
disable_web_page_preview: true
|
||||
|
|
|
@ -52,20 +52,29 @@ Stable version: `2.19.0`
|
|||
Release candidate: `2.19.1-rc.0`, `2.19.1-rc.1`, ...
|
||||
Next version: `2.19.1`
|
||||
|
||||
## Auto-bump version
|
||||
|
||||
After each PR merge to the `next` branch [bump-version-on-merge-next.yml](.github/workflows/bump-version-on-merge-next.yml)
|
||||
workflow will check if a package version was updated. If there is no update then it will open a new PR with a next
|
||||
prerelease version.
|
||||
|
||||
You can edit version (and PR name of course) if you need to publish not a pre-release version or any other.
|
||||
|
||||
## Example pipeline
|
||||
|
||||
Let's imagine that package version is `2.19.0` and you want to add some bug fixes and publish an update as `2.19.1`.
|
||||
|
||||
1. Merge a single update or a few pulls with fixes to the default branch `next`
|
||||
and bump the version up to `2.19.1-rc.0` in the package.json.
|
||||
For the rest rc updates you should bump version number in suffix (to `2.19.1-rc.1` etc).
|
||||
2. Workflow [create-a-release-draft.yml](.github/workflows/create-a-release-draft.yml)
|
||||
1. Merge a single update or a few pulls with fixes to the default branch `next`.
|
||||
2. Workflow [bump-version-on-merge-next.yml](.github/workflows/bump-version-on-merge-next.yml) will bump the version up
|
||||
to `2.19.1-rc.0` in the package.json and open a new pull request.
|
||||
3. After bump version PR merge, the workflow [create-a-release-draft.yml](.github/workflows/create-a-release-draft.yml)
|
||||
will automatically create a draft release on GitHub.
|
||||
3. Check this new draft release on the releases page. Check tag `v2.19.1-rc.0` and notice "This is pre-release" checkbox
|
||||
4. Check this new draft release on the releases page. Check tag `v2.19.1-rc.0` and notice "This is pre-release" checkbox
|
||||
if it should be for a release candidate versions. Then publish that release.
|
||||
4. [Workflow](.github/workflows/publish-package-to-npm.yml) will automatically push the package to NPM with tag `next`.
|
||||
5. When you ready to publish a release, remove suffix from version name in package.json (`2.19.1-rc.0` -> `v2.19.1`)
|
||||
and push changes. Follow steps 2-4 with workflows and publish a new version as `latest` update.
|
||||
6. Merge branch `next` to `master` and save sources for history.
|
||||
5. [Workflow](.github/workflows/publish-package-to-npm.yml) will automatically push the package to NPM with tag `next`.
|
||||
6. When you ready to publish a release, remove suffix from version name in package.json (`2.19.1-rc.0` -> `v2.19.1`)
|
||||
in pull request from workflow [bump-version-on-merge-next.yml](.github/workflows/bump-version-on-merge-next.yml).
|
||||
Follow steps 3-5 with workflows and publish a new version as `latest` update.
|
||||
7. Merge branch `next` to `master` and save sources for history.
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue