diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..fe5e850d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,71 @@ +name: Release +on: + push: + branches: + - main + paths: + - 'package.json' + - 'cli/package.json' +jobs: + release-redoc: + runs-on: ubuntu-latest + if: ${{ startsWith(github.event.head_commit.message, '[RELEASE] - v') }} + env: + NPM_BASE_64_AUTH: ${{ secrets.NPM_BASE_64_AUTH }} + NPM_EMAIL: ${{ secrets.NPM_EMAIL }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - name: Install dependencies + run: npm ci && npm ci --prefix cli + - name: Create bundles + run: npm run bundle + - name: Run unit tests + run: npm run test + - name: Run e2e tests + run: npm run e2e + - name: Split commit message + uses: jungwinter/split@v2 + id: split + with: + msg: ${{ github.event.head_commit.message }} + separator: ' - ' + - name: Push build artifacts and create 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. + run: | + git config user.email 'github-actions[bot]@users.noreply.github.com' + git config user.name 'github-actions[bot]' + git add -f bundles/ typings/ + git commit --no-verify -m 'Add build artifacts' + git tag ${{ steps.split.outputs._1 }} + git push --tags + release-redoc-cli: + runs-on: ubuntu-latest + if: ${{ startsWith(github.event.head_commit.message, '[RELEASE] - @dop/redoc-cli') }} + env: + NPM_BASE_64_AUTH: ${{ secrets.NPM_BASE_64_AUTH }} + NPM_EMAIL: ${{ secrets.NPM_EMAIL }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - name: Install dependencies + run: npm ci && npm ci --prefix cli + - name: Create bundles + run: npm run bundle + - name: Run unit tests + run: npm run test + - name: Run e2e tests + run: npm run e2e + - name: Split commit message + uses: jungwinter/split@v2 + id: split + with: + msg: ${{ github.event.head_commit.message }} + separator: ' - ' + - name: Push build artifacts and create tag + run: | + git config user.email 'github-actions[bot]@users.noreply.github.com' + git config user.name 'github-actions[bot]' + git tag ${{ steps.split.outputs._1 }} + git push --tags diff --git a/.gitignore b/.gitignore index 0ba02826..86350375 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ yarn.lock .idea .vscode .eslintcache + +# Test output from redoc-cli +redoc-*.html diff --git a/.npmrc b/.npmrc index 82f2593a..e0cd6edb 100644 --- a/.npmrc +++ b/.npmrc @@ -2,3 +2,4 @@ registry=https://artifactory.corp.mongodb.com/artifactory/api/npm/npm/ _auth=${NPM_BASE_64_AUTH} _email=${NPM_EMAIL} _always-auth=true +git-tag-version=false diff --git a/README.md b/README.md index 6767e1ad..a78f1296 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,37 @@ With `node` installed, run by doing the following: node build --options= --output= ``` +### Releasing + +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. + +: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: + +``` +$ git remote -v +upstream https://github.com/mongodb-forks/redoc.git (fetch) +upstream https://github.com/mongodb-forks/redoc.git (push) +``` + +#### Redoc + +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. +2) Run `npm version [major | minor | patch | prerelease --preid=rc]`. + +#### Redoc CLI + +Releasing the Redoc CLI 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. +2) Go to the `cli/` directory. +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`. +4) Run `npm version [major | minor | patch | prerelease --preid=rc]`. + ## About Redoc Redoc is an open-source tool for generating documentation from OpenAPI (fka Swagger) definitions. diff --git a/cli/npm-shrinkwrap.json b/cli/npm-shrinkwrap.json index 61788120..5ea23084 100644 --- a/cli/npm-shrinkwrap.json +++ b/cli/npm-shrinkwrap.json @@ -1,12 +1,12 @@ { "name": "redoc-cli", - "version": "0.13.20", + "version": "0.0.1-test-rc.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "redoc-cli", - "version": "0.13.20", + "version": "0.0.1-test-rc.1", "license": "MIT", "dependencies": { "chokidar": "^3.5.1", diff --git a/cli/package.json b/cli/package.json index 2f2cb564..ab168283 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,15 +1,18 @@ { - "name": "redoc-cli", - "version": "0.13.20", + "name": "@dop/redoc-cli", + "version": "0.0.0", "description": "ReDoc's Command Line Interface", "main": "index.js", "bin": "index.js", - "repository": "https://github.com/Redocly/redoc", - "author": "Roman Hotsiy ", + "repository": "https://github.com/mongodb-forks/redoc", "license": "MIT", "engines": { "node": ">=12.0.0" }, + "scripts": { + "version": "git add -u . && git commit -m \"[RELEASE] - @dop/redoc-cli@$npm_package_version\"", + "postversion": "git push upstream main" + }, "dependencies": { "chokidar": "^3.5.1", "handlebars": "^4.7.7", diff --git a/package-lock.json b/package-lock.json index 6f1c3872..e0919434 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "redoc", - "version": "2.0.0", + "name": "@dop/redoc", + "version": "0.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "redoc", - "version": "2.0.0", + "name": "@dop/redoc", + "version": "0.0.1", "license": "MIT", "dependencies": { "@emotion/css": "^11.0.0", diff --git a/package.json b/package.json index e132f1e8..5cb234d0 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "redoc", - "version": "2.0.0", + "name": "@dop/redoc", + "version": "0.0.0", "description": "ReDoc", "repository": { "type": "git", - "url": "git://github.com/Redocly/redoc" + "url": "https://github.com/mongodb-forks/redoc" }, "browserslist": [ "defaults" @@ -59,7 +59,9 @@ "license-check": "license-checker --production --onlyAllow 'MIT;ISC;Apache-2.0;BSD;BSD-2-Clause;BSD-3-Clause;CC-BY-4.0;Python-2.0' --summary", "docker:build": "docker build -f config/docker/Dockerfile -t redoc .", "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\"", + "postversion": "git push upstream main" }, "devDependencies": { "@cypress/webpack-preprocessor": "^5.12.0",