changeset #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
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: Get version | |
id: get_version | |
run: | | |
value="$(cat packages/cli/package.json | jq -r '.version')" | |
echo "value=$value" >> "$GITHUB_OUTPUT" | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
redocly/cli | |
ghcr.io/redocly/cli | |
tags: | | |
${{ steps.get_version.outputs.value }} | |
latest | |
- 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 | |
continue-on-error: true | |
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 | |
continue-on-error: true | |
run: | | |
expected_version="$(cat packages/cli/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" | |
fi | |
redocly lint https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml --format=stylish | |
redocly bundle https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml -o bundled.json | |
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 | |
continue-on-error: true | |
run: | | |
expected_version="$(cat packages/cli/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" | |
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 --output=bundled.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: Send the Release Message to Slack | |
runs-on: ubuntu-latest | |
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: Write release message to file | |
run: node scripts/write-release-message.js | |
- name: Send to a Slack channel | |
id: slack | |
uses: slackapi/slack-github-action@v1.25.0 | |
with: | |
channel-id: C019K52TC0L #releases | |
payload-file-path: './output/release-message.json' | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.RELEASES_SLACK_BOT_TOKEN }} |