mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 04:21:09 +00:00
195 lines
6.1 KiB
YAML
195 lines
6.1 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
cache: 'npm'
|
|
- run: npm ci
|
|
- 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:
|
|
needs: [release]
|
|
if: needs.release.outputs.published == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 20
|
|
cache: 'npm'
|
|
- run: npm ci
|
|
|
|
- name: Bundle into single file
|
|
run: npm run webpack-bundle
|
|
|
|
- name: Upload to AWS S3 bucket
|
|
run: npm run upload
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
AWS_S3_PATH: openapi-cli-dist
|
|
|
|
- name: Upload to AWS sandbox S3 bucket
|
|
run: npm run upload
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_SANDBOX_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SANDBOX_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
AWS_S3_PATH: redocly-sandbox-openapi-cli-dist
|
|
|
|
dockerhub:
|
|
needs: [release]
|
|
if: needs.release.outputs.published == 'true'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Docker meta
|
|
id: docker_meta
|
|
uses: crazy-max/ghaction-docker-meta@v1
|
|
with:
|
|
images: |
|
|
redocly/cli
|
|
ghcr.io/redocly/cli
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
|
|
post-release-smoke-checks:
|
|
needs:
|
|
- release
|
|
- deploy
|
|
- dockerhub
|
|
name: Test released version
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-node@v3
|
|
- name: Install CLI from npm
|
|
run: npm i -g @redocly/cli@latest
|
|
- name: Test version from NPM
|
|
run: |
|
|
expected_version="$(cat package.json | jq -r '.version')"
|
|
actual_version="$(redocly --version)"
|
|
if [[ $expected_version == $actual_version ]]; then
|
|
echo "The version is correct. Actual version: $actual_version"
|
|
else
|
|
echo "The version is incorrect. Expected: $expected_version, actual: $actual_version"
|
|
exit 1
|
|
fi
|
|
redocly lint https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
|
|
redocly bundle https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
|
|
redocly build-docs https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
|
|
- name: Pull docker image
|
|
run: docker pull redocly/cli:latest
|
|
- name: Test docker image
|
|
run: |
|
|
expected_version="$(cat package.json | jq -r '.version')"
|
|
actual_version="$(docker run --rm redocly/cli --version)"
|
|
if [[ $expected_version == $actual_version ]]; then
|
|
echo "The version is correct. Actual version: $actual_version"
|
|
else
|
|
echo "The version is incorrect. Expected: $expected_version, actual: $actual_version"
|
|
exit 1
|
|
fi
|
|
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 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 }}
|