mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-10 12:47:49 +00:00
chore: enable chagesets (#1211)
This commit is contained in:
8
.changeset/README.md
Normal file
8
.changeset/README.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Changesets
|
||||||
|
|
||||||
|
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
||||||
|
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
||||||
|
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
||||||
|
|
||||||
|
We have a quick list of common questions to get you started engaging with this project in
|
||||||
|
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
||||||
11
.changeset/config.json
Normal file
11
.changeset/config.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
|
||||||
|
"changelog": "./format.js",
|
||||||
|
"commit": false,
|
||||||
|
"fixed": [["@redocly/cli", "@redocly/openapi-core"]],
|
||||||
|
"linked": [],
|
||||||
|
"access": "public",
|
||||||
|
"baseBranch": "main",
|
||||||
|
"updateInternalDependencies": "patch",
|
||||||
|
"ignore": []
|
||||||
|
}
|
||||||
22
.changeset/format.js
Normal file
22
.changeset/format.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const getReleaseLine = async (changeset, _type) => {
|
||||||
|
const [firstLine, ...futureLines] = changeset.summary.split('\n').map((l) => l.trimRight());
|
||||||
|
|
||||||
|
let returnVal = `- ${firstLine}`;
|
||||||
|
|
||||||
|
if (futureLines.length > 0) {
|
||||||
|
returnVal += `\n${futureLines.map((l) => ` ${l}`).join('\n')}`;
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => {
|
||||||
|
if (dependenciesUpdated.length === 0) return '';
|
||||||
|
return `- Updated ${dependenciesUpdated[0].name} to v${dependenciesUpdated[0].newVersion}.`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultChangelogFunctions = {
|
||||||
|
getReleaseLine,
|
||||||
|
getDependencyReleaseLine,
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = defaultChangelogFunctions;
|
||||||
19
.github/CONTRIBUTING.md
vendored
19
.github/CONTRIBUTING.md
vendored
@@ -26,6 +26,7 @@ Before submitting a pull request, please make sure the following is done:
|
|||||||
3. If you’ve fixed a bug or added code that should be tested, don't forget to add tests!
|
3. If you’ve fixed a bug or added code that should be tested, don't forget to add tests!
|
||||||
4. Ensure the test suite passes (`npm test`). Tip: `npm test -- --watch TestName` is helpful in development.
|
4. Ensure the test suite passes (`npm test`). Tip: `npm test -- --watch TestName` is helpful in development.
|
||||||
5. Format your code with prettier (`npm run prettier`).
|
5. Format your code with prettier (`npm run prettier`).
|
||||||
|
6. Each feat/fix PR should also contain a changeset (to create one, run `npx changeset`). Please describe what you've done in this PR using sentence case (you can refer to our [changelog](https://redocly.com/docs/cli/changelog/)). This produces a file in `.changeset` folder. Please commit this file along with your changes.
|
||||||
|
|
||||||
## Development Setup
|
## Development Setup
|
||||||
|
|
||||||
@@ -90,20 +91,6 @@ To test local changes as a package, you can use the following steps:
|
|||||||
|
|
||||||
Don't forget to revert the changes to **package.json** files later.
|
Don't forget to revert the changes to **package.json** files later.
|
||||||
|
|
||||||
## Version updating
|
|
||||||
|
|
||||||
Keep the same versions for both packages. To increase the version follow the steps below:
|
|
||||||
|
|
||||||
1. First bump the version in **packages/core/package.json**.
|
|
||||||
|
|
||||||
1. Run `npm install` in the repository root.
|
|
||||||
|
|
||||||
1. Run `npm run compile` in the repository root.
|
|
||||||
|
|
||||||
1. Bump the version in **packages/cli/package.json** and **package.json** (3 entries in total).
|
|
||||||
|
|
||||||
1. Run `npm install` in the repository root.
|
|
||||||
|
|
||||||
## Contribute documentation
|
## Contribute documentation
|
||||||
|
|
||||||
### Prose linting
|
### Prose linting
|
||||||
@@ -208,3 +195,7 @@ E2E tests are sensitive to any additional output (like `console.log`) in the sou
|
|||||||
- **`packages/core/src/typings`**: contains the common Typescript typings.
|
- **`packages/core/src/typings`**: contains the common Typescript typings.
|
||||||
|
|
||||||
- **`resources`**: contains some example API definitions and configuration files that might be useful for testing.
|
- **`resources`**: contains some example API definitions and configuration files that might be useful for testing.
|
||||||
|
|
||||||
|
## Release flow
|
||||||
|
|
||||||
|
We use [Changesets](https://github.com/changesets/changesets) flow. After merging a PR with a changeset, the release PR is automatically created. Merging that PR triggers the release process.
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
name: CD to NPM & AWS S3
|
name: Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
branches:
|
||||||
- v[0-9]*.[0-9]*.[0-9]*
|
- main
|
||||||
- v[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+ # beta/rc releases
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -17,14 +20,52 @@ jobs:
|
|||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: [test]
|
||||||
|
name: Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
published: ${{ steps.changesets.outputs.published }}
|
||||||
|
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Create Release Pull Request or Publish to npm
|
||||||
|
id: changesets
|
||||||
|
uses: RomanHotsiy/changesets-action@v1
|
||||||
|
with:
|
||||||
|
# This expects you to have a script called release which does a build for your packages and calls changeset publish
|
||||||
|
publish: npm run release
|
||||||
|
commit: 'chore: 🔖 release new versions'
|
||||||
|
title: 'chore: 🔖 release new versions'
|
||||||
|
version: |
|
||||||
|
npx changeset version
|
||||||
|
npm i
|
||||||
|
node scripts/post-changeset.js
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: test
|
needs: [release]
|
||||||
|
if: needs.release.outputs.published == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 20
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
|
||||||
@@ -46,26 +87,10 @@ jobs:
|
|||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SANDBOX_SECRET_ACCESS_KEY }}
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SANDBOX_SECRET_ACCESS_KEY }}
|
||||||
AWS_DEFAULT_REGION: us-east-1
|
AWS_DEFAULT_REGION: us-east-1
|
||||||
AWS_S3_PATH: redocly-sandbox-openapi-cli-dist
|
AWS_S3_PATH: redocly-sandbox-openapi-cli-dist
|
||||||
publish:
|
|
||||||
needs: [test, deploy]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
cache: 'npm'
|
|
||||||
registry-url: 'https://registry.npmjs.org'
|
|
||||||
|
|
||||||
- run: npm ci
|
|
||||||
|
|
||||||
- name: Publish to NPM
|
|
||||||
run: cd packages/core && npm publish && cd ../cli && npm publish
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
dockerhub:
|
dockerhub:
|
||||||
needs: [publish]
|
needs: [release]
|
||||||
|
if: needs.release.outputs.published == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
@@ -109,11 +134,11 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||||
test-released-version:
|
|
||||||
|
post-release-smoke-checks:
|
||||||
needs:
|
needs:
|
||||||
- test
|
- release
|
||||||
- deploy
|
- deploy
|
||||||
- publish
|
|
||||||
- dockerhub
|
- dockerhub
|
||||||
name: Test released version
|
name: Test released version
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -150,3 +175,20 @@ jobs:
|
|||||||
docker run --rm redocly/cli lint https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
|
docker run --rm redocly/cli lint https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
|
||||||
docker run --rm redocly/cli bundle https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
|
docker run --rm redocly/cli bundle https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
|
||||||
docker run --rm redocly/cli build-docs https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
|
docker run --rm redocly/cli build-docs https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
|
||||||
|
|
||||||
|
notify:
|
||||||
|
needs:
|
||||||
|
- release
|
||||||
|
- post-release-smoke-checks
|
||||||
|
if: needs.release.outputs.published == 'true'
|
||||||
|
name: Post the Release Message
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Post to a Slack channel
|
||||||
|
id: slack
|
||||||
|
uses: slackapi/slack-github-action@v1.23.0
|
||||||
|
with:
|
||||||
|
channel-id: C019K52TC0L #releases
|
||||||
|
slack-message: ${{ needs.release.outputs.publishedPackages }}
|
||||||
|
env:
|
||||||
|
SLACK_BOT_TOKEN: ${{ secrets.RELEASES_SLACK_BOT_TOKEN }}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
coverage/
|
coverage/
|
||||||
dist/
|
dist/
|
||||||
packages/cli/lib/
|
lib/
|
||||||
packages/core/lib/
|
output/
|
||||||
*snapshot.js
|
*snapshot.js
|
||||||
packages/core/src/rules/__tests__/fixtures/invalid-yaml.yaml
|
packages/core/src/rules/__tests__/fixtures/invalid-yaml.yaml
|
||||||
resources/output/invalid.json
|
|
||||||
__tests__/webpack-bundle/bundle-workflows/metafile.json
|
__tests__/webpack-bundle/bundle-workflows/metafile.json
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ toc:
|
|||||||
|
|
||||||
# Redocly CLI changelog
|
# Redocly CLI changelog
|
||||||
|
|
||||||
|
<!-- do-not-remove -->
|
||||||
|
|
||||||
## 1.0.0 (2023-07-25)
|
## 1.0.0 (2023-07-25)
|
||||||
|
|
||||||
This release marks the stable version 1.0. There are no changes from previous releases.
|
This release marks the stable version 1.0. There are no changes from previous releases.
|
||||||
|
|||||||
4450
package-lock.json
generated
4450
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -31,6 +31,7 @@
|
|||||||
"build-docs": "npm run cli build-docs resources/pets.yaml",
|
"build-docs": "npm run cli build-docs resources/pets.yaml",
|
||||||
"benchmark": "node --expose-gc --noconcurrent_sweeping --predictable packages/core/src/benchmark/benchmark.js",
|
"benchmark": "node --expose-gc --noconcurrent_sweeping --predictable packages/core/src/benchmark/benchmark.js",
|
||||||
"webpack-bundle": "webpack --config webpack.config.ts",
|
"webpack-bundle": "webpack --config webpack.config.ts",
|
||||||
|
"release": "changeset publish",
|
||||||
"upload": "node scripts/archive-and-upload-bundle.js",
|
"upload": "node scripts/archive-and-upload-bundle.js",
|
||||||
"deploy-local": "npm run webpack-bundle && npm run compile && ENV=local npm run upload",
|
"deploy-local": "npm run webpack-bundle && npm run compile && ENV=local npm run upload",
|
||||||
"pack:prepare": "./scripts/local-pack.sh"
|
"pack:prepare": "./scripts/local-pack.sh"
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@changesets/cli": "^2.26.2",
|
||||||
"@types/jest": "^26.0.15",
|
"@types/jest": "^26.0.15",
|
||||||
"@types/mark.js": "^8.11.5",
|
"@types/mark.js": "^8.11.5",
|
||||||
"@types/marked": "^4.0.3",
|
"@types/marked": "^4.0.3",
|
||||||
|
|||||||
13
scripts/post-changeset.js
Normal file
13
scripts/post-changeset.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const generatedLogs = fs.readFileSync('./packages/cli/CHANGELOG.md').toString();
|
||||||
|
const [, log] = generatedLogs.split('\n## ', 2);
|
||||||
|
const mainChangelog = fs.readFileSync('./docs/changelog.md').toString();
|
||||||
|
const [date] = new Date().toISOString().split('T');
|
||||||
|
const logWithDate = log.replace('\n', ' (${date})\n');
|
||||||
|
const modifiedChangelog = mainChangelog.replace(
|
||||||
|
'<!-- do-not-remove -->\n',
|
||||||
|
'<!-- do-not-remove -->\n\n## ' + logWithDate
|
||||||
|
);
|
||||||
|
|
||||||
|
fs.writeFileSync('./docs/changelog.md', modifiedChangelog);
|
||||||
Reference in New Issue
Block a user