2021-10-11 12:40:56 +03:00
|
|
|
name: Publish cli
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-10-11 18:23:26 +03:00
|
|
|
branches:
|
|
|
|
- master
|
2021-10-11 12:40:56 +03:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
bundle:
|
2022-01-05 18:11:05 +03:00
|
|
|
needs: [check-version-cli]
|
2021-10-11 18:23:26 +03:00
|
|
|
if: needs.check-version-cli.outputs.changed == 'true'
|
2021-10-11 12:40:56 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-05-16 16:16:16 +03:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-node@v3
|
2022-01-05 18:11:05 +03:00
|
|
|
- name: Cache node modules
|
2022-05-16 16:16:16 +03:00
|
|
|
uses: actions/cache@v3
|
2022-01-05 18:11:05 +03:00
|
|
|
with:
|
|
|
|
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
|
|
|
|
key: npm-${{ hashFiles('package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
npm-${{ hashFiles('package-lock.json') }}
|
|
|
|
npm-
|
|
|
|
- run: npm ci
|
|
|
|
- run: npm run bundle
|
|
|
|
- name: Store bundle artifact
|
2022-05-16 16:16:16 +03:00
|
|
|
uses: actions/upload-artifact@v3
|
2022-01-05 18:11:05 +03:00
|
|
|
with:
|
|
|
|
name: bundles-cli
|
|
|
|
path: bundles
|
|
|
|
retention-days: 1
|
2021-10-11 12:40:56 +03:00
|
|
|
unit-tests:
|
2022-01-05 18:11:05 +03:00
|
|
|
needs: [check-version-cli]
|
2021-10-11 18:23:26 +03:00
|
|
|
if: needs.check-version-cli.outputs.changed == 'true'
|
2021-10-11 12:40:56 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-05-16 16:16:16 +03:00
|
|
|
- uses: actions/checkout@v3
|
2022-05-12 15:31:35 +03:00
|
|
|
- run: npm ci && npm ci --prefix cli
|
2022-01-05 18:11:05 +03:00
|
|
|
- run: npm test
|
2021-10-11 12:40:56 +03:00
|
|
|
e2e-tests:
|
2022-01-05 18:11:05 +03:00
|
|
|
needs: [bundle]
|
2021-10-11 12:40:56 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-05-16 16:16:16 +03:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-05 18:11:05 +03:00
|
|
|
- run: npm ci
|
|
|
|
- name: Download bundled artifact
|
2022-05-16 16:16:16 +03:00
|
|
|
uses: actions/download-artifact@v3
|
2022-01-05 18:11:05 +03:00
|
|
|
with:
|
|
|
|
name: bundles-cli
|
|
|
|
path: bundles
|
|
|
|
- run: npm run e2e
|
2021-10-11 12:40:56 +03:00
|
|
|
bundle-cli:
|
2022-01-05 18:11:05 +03:00
|
|
|
needs: [check-version-cli]
|
2021-10-11 18:23:26 +03:00
|
|
|
if: needs.check-version-cli.outputs.changed == 'true'
|
2021-10-11 12:40:56 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-05-16 16:16:16 +03:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-node@v3
|
2021-10-11 12:40:56 +03:00
|
|
|
- name: Cache node modules
|
2022-05-16 16:16:16 +03:00
|
|
|
uses: actions/cache@v3
|
2021-10-11 12:40:56 +03:00
|
|
|
with:
|
|
|
|
path: ~/.npm
|
|
|
|
key: npm-${{ hashFiles('package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
npm-${{ hashFiles('package-lock.json') }}
|
|
|
|
npm-
|
|
|
|
- name: Install dependencies
|
|
|
|
run: npm ci
|
|
|
|
- name: Bundle
|
|
|
|
run: npm run compile:cli
|
|
|
|
- name: Store bundle artifact
|
2022-05-16 16:16:16 +03:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-10-11 12:40:56 +03:00
|
|
|
with:
|
|
|
|
name: cli
|
|
|
|
path: cli
|
|
|
|
retention-days: 1
|
|
|
|
check-version-cli:
|
|
|
|
name: Check Version
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
changed: ${{ steps.check.outputs.changed }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2022-05-16 16:16:16 +03:00
|
|
|
uses: actions/checkout@v3
|
2021-10-11 12:40:56 +03:00
|
|
|
- name: Set up Node.js
|
2022-05-16 16:16:16 +03:00
|
|
|
uses: actions/setup-node@v3
|
2021-10-11 12:40:56 +03:00
|
|
|
- name: Check if version has been updated
|
|
|
|
id: check
|
|
|
|
uses: EndBug/version-check@v2.0.1
|
|
|
|
with:
|
|
|
|
file-name: ./cli/package.json
|
|
|
|
file-url: https://unpkg.com/redoc-cli/package.json
|
|
|
|
static-checking: localIsNew
|
|
|
|
publish-cli:
|
2021-10-11 18:23:26 +03:00
|
|
|
needs: [bundle-cli, unit-tests, e2e-tests]
|
2021-10-11 12:40:56 +03:00
|
|
|
if: needs.check-version-cli.outputs.changed == 'true'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-05-16 16:16:16 +03:00
|
|
|
- uses: actions/setup-node@v3
|
2021-10-11 12:40:56 +03:00
|
|
|
with:
|
2022-01-05 18:11:05 +03:00
|
|
|
node-version: '14.x'
|
2021-10-11 21:00:54 +03:00
|
|
|
registry-url: 'https://registry.npmjs.org'
|
2022-05-16 16:16:16 +03:00
|
|
|
- uses: actions/checkout@v3
|
2021-10-11 12:40:56 +03:00
|
|
|
- name: Download cli bundled artifact
|
2022-05-16 16:16:16 +03:00
|
|
|
uses: actions/download-artifact@v3
|
2021-10-11 12:40:56 +03:00
|
|
|
with:
|
|
|
|
name: cli
|
|
|
|
path: cli
|
|
|
|
- name: Cache node modules
|
2022-05-16 16:16:16 +03:00
|
|
|
uses: actions/cache@v3
|
2021-10-11 12:40:56 +03:00
|
|
|
with:
|
|
|
|
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
|
|
|
|
key: npm-${{ hashFiles('package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
npm-${{ hashFiles('package-lock.json') }}
|
|
|
|
npm-
|
|
|
|
- name: Publish to NPM
|
|
|
|
run: cd cli/ && npm publish
|
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|