Merge branch 'main' of github.com:scalar/scalar #7
This file contains hidden or 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: CI | |
# This workflow runs on: | |
# 1. Push events to the main branch | |
# 2. Pull request events | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: null | |
env: | |
NODE_OPTIONS: '--max_old_space_size=8192' | |
TURBO_CACHE_DIR: '${{ github.ref_name }}/.turbo' | |
jobs: | |
harden_security: | |
name: Check used GitHub Actions | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Ensure all Actions are pinned to a Commit SHA | |
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@fc87bb5b5a97953d987372e74478de634726b3e5 | |
# Initial build. | |
# We only build the packages and integrations as everything else depends on them | |
# turbo is cached to sticky disk and pnpm is cached in the standard actions cache | |
build: | |
runs-on: blacksmith-8vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [20, 22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: './{packages,integrations}/**' | |
docker: | |
name: Build and Tag Docker Image | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Check whether the Dockerfile or any of its contents were modified | |
id: changed-files | |
uses: step-security/changed-files@95b56dadb92a30ca9036f16423fd3c088a71ee94 | |
with: | |
files_yaml: | | |
api_reference_docker: | |
- integrations/docker/** | |
api_reference_docker_version: | |
- integrations/docker/package.json | |
- if: steps.changed-files.outputs.api_reference_docker_any_changed == 'true' | |
name: Get version from package.json | |
id: package-version | |
working-directory: integrations/docker | |
run: echo "VERSION=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT" | |
- if: steps.changed-files.outputs.api_reference_docker_any_changed == 'true' | |
name: Build @scalar/api-reference | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: 22 | |
packages: '@scalar/api-reference...' | |
- if: steps.changed-files.outputs.api_reference_docker_any_changed == 'true' | |
name: Copy JavaScript asset from @scalar/api-reference | |
working-directory: integrations/docker | |
run: pnpm copy:standalone | |
- if: steps.changed-files.outputs.api_reference_docker_any_changed == 'true' | |
name: Compress static assets | |
working-directory: integrations/docker | |
run: pnpm compress | |
- if: steps.changed-files.outputs.api_reference_docker_any_changed == 'true' | |
name: Build Docker image | |
uses: useblacksmith/build-push-action@574eb0ee0b59c6a687ace24192f0727dfb65d6d7 | |
with: | |
context: integrations/docker | |
file: integrations/docker/Dockerfile | |
load: true | |
tags: | | |
scalarapi/api-reference:latest | |
scalarapi/api-reference:${{ steps.package-version.outputs.VERSION }} | |
- if: steps.changed-files.outputs.api_reference_docker_any_changed == 'true' | |
name: Scan for vulnerabilities | |
uses: aquasecurity/trivy-action@76071ef0d7ec797419534a183b498b4d6366cf37 | |
with: | |
scan-type: 'image' | |
image-ref: 'scalarapi/api-reference:latest' | |
format: 'table' | |
ignore-unfixed: true | |
vuln-type: 'os,library' | |
severity: 'CRITICAL,HIGH' | |
- if: startsWith(github.event.head_commit.message, 'RELEASING:') && steps.changed-files.outputs.api_reference_docker_version_any_changed == 'true' | |
name: Log in to DockerHub | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 | |
with: | |
# Username of your Docker account | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
# https://app.docker.com/settings/personal-access-tokens | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- if: startsWith(github.event.head_commit.message, 'RELEASING:') && steps.changed-files.outputs.api_reference_docker_version_any_changed == 'true' | |
name: Build and Push Docker image | |
uses: useblacksmith/build-push-action@574eb0ee0b59c6a687ace24192f0727dfb65d6d7 | |
with: | |
context: integrations/docker | |
file: integrations/docker/Dockerfile | |
push: true | |
# With ARM | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
tags: | | |
scalarapi/api-reference:latest | |
scalarapi/api-reference:${{ steps.package-version.outputs.VERSION }} | |
format: | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: useblacksmith/setup-node@65c6ca86fdeb0ab3d85e78f57e4f6a7e4780b391 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- name: Install dev dependencies | |
run: pnpm install --dev | |
# You might ask why we need a GitHub Action to install Biome. | |
# Well, it's because GHA throws an error when it's run through pnpm.# > Error: Cannot find module '@biomejs/cli-linux-x64/biome' | |
- name: Setup Biome | |
uses: biomejs/setup-biome@454fa0d884737805f48d7dc236c1761a0ac3cc13 | |
with: | |
version: 1.9.4 | |
- name: Lint code | |
run: biome lint --diagnostic-level=error | |
- name: Check formatting | |
run: pnpm prettier --check . && biome format | |
build-examples: | |
needs: [build] | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: './examples/**' | |
types: | |
needs: [build] | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: './{packages,integrations}/**' | |
- name: Check types | |
run: pnpm types:check | |
test-packages: | |
needs: [build] | |
runs-on: blacksmith-4vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [20, 22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build packages | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: './packages/**' | |
- name: Start test servers | |
run: pnpm script run test-servers & | |
- name: Run tests | |
run: | | |
pnpm script wait -p 5051 5052 && | |
pnpm test:packages:ci | |
test-integrations: | |
needs: [build] | |
runs-on: blacksmith-4vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [20, 22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build packages | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: './integrations/**' | |
- name: Run tests | |
run: pnpm test:integrations:ci | |
test-proxy-server: | |
needs: [build] | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
go-version: ['1.21'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Setup Go | |
uses: actions/setup-go@fa96338abe5531f6e34c5cc0bbe28c1a533d5505 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Run tests for the proxy server (Go) | |
run: cd projects/proxy-scalar-com && go test -v | |
stats: | |
needs: [build] | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build @scalar/api-reference | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: '@scalar/api-reference' | |
- name: Send bundle stats and build information to RelativeCI | |
uses: relative-ci/agent-action@26338b6cffd0b7eef7136ebed5ff3ddc22cbe113 | |
with: | |
key: ${{ secrets.RELATIVE_CI_KEY }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
webpackStatsFile: ./packages/api-reference/dist/browser/webpack-stats.json | |
npm-publish: | |
if: github.ref == 'refs/heads/main' | |
runs-on: beefcake | |
timeout-minutes: 15 | |
# Avoid running this job in parallel: | |
# `changesets/action` creates/updates the release branch, which shouldn't happen in parallel. | |
# npm publish also shouldn't happen in parallel. | |
concurrency: | |
group: npm-publish | |
cancel-in-progress: false | |
permissions: | |
contents: write | |
id-token: write | |
needs: | |
[harden_security, build, format, types, test-packages, test-integrations] | |
strategy: | |
matrix: | |
node-version: [22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build | |
uses: ./.github/actions/build | |
with: | |
node-version: ${{ matrix.node-version }} | |
use-github-runner: 'true' | |
- name: Git Status | |
run: git status | |
- name: Stash changes | |
run: git stash | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308 | |
with: | |
# The pull request title. | |
title: 'chore: release' | |
# The command to update version, edit CHANGELOG, read and delete changesets. | |
version: 'pnpm changeset version' | |
# The commit message to use. | |
commit: 'chore: version packages' | |
# The command to use to build and publish packages | |
publish: 'pnpm -r publish --access public' | |
env: | |
# https://github.com/settings/tokens/new | |
# Expiration: No expiration | |
# Select: repo.* | |
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | |
# https://www.npmjs.com/settings/YOUR_ACCOUNT_HANDLE/tokens/granular-access-tokens/new | |
# Custom Expiration: 01-01-2100 | |
# Permissions: Read and Write | |
# Select packages: @scalar | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
bust-cdn-cache: | |
needs: [npm-publish] | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
steps: | |
- name: Bust CDN cache | |
uses: fjogeleit/http-request-action@23ad54bcd1178fcff6a0d17538fa09de3a7f0a4d | |
with: | |
url: 'https://purge.jsdelivr.net/npm/@scalar/api-reference' | |
method: 'GET' | |
todesktop-build: | |
if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'RELEASING:') | |
runs-on: blacksmith-4vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
needs: [build, test-packages] | |
strategy: | |
matrix: | |
node-version: [22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: './{packages,integrations,projects}/**' | |
- name: Git Status | |
run: git status | |
- name: Stash changes | |
run: git stash | |
- name: Check whether appFiles are there | |
run: ls -R ./projects/scalar-app/dist | |
- if: startsWith(github.event.head_commit.message, 'RELEASING:') | |
name: Check whether there's a new version of the app | |
id: changed-files | |
uses: step-security/changed-files@95b56dadb92a30ca9036f16423fd3c088a71ee94 | |
with: | |
files_yaml: | | |
api_client_app: | |
- projects/scalar-app/package.json | |
- if: steps.changed-files.outputs.api_client_app_any_changed == 'true' | |
name: Check whether appFiles are there | |
run: ls -R ./projects/scalar-app/dist | |
- if: steps.changed-files.outputs.api_client_app_any_changed == 'true' | |
name: Build in the toDesktop cloud | |
run: pnpm --filter scalar-app todesktop:build:ci | |
env: | |
TODESKTOP_EMAIL: ${{ secrets.TODESKTOP_EMAIL }} | |
TODESKTOP_ACCESS_TOKEN: ${{ secrets.TODESKTOP_ACCESS_TOKEN }} | |
deploy-api-client: | |
# Only run this job for PRs from the same repository | |
if: github.ref == 'refs/heads/main' || github.event.pull_request.head.repo.full_name == github.repository | |
needs: [build] | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Check which files were touched | |
id: changed-files | |
uses: step-security/changed-files@95b56dadb92a30ca9036f16423fd3c088a71ee94 | |
with: | |
files_yaml: | | |
api_client: | |
- projects/client-scalar-com/** | |
- packages/api-client/** | |
- if: steps.changed-files.outputs.api_client_any_changed == 'true' | |
name: Build | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: 'client-scalar-com...' | |
- if: steps.changed-files.outputs.api_client_any_changed == 'true' | |
name: Deploy to client.staging.scalar.com (staging) | |
id: deploy-client-staging | |
uses: cloudflare/wrangler-action@7a5f8bbdfeedcde38e6777a50fe685f89259d4ca | |
with: | |
command: pages deploy dist --project-name=client-staging | |
workingDirectory: projects/client-scalar-com | |
# 1) Log in to the Cloudflare dashboard. | |
# 2) Select Workers & Pages. | |
# 3) See the Account ID in the right sidebar. | |
# Read more: https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/ | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
# 1) Go to https://dash.cloudflare.com/profile/api-tokens | |
# 2) Create a token with the following permissions: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
- if: github.ref != 'refs/heads/main' && steps.deploy-client-staging.outputs.deployment-url | |
name: Add Cloudflare Preview URL to the PR | |
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 | |
with: | |
message: | | |
**Cloudflare Preview for the API Client** | |
${{ steps.deploy-client-staging.outputs.deployment-url }} | |
comment_tag: 'cloudflare-preview' | |
- if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'RELEASING:') | |
name: Check for new @scalar/api-client version | |
id: client-version | |
uses: step-security/changed-files@95b56dadb92a30ca9036f16423fd3c088a71ee94 | |
with: | |
files_yaml: | | |
api_client: | |
- packages/api-client/** | |
- if: steps.client-version.outputs.api_client_any_changed == 'true' | |
name: Deploy to client.scalar.com (production) | |
id: deploy-client-production | |
uses: cloudflare/wrangler-action@7a5f8bbdfeedcde38e6777a50fe685f89259d4ca | |
with: | |
command: pages deploy dist --project-name=client | |
workingDirectory: projects/client-scalar-com | |
# 1) Log in to the Cloudflare dashboard. | |
# 2) Select Workers & Pages. | |
# 3) See the Account ID in the right sidebar. | |
# Read more: https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/ | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
# 1) Go to https://dash.cloudflare.com/profile/api-tokens | |
# 2) Create a token with the following permissions: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
deploy-examples: | |
# Main Branch or PR from the same repository | |
if: | | |
github.ref == 'refs/heads/main' || ( | |
github.event_name == 'pull_request' && | |
github.event.pull_request.head.repo.full_name == github.repository && !contains(github.actor, '[bot]') | |
) | |
needs: [build] | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
strategy: | |
matrix: | |
node-version: [22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Generate new DEPLOY_ID | |
run: echo "DEPLOY_ID=$(uuidgen)" >> "$GITHUB_ENV" && echo $DEPLOY_ID | |
- name: Build | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: '@scalar-examples/web...' | |
env: | |
DEPLOY_ID: ${{ env.DEPLOY_ID }} | |
- name: Install Netlify CLI | |
run: pnpm install -g netlify | |
- name: Deploy to Netlify | |
run: | | |
netlify deploy --dir "./examples/web/dist" \ | |
--message "Deployed from GitHub (${{ env.DEPLOY_ID }})" \ | |
--site ${{ vars.NETLIFY_SITE_ID_PREVIEW }} \ | |
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \ | |
--filter @scalar-examples/web \ | |
--alias=${{env.DEPLOY_ID}} | |
- name: Add Netlify Preview URL to the PR | |
if: github.event_name == 'pull_request' | |
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 | |
with: | |
message: | | |
**Preview Examples** | |
https://${{env.DEPLOY_ID}}--scalar-deploy-preview.netlify.app | |
comment_tag: 'netlify-preview' | |
deploy-components: | |
# Skip for forks and bot PRs | |
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !contains(github.actor, '[bot]') | |
needs: [build] | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [22] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Check which files were touched | |
id: changed-files | |
uses: step-security/changed-files@95b56dadb92a30ca9036f16423fd3c088a71ee94 | |
with: | |
files_yaml: | | |
components: | |
- packages/components/** | |
- if: steps.changed-files.outputs.components_any_changed == 'true' | |
name: Generate new DEPLOY_ID | |
run: echo "DEPLOY_ID=$(uuidgen)" >> "$GITHUB_ENV" && echo $DEPLOY_ID | |
- if: steps.changed-files.outputs.components_any_changed == 'true' | |
name: Build | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: ${{ matrix.node-version }} | |
packages: './packages/**' | |
env: | |
DEPLOY_ID: ${{ env.DEPLOY_ID }} | |
- if: steps.changed-files.outputs.components_any_changed == 'true' | |
name: Install Netlify CLI | |
run: pnpm install -g netlify | |
- if: steps.changed-files.outputs.components_any_changed == 'true' | |
name: Build storybook | |
run: pnpm --filter components build:storybook | |
- if: steps.changed-files.outputs.components_any_changed == 'true' | |
name: Deploy Storybook to Netlify (Preview) | |
run: | | |
netlify deploy --dir "./packages/components/storybook-static" \ | |
--message "Deployed from GitHub (${{ env.DEPLOY_ID }})" \ | |
--site ${{ vars.NETLIFY_SITE_ID_COMPONENTS }} \ | |
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \ | |
--filter @scalar/components \ | |
--alias=${{env.DEPLOY_ID}} | |
- if: steps.changed-files.outputs.components_any_changed == 'true' | |
name: Add Netlify Preview URL to the PR | |
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 | |
with: | |
message: | | |
**Preview Storybook** | |
https://${{env.DEPLOY_ID}}--scalar-components.netlify.app | |
comment_tag: 'storybook-preview' | |
aspnetcore-build-test: | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
needs: [build] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build @scalar/api-reference | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: 22 | |
packages: '@scalar/api-reference...' | |
- name: Copy JavaScript asset from @scalar/api-reference | |
working-directory: integrations/aspnetcore | |
run: pnpm copy:standalone | |
- name: Compress static assets | |
working-directory: integrations/aspnetcore | |
run: pnpm compress | |
- name: Setup .NET | |
uses: actions/setup-dotnet@0f55b457d2a9ef0a7d0c7a2dd7cac6b1647730a4 | |
with: | |
dotnet-version: | | |
9.x | |
8.x | |
- name: Restore dependencies | |
working-directory: integrations/aspnetcore | |
run: dotnet restore | |
- name: Build solution | |
working-directory: integrations/aspnetcore | |
run: dotnet build -c Release --no-restore | |
- name: Test solution | |
working-directory: integrations/aspnetcore | |
run: dotnet test -c Release --no-build | |
aspire-build-test: | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
needs: [build] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Build @scalar/api-reference | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: 22 | |
packages: '@scalar/api-reference...' | |
- name: Copy JavaScript asset from @scalar/api-reference | |
working-directory: integrations/aspire | |
run: pnpm copy:standalone | |
- name: Setup .NET | |
uses: actions/setup-dotnet@0f55b457d2a9ef0a7d0c7a2dd7cac6b1647730a4 | |
with: | |
dotnet-version: | | |
9.x | |
8.x | |
- name: Restore dependencies | |
working-directory: integrations/aspire | |
run: dotnet restore | |
- name: Build solution | |
working-directory: integrations/aspire | |
run: dotnet build -c Release --no-restore | |
- name: Test solution | |
working-directory: integrations/aspire | |
run: dotnet test -c Release --no-build | |
aspnetcore-publish: | |
if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'RELEASING:') | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
# We don't want to run `nuget push` (publishing to NuGet) in parallel. | |
concurrency: | |
group: aspnetcore-publish | |
cancel-in-progress: false | |
needs: | |
[ | |
harden_security, | |
build, | |
format, | |
types, | |
test-packages, | |
test-integrations, | |
aspnetcore-build-test, | |
] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Git Status | |
run: git status | |
- name: Stash changes | |
run: git stash | |
- name: Check for new NuGet package version | |
id: changed-files | |
uses: step-security/changed-files@95b56dadb92a30ca9036f16423fd3c088a71ee94 | |
with: | |
files_yaml: | | |
aspnetcore_package: | |
- integrations/aspnetcore/package.json | |
- if: steps.changed-files.outputs.aspnetcore_package_any_changed == 'true' | |
name: Extract version from package.json | |
working-directory: integrations/aspnetcore | |
run: | | |
VERSION=$(node -p "require('./package.json').version") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- if: steps.changed-files.outputs.aspnetcore_package_any_changed == 'true' | |
name: Build @scalar/api-reference | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: 22 | |
packages: '@scalar/api-reference...' | |
- if: steps.changed-files.outputs.aspnetcore_package_any_changed == 'true' | |
name: Copy JavaScript asset from @scalar/api-reference | |
working-directory: integrations/aspnetcore | |
run: pnpm copy:standalone | |
- if: steps.changed-files.outputs.aspnetcore_package_any_changed == 'true' | |
name: Compress static assets | |
working-directory: integrations/aspnetcore | |
run: pnpm compress | |
- if: steps.changed-files.outputs.aspnetcore_package_any_changed == 'true' | |
name: Setup .NET | |
uses: actions/setup-dotnet@0f55b457d2a9ef0a7d0c7a2dd7cac6b1647730a4 | |
with: | |
dotnet-version: | | |
9.x | |
8.x | |
- if: steps.changed-files.outputs.aspnetcore_package_any_changed == 'true' | |
name: Restore dependencies | |
working-directory: integrations/aspnetcore | |
run: dotnet restore | |
- if: steps.changed-files.outputs.aspnetcore_package_any_changed == 'true' | |
name: Pack packages | |
working-directory: integrations/aspnetcore | |
run: | | |
dotnet pack src/Scalar.AspNetCore -c Release --no-restore --output nupkgs /p:Version=$VERSION | |
dotnet pack src/Scalar.AspNetCore.Microsoft -c Release --no-restore --output nupkgs /p:Version=$VERSION | |
dotnet pack src/Scalar.AspNetCore.Swashbuckle -c Release --no-restore --output nupkgs /p:Version=$VERSION | |
- if: steps.changed-files.outputs.aspnetcore_package_any_changed == 'true' | |
name: Publish packages | |
working-directory: integrations/aspnetcore | |
run: dotnet nuget push nupkgs/*.nupkg -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json | |
aspire-publish: | |
if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'RELEASING:') | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
concurrency: | |
group: aspire-publish | |
cancel-in-progress: false | |
needs: | |
[ | |
harden_security, | |
build, | |
format, | |
types, | |
test-packages, | |
test-integrations, | |
aspire-build-test, | |
] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Git Status | |
run: git status | |
- name: Stash changes | |
run: git stash | |
- name: Check for Aspire package.json changes | |
id: changed-files | |
uses: step-security/changed-files@95b56dadb92a30ca9036f16423fd3c088a71ee94 | |
with: | |
files_yaml: | | |
aspire_package: | |
- integrations/aspire/package.json | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Extract version from package.json | |
working-directory: integrations/aspire | |
run: | | |
VERSION=$(node -p "require('./package.json').version") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Build @scalar/api-reference | |
uses: ./.github/actions/build-blacksmith | |
with: | |
node-version: 22 | |
packages: '@scalar/api-reference...' | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Copy JavaScript asset from @scalar/api-reference | |
working-directory: integrations/aspire | |
run: pnpm copy:standalone | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Log in to DockerHub | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Setup Buildx | |
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Build and push Aspire Docker image | |
uses: useblacksmith/build-push-action@574eb0ee0b59c6a687ace24192f0727dfb65d6d7 | |
with: | |
context: integrations/aspire | |
file: integrations/aspire/src/Scalar.Aspire.Service/Dockerfile | |
push: true | |
# With ARM | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
tags: | | |
scalarapi/aspire-api-reference:latest | |
scalarapi/aspire-api-reference:${{ env.VERSION }} | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Set version in Constants.cs | |
working-directory: integrations/aspire | |
run: | | |
sed -i 's/ImageTag = "latest"/ImageTag = "'$VERSION'"/' src/Scalar.Aspire/Constants.cs | |
cat src/Scalar.Aspire/Constants.cs | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Setup .NET | |
uses: actions/setup-dotnet@0f55b457d2a9ef0a7d0c7a2dd7cac6b1647730a4 | |
with: | |
dotnet-version: | | |
9.x | |
8.x | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Restore dependencies | |
working-directory: integrations/aspire/src/Scalar.Aspire | |
run: dotnet restore | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Pack Scalar.Aspire NuGet package | |
working-directory: integrations/aspire/src/Scalar.Aspire | |
run: dotnet pack -c Release --no-restore --output nupkgs /p:Version=$VERSION | |
- if: steps.changed-files.outputs.aspire_package_any_changed == 'true' | |
name: Publish Scalar.Aspire NuGet package | |
working-directory: integrations/aspire/src/Scalar.Aspire | |
run: dotnet nuget push nupkgs/*.nupkg -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json | |
fastapi-build-test: | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
needs: [build] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Setup Python | |
uses: actions/setup-python@532b046aaf352bab5717122cc0ea52b7f12266a3 | |
with: | |
python-version: '3.11' | |
- name: Install build dependencies | |
working-directory: integrations/fastapi | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build Python package | |
working-directory: integrations/fastapi | |
run: python -m build | |
- name: Run tests | |
working-directory: integrations/fastapi | |
run: python run_tests.py | |
fastapi-publish: | |
if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'RELEASING:') | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
timeout-minutes: 10 | |
concurrency: | |
group: fastapi-publish | |
cancel-in-progress: false | |
needs: | |
[ | |
harden_security, | |
build, | |
format, | |
types, | |
test-packages, | |
test-integrations, | |
fastapi-build-test, | |
] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f | |
- name: Check for FastAPI integration changes | |
id: changed-files | |
uses: step-security/changed-files@95b56dadb92a30ca9036f16423fd3c088a71ee94 | |
with: | |
files_yaml: | | |
fastapi_integration: | |
- integrations/fastapi/package.json | |
- if: steps.changed-files.outputs.fastapi_integration_any_changed == 'true' | |
name: Setup Python | |
uses: actions/setup-python@532b046aaf352bab5717122cc0ea52b7f12266a3 | |
with: | |
python-version: '3.11' | |
- if: steps.changed-files.outputs.fastapi_integration_any_changed == 'true' | |
name: Install build dependencies | |
working-directory: integrations/fastapi | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine | |
- if: steps.changed-files.outputs.fastapi_integration_any_changed == 'true' | |
name: Build Python package | |
working-directory: integrations/fastapi | |
run: python -m build | |
- if: steps.changed-files.outputs.fastapi_integration_any_changed == 'true' | |
name: Publish to PyPI | |
working-directory: integrations/fastapi | |
run: | | |
twine upload --username __token__ --password ${{ secrets.PYPI_TOKEN }} dist/* |