DOP-3460: Use PRs for releases (#9)

This commit is contained in:
rayangler 2023-02-06 13:48:02 -05:00 committed by GitHub
parent b9c1391bad
commit add45a7239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 13 deletions

28
.github/workflows/release-pr.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Create Release PR
on:
push:
branches:
- 'releases/**'
jobs:
create-release-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create PR
uses: repo-sync/pull-request@v2
with:
destination_branch: 'main'
pr_title: ${{ github.event.head_commit.message }}
pr_body: |
This is an automated PR.
Please double-check that:
- The correct component's version was updated.
- The version was updated as intended.
- The PR title is in the format "[RELEASE] - "
- The PR will be squashed and merged with the same PR title format.
- The PR commit description is empty prior to squash merging (i.e. remove "co-authored by" text, if exists).
For more information, please see the [release](https://github.com/mongodb-forks/redoc/blob/main/.github/workflows/release.yml) workflow.
pr_label: 'release'

View File

@ -29,7 +29,6 @@ jobs:
id: split id: split
with: with:
msg: ${{ github.event.head_commit.message }} msg: ${{ github.event.head_commit.message }}
separator: ' - '
- name: Push build artifacts and create tag - name: Push build artifacts and create tag
# Use build artifacts in current branch, but only push it to new tag. # Use build artifacts in current branch, but only push it to new tag.
# Build artifacts are needed by redoc-cli since the dependency is pulled from a GitHub branch/tag. # Build artifacts are needed by redoc-cli since the dependency is pulled from a GitHub branch/tag.
@ -38,11 +37,11 @@ jobs:
git config user.name 'github-actions[bot]' git config user.name 'github-actions[bot]'
git add -f bundles/ typings/ git add -f bundles/ typings/
git commit --no-verify -m 'Add build artifacts' git commit --no-verify -m 'Add build artifacts'
git tag ${{ steps.split.outputs._1 }} git tag ${{ steps.split.outputs._2 }}
git push --tags git push --tags
release-redoc-cli: release-redoc-cli:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ startsWith(github.event.head_commit.message, '[RELEASE] - @dop/redoc-cli') }} if: ${{ startsWith(github.event.head_commit.message, '[RELEASE] - @dop/redoc-cli@') }}
env: env:
NPM_BASE_64_AUTH: ${{ secrets.NPM_BASE_64_AUTH }} NPM_BASE_64_AUTH: ${{ secrets.NPM_BASE_64_AUTH }}
NPM_EMAIL: ${{ secrets.NPM_EMAIL }} NPM_EMAIL: ${{ secrets.NPM_EMAIL }}
@ -62,10 +61,9 @@ jobs:
id: split id: split
with: with:
msg: ${{ github.event.head_commit.message }} msg: ${{ github.event.head_commit.message }}
separator: ' - '
- name: Push build artifacts and create tag - name: Push build artifacts and create tag
run: | run: |
git config user.email 'github-actions[bot]@users.noreply.github.com' git config user.email 'github-actions[bot]@users.noreply.github.com'
git config user.name 'github-actions[bot]' git config user.name 'github-actions[bot]'
git tag ${{ steps.split.outputs._1 }} git tag ${{ steps.split.outputs._2 }}
git push --tags git push --tags

View File

@ -44,7 +44,7 @@ node <path/to/redoc/cli/index.js> build <path/to/spec/file/or/url> --options=<pa
The Redoc React component and the Redoc CLI have 2 separate release processes. Because the Redoc CLI pulls its version of Redoc from GitHub, build artifacts are included in the version tag being installed. The Redoc React component and the Redoc CLI have 2 separate release processes. Because the Redoc CLI pulls its version of Redoc from GitHub, build artifacts are included in the version tag being installed.
See the sections below for release steps for each component. A release commit will be pushed to the `main` branch of `mongodb-forks/redoc` after following the steps, which will trigger a GitHub workflow. The workflow is responsible for testing, building artifacts (for the Redoc component, if applicable), and creating a tag. See the sections below for release steps for each component. A pull request will be made with the necessary release changes. After merging the PR, a release commit will be pushed to the `main` branch of `mongodb-forks/redoc` after following the steps, which will trigger a GitHub workflow. The workflow is responsible for testing, building artifacts (for the Redoc component, if applicable), and creating a tag.
:warning: Note: Ensure that your local clone of the `mongodb-forks/redoc` repo is clean and up-to-date with the `main` branch. Please check your remotes to ensure that the `upstream` remote is set to the `mongodb-forks/redoc` repo. Example: :warning: Note: Ensure that your local clone of the `mongodb-forks/redoc` repo is clean and up-to-date with the `main` branch. Please check your remotes to ensure that the `upstream` remote is set to the `mongodb-forks/redoc` repo. Example:
@ -60,6 +60,9 @@ Releasing the Redoc React component can be done by:
1) Go to your local clone of the `mongodb-forks/redoc` repo and ensure you are on the latest iteration of the `main` branch. 1) Go to your local clone of the `mongodb-forks/redoc` repo and ensure you are on the latest iteration of the `main` branch.
2) Run `npm version [major | minor | patch | prerelease --preid=rc]`. 2) Run `npm version [major | minor | patch | prerelease --preid=rc]`.
- A commit should have been pushed to a new `releases/vX.Y.Z` branch.
- The creation of the new branch should create a new pull request.
3) Approve and merge the new pull request to the `main` branch.
#### Redoc CLI #### Redoc CLI
@ -70,6 +73,9 @@ Releasing the Redoc CLI can be done by:
3) Run `npm install https://github.com/mongodb-forks/redoc.git#{VERSION_TAG}` to update the version of Redoc that the CLI uses. 3) Run `npm install https://github.com/mongodb-forks/redoc.git#{VERSION_TAG}` to update the version of Redoc that the CLI uses.
- Example: `npm install https://github.com/mongodb-forks/redoc.git#v1.0.0`. You should see the version set in the CLI's `package.json`. - Example: `npm install https://github.com/mongodb-forks/redoc.git#v1.0.0`. You should see the version set in the CLI's `package.json`.
4) Run `npm version [major | minor | patch | prerelease --preid=rc]`. 4) Run `npm version [major | minor | patch | prerelease --preid=rc]`.
- A commit should have been pushed to a new `releases/@dop/redoc-cli@X.Y.Z` branch.
- The creation of the new branch should create a new pull request.
5) Approve and merge the new pull request to the `main` branch.
## About Redoc ## About Redoc

View File

@ -10,8 +10,8 @@
"node": ">=12.0.0" "node": ">=12.0.0"
}, },
"scripts": { "scripts": {
"version": "git add -u . && git commit -m \"[RELEASE] - @dop/redoc-cli@$npm_package_version\"", "version": "git add -u . && git checkout -b releases/@dop/redoc-cli@$npm_package_version && git commit -m \"[RELEASE] - @dop/redoc-cli@$npm_package_version\"",
"postversion": "git push upstream main" "postversion": "git push upstream releases/@dop/redoc-cli@$npm_package_version && git checkout - && git branch -D releases/@dop/redoc-cli@$npm_package_version"
}, },
"dependencies": { "dependencies": {
"chokidar": "^3.5.1", "chokidar": "^3.5.1",

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@dop/redoc", "name": "@dop/redoc",
"version": "0.0.1", "version": "0.0.1-dop-3460.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@dop/redoc", "name": "@dop/redoc",
"version": "0.0.1", "version": "0.0.1-dop-3460.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@emotion/css": "^11.0.0", "@emotion/css": "^11.0.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@dop/redoc", "name": "@dop/redoc",
"version": "0.0.0", "version": "0.0.1-dop-3460.0",
"description": "ReDoc", "description": "ReDoc",
"repository": { "repository": {
"type": "git", "type": "git",
@ -60,8 +60,8 @@
"docker:build": "docker build -f config/docker/Dockerfile -t redoc .", "docker:build": "docker build -f config/docker/Dockerfile -t redoc .",
"prepare": "husky install", "prepare": "husky install",
"pre-commit": "pretty-quick --staged && npm run lint", "pre-commit": "pretty-quick --staged && npm run lint",
"version": "git add -u . && git commit -m \"[RELEASE] - v$npm_package_version\"", "version": "git add -u . && git checkout -b releases/v$npm_package_version && git commit -m \"[RELEASE] - v$npm_package_version\"",
"postversion": "git push upstream main" "postversion": "git push upstream releases/v$npm_package_version && git checkout - && git branch -D releases/v$npm_package_version"
}, },
"devDependencies": { "devDependencies": {
"@cypress/webpack-preprocessor": "^5.12.0", "@cypress/webpack-preprocessor": "^5.12.0",