diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0cdf2500..34ee6557 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -71,6 +71,7 @@ jobs: # - name: Invalidate # run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DEMO_DISTRIBUTION_ID }} --paths "/*" publish: + name: Publish to NPM needs: [bundle, unit-tests, e2e-tests] runs-on: ubuntu-latest steps: @@ -98,3 +99,21 @@ jobs: run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + publish-cdn: + name: Publish to CDN + needs: [bundle, unit-tests, e2e-tests] + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Configure AWS + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Download all artifact + uses: actions/download-artifact@v3 + - name: Publish to S3 + run: npm run publish-cdn diff --git a/README.md b/README.md index 0b55dece..5d1c28dc 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Build Status](https://travis-ci.com/Redocly/redoc.svg?branch=master)](https://travis-ci.com/Redocly/redoc) [![Coverage Status](https://coveralls.io/repos/Redocly/redoc/badge.svg?branch=master&service=github)](https://coveralls.io/github/Redocly/redoc?branch=master) [![npm](http://img.shields.io/npm/v/redoc.svg)](https://www.npmjs.com/package/redoc) [![License](https://img.shields.io/npm/l/redoc.svg)](https://github.com/Redocly/redoc/blob/master/LICENSE) - [![bundle size](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js?compression=gzip&max=300000)](https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js) [![npm](https://img.shields.io/npm/dm/redoc.svg)](https://www.npmjs.com/package/redoc) [![](https://data.jsdelivr.com/v1/package/npm/redoc/badge)](https://www.jsdelivr.com/package/npm/redoc) [![Docker Build Status](https://img.shields.io/docker/build/redocly/redoc.svg)](https://hub.docker.com/r/redocly/redoc/) + [![bundle size](http://img.badgesize.io/https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js?compression=gzip&max=300000)](https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js) [![npm](https://img.shields.io/npm/dm/redoc.svg)](https://www.npmjs.com/package/redoc) [![](https://data.jsdelivr.com/v1/package/npm/redoc/badge)](https://www.jsdelivr.com/package/npm/redoc) [![Docker Build Status](https://img.shields.io/docker/build/redocly/redoc.svg)](https://hub.docker.com/r/redocly/redoc/) **This is the README for the `2.x` version of Redoc (React-based).** @@ -102,9 +102,9 @@ Refer to the Redocly's documentation for more information on these products: ![](docs/images/code-samples-demo.gif) ## Releases -**Important:** all the 2.x releases are deployed to npm and can be used with jsdeliver: -- particular release, for example, `v2.0.0-alpha.15`: https://cdn.jsdelivr.net/npm/redoc@2.0.0-alpha.17/bundles/redoc.standalone.js -- `next` release: https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js +**Important:** all the 2.x releases are deployed to npm and can be used with Redocly-cdn: +- particular release, for example, `v2.0.0-rc.70`: https://cdn.redoc.ly/redoc/v2.0.0-rc.70/bundles/redoc.standalone.js +- `latest` release: https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js Additionally, all the 1.x releases are hosted on our GitHub Pages-based CDN **(deprecated)**: - particular release, for example `v1.2.0`: https://rebilly.github.io/ReDoc/releases/v1.2.0/redoc.min.js @@ -166,7 +166,7 @@ replace the `spec-url` attribute with the url or local file address to your defi - + diff --git a/docs/deployment/html.md b/docs/deployment/html.md index 53568ab2..5c392be9 100644 --- a/docs/deployment/html.md +++ b/docs/deployment/html.md @@ -51,7 +51,7 @@ or the files located in your `node modules` folder. To reference the Redoc script with a CDN link: ```html - + ``` ### Node modules link diff --git a/docs/quickstart.md b/docs/quickstart.md index 7607c10f..1b01e0f1 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -38,7 +38,7 @@ replace the `spec-url` attribute with the URL or local file address to your defi - + ``` diff --git a/package.json b/package.json index f5d9319d..3190e111 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "start:demo": "webpack serve --hot --config demo/webpack.config.ts --mode=development", "compile:cli": "tsc custom.d.ts cli/index.ts --target es6 --module commonjs --types yargs", "build:demo": "webpack --mode=production --config demo/webpack.config.ts", + "publish-cdn": "scripts/publish-cdn.sh", "deploy:demo": "aws s3 sync demo/dist s3://production-redoc-demo --acl=public-read", "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 .", diff --git a/scripts/publish-cdn.sh b/scripts/publish-cdn.sh new file mode 100755 index 00000000..af930849 --- /dev/null +++ b/scripts/publish-cdn.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -e # exit on error + +# TODO: Update script! + +VERSION=$(node scripts/version.js) +VERSION_TAG=v${VERSION:0:1}.x + +copy_to_s3 () { + aws s3 cp bundles "s3://redocly-cdn/redoc/$1/bundles" --recursive "$2" + aws s3 cp CHANGELOG.md "s3://redocly-cdn/redoc/$1/CHANGELOG.md" "$2" + aws s3 cp LICENSE "s3://redocly-cdn/redoc/$1/LICENSE" "$2" + aws s3 cp package.json "s3://redocly-cdn/redoc/$1/package.json" "$2" + aws s3 cp README.md "s3://redocly-cdn/redoc/$1/README.md" "$2" +} + +if aws s3 ls "redocly-cdn/redoc/v$VERSION/" "$@"; then + echo "Version $VERSION already exists" + exit 1 +else + echo Releasing $VERSION + + echo Uploading to S3 $VERSION + copy_to_s3 "v$VERSION" $@ + + echo Uploading to S3 $VERSION_TAG + copy_to_s3 "$VERSION_TAG" $@ + + if [[ "$VERSION_TAG" == "v2.x" ]]; then + echo Uploading to S3 latest + copy_to_s3 latest $@ + fi + + echo + echo Deployed successfully + exit 0 +fi diff --git a/scripts/version.js b/scripts/version.js new file mode 100644 index 00000000..8729268e --- /dev/null +++ b/scripts/version.js @@ -0,0 +1 @@ +console.log(require('../package.json').version);