Skip to content

Publish

Publish #330

Workflow file for this run

name: "Publish"
env:
CI: 1
# 7 GiB by default on GitHub, setting to 6 GiB
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
NODE_OPTIONS: --max-old-space-size=6144
GIT_AUTHOR_NAME: "SWC Bot"
GIT_AUTHOR_EMAIL: "[email protected]"
GIT_COMMITTER_NAME: "SWC Bot"
GIT_COMMITTER_EMAIL: "[email protected]"
# https://github.com/actions/setup-node/issues/899#issuecomment-1819151595
SKIP_YARN_COREPACK_CHECK: 1
on:
workflow_dispatch:
inputs:
version:
description: "Version to publish"
required: true
type: string
skipBuild:
description: "Skip build. Used to debug swc-ecosystem-ci."
required: false
type: boolean
default: false
onlyNightly:
description: "Publish only nightly"
required: false
type: boolean
default: false
allowBreakingWasm:
description: "Allow breaking changes in wasm"
required: false
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
cargo-bump:
name: "Bump crates"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
if: github.event_name == 'workflow_dispatch'
with:
profile: minimal
- name: Install cargo-edit
if: github.event_name == 'workflow_dispatch'
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- run: cargo bump
if: github.event_name == 'workflow_dispatch'
continue-on-error: true
- uses: webfactory/[email protected]
if: github.event_name == 'workflow_dispatch'
with:
ssh-private-key: ${{ secrets.SWC_BOT_SSH }}
- name: Push bump commit
if: github.event_name == 'workflow_dispatch'
run: |
git push [email protected]:swc-project/swc.git --no-verify
publish-cargo:
name: "Publish cargo crates"
runs-on: ubuntu-latest
needs:
- cargo-bump
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
if: github.event_name == 'workflow_dispatch'
- uses: actions-rs/toolchain@v1
if: github.event_name == 'workflow_dispatch'
with:
profile: minimal
- name: Install cargo-edit
if: github.event_name == 'workflow_dispatch'
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Install cargo-edit
if: github.event_name == 'workflow_dispatch'
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Update constant of swc_core
if: github.event_name == 'workflow_dispatch'
run: npx ts-node .github/bot/src/cargo/update-constants.ts
- name: Publish crates
if: github.event_name == 'workflow_dispatch'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo mono publish --no-verify
determine-nightly-version:
name: "Determine nightly version"
runs-on: ubuntu-latest
outputs:
version: ${{ steps.determine-nightly-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- name: Determine nightly version
id: determine-nightly-version
run: |
npx ts-node .github/bot/src/nightly-version.ts ${{ github.event.inputs.version }} >> $GITHUB_OUTPUT
git-tag-nightly:
name: "Git tag nightly"
runs-on: ubuntu-latest
needs:
- publish-cargo
- determine-nightly-version
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/tag-git-release
with:
version: ${{ needs.determine-nightly-version.outputs.version }}
ssh-private-key: ${{ secrets.SWC_BOT_SSH }}
publish-npm-nightly:
name: "Publish ${{ matrix.package }}@${{ needs.determine-nightly-version.outputs.version }}"
strategy:
fail-fast: false
matrix:
package:
- core
- html
needs:
- git-tag-nightly
- publish-cargo
- determine-nightly-version
uses: ./.github/workflows/publish-npm-package.yml
secrets: inherit
with:
package: ${{ matrix.package }}
version: ${{ needs.determine-nightly-version.outputs.version }}
buildCli: true
skipBuild: ${{ inputs.skipBuild || false }}
skipPublishing: ${{ github.event_name == 'pull_request' }}
run-ecosystem-ci-with-nightly:
name: "Test nightly using ecosystem CI"
needs:
- determine-nightly-version
- publish-npm-nightly
uses: ./.github/workflows/ecosystem-ci.yml
with:
version: ${{ needs.determine-nightly-version.outputs.version }}
mode: "passing"
suites: '["_"]'
allowBreakingWasm: ${{ inputs.allowBreakingWasm || false }}
git-tag-stable:
name: "Git tag stable"
runs-on: ubuntu-latest
needs:
- publish-cargo
- run-ecosystem-ci-with-nightly
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/tag-git-release
with:
version: ${{ inputs.version }}
ssh-private-key: ${{ secrets.SWC_BOT_SSH }}
publish-npm-stable:
name: "Publish ${{ matrix.package }}@${{ inputs.version || 'stable' }} to npm"
strategy:
fail-fast: false
matrix:
package:
- core
- html
needs:
- publish-cargo
- run-ecosystem-ci-with-nightly
- git-tag-stable
uses: ./.github/workflows/publish-npm-package.yml
secrets: inherit
with:
package: ${{ matrix.package }}
version: ${{ inputs.version }}
buildCli: true
skipBuild: ${{ inputs.skipBuild || inputs.onlyNightly || false }}
skipPublishing: ${{ github.event_name == 'pull_request' }}