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

Feature: create a release draft workflow #1555

Merged
merged 3 commits into from
Feb 22, 2021
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
91 changes: 91 additions & 0 deletions .github/workflows/create-a-release-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Create a release draft

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:
# Pull submodules
submodules: 'recursive'

- name: Check if version has been updated
id: check
uses: EndBug/version-check@v1
with:
diff-search: true

- name: Throw an error and stop workflow if no version changes
uses: actions/github-script@v3
if: steps.check.outputs.changed != 'true'
with:
script: |
core.setFailed('No version changes')

# Create a new draft release
release-draft:
needs: check-version-changing
runs-on: ubuntu-latest
steps:
# Checkout to target branch
- uses: actions/checkout@v2
with:
# Pull submodules
submodules: 'recursive'

# Setup node environment
- uses: actions/setup-node@v1
with:
node-version: 15
registry-url: https://registry.npmjs.org/

# Prepare, build and publish project
- name: Install dependencies
run: yarn

# Build Editor.js
- name: Build output files
run: yarn build

# Get package version name
- name: Get package info
id: package
uses: codex-team/action-nodejs-package-info@v1

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package.outputs.version }}
release_name: v${{ steps.package.outputs.version }}

# Fill release description from pull request body name
body: "${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}"

# Save as a draft release
draft: true

# If version name contains "-rc" suffix than mark a "pre-release" checkbox
prerelease: ${{ contains(steps.package.outputs.version, '-rc') }}

# Build and upload target Editor.js build to release as artifact
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/editor.js
asset_name: editor.js
asset_content_type: application/javascript
37 changes: 19 additions & 18 deletions docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ Pre-release versions may contain additional `-rc.*` suffix.

## Release publishing

> 👉 Stable versions are published to releases from `master` branch.
Drafts for new releases are created automatically via [create-a-release-draft.yml](.github/workflows/create-a-release-draft.yml)
workflow when pull request to `next` branch was merged with an updated version in the package.json file.

There is an [action](.github/workflows/publish.yml) that fired on a new release publishing on GitHub.

After update merging, when a new package version is ready to be published,
create a [new release](https://github.com/codex-team/editor.js/releases/new) with the correct version tag.
There is a [workflow](.github/workflows/publish-package-to-npm.yml) that fired on a new release publishing on GitHub.

Use target version changelog as a description.

Expand All @@ -43,28 +41,31 @@ This package version will be published to NPM with default `latest` tag.

### Release candidate publishing

> 👉 Release candidate versions are published to releases from default `next` branch.
If you want to publish release candidate version, use suffix `-rc.*` for package
version in package.json file and in tag on releases page. Workflow will detect it and mark a release as "pre-release".

If you want to publish release candidate version, use suffix `-rc.*` for package version in package.json file and in tag on releases page.
![](https://capella.pics/796de9eb-bbe0-485c-bc8f-9a4cb76641b7.jpg)

This package version will be published to NPM with `next` tag.

Stable version: `2.19.0`
Release candidate: `2.19.1-rc.0`, `2.19.1-rc.1`, ...
Next version: `2.19.1`

Do not forget to mark this release as a pre-release!

![](https://capella.pics/796de9eb-bbe0-485c-bc8f-9a4cb76641b7.jpg)

## 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`.
2. 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).
3. Create a new release on the releases page with tag `v2.19.1-rc.0` and mark "This is pre-release" checkbox.
[Action](.github/workflows/publish.yml) will automatically push the package to NPM with tag `next`.
4. 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.
5. Merge branch `next` to `master` and create a new release with tag `v2.19.1`.
Same action will publish a new package as `latest` update.
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)
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
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.