From 13343efb33a93bea6501f8b90aeaacb2518fb57d Mon Sep 17 00:00:00 2001 From: Taly Date: Sat, 20 Feb 2021 21:48:54 +0300 Subject: [PATCH 1/3] Rename workflow file --- .github/workflows/{publish.yml => publish-package-to-npm.yml} | 0 docs/releases.md | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{publish.yml => publish-package-to-npm.yml} (100%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish-package-to-npm.yml similarity index 100% rename from .github/workflows/publish.yml rename to .github/workflows/publish-package-to-npm.yml diff --git a/docs/releases.md b/docs/releases.md index e2337310d..8c346ced8 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -28,7 +28,7 @@ Pre-release versions may contain additional `-rc.*` suffix. > 👉 Stable versions are published to releases from `master` branch. -There is an [action](.github/workflows/publish.yml) that fired on a new release publishing on GitHub. +There is an [action](.github/workflows/publish-package-to-npm.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. @@ -64,7 +64,7 @@ Let's imagine that package version is `2.19.0` and you want to add some bug fixe 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`. +[Action](.github/workflows/publish-package-to-npm.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. From 00d75ca9e3e0e611493ba51bbd95923a85149cea Mon Sep 17 00:00:00 2001 From: Taly Date: Sat, 20 Feb 2021 21:49:06 +0300 Subject: [PATCH 2/3] Create create-a-release-draft.yml --- .github/workflows/create-a-release-draft.yml | 91 ++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/create-a-release-draft.yml diff --git a/.github/workflows/create-a-release-draft.yml b/.github/workflows/create-a-release-draft.yml new file mode 100644 index 000000000..ac56d25d5 --- /dev/null +++ b/.github/workflows/create-a-release-draft.yml @@ -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 From b8b28fefd75be89e10c4e63de04cdbe39ac78de6 Mon Sep 17 00:00:00 2001 From: Taly Date: Sat, 20 Feb 2021 22:16:09 +0300 Subject: [PATCH 3/3] Update releases.md --- docs/releases.md | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/docs/releases.md b/docs/releases.md index 8c346ced8..7b904cb32 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -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-package-to-npm.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. @@ -43,9 +41,10 @@ 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. @@ -53,18 +52,20 @@ 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-package-to-npm.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. + +