🚀 Release packages #110
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: 🚀 Release packages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: 'Branch to release' | |
| required: true | |
| default: 'main' | |
| dry_run: | |
| type: boolean | |
| description: 'Run the workflow in dry-run mode' | |
| required: false | |
| default: false | |
| npm_tag: | |
| type: choice | |
| description: 'Specify npm tag' | |
| required: true | |
| default: 'alpha' | |
| options: | |
| - alpha | |
| - beta | |
| - rc | |
| - canary | |
| - latest | |
| extension_type: | |
| type: choice | |
| description: 'Specify the release type of extension' | |
| required: true | |
| default: pre-release | |
| options: | |
| - official | |
| - pre-release | |
| to_release: | |
| description: 'Packages to release' | |
| type: choice | |
| required: true | |
| options: | |
| - all | |
| - npm | |
| - extension | |
| permissions: | |
| contents: read | |
| jobs: | |
| publish-npm: | |
| if: ${{ inputs.to_release == 'all' || inputs.to_release == 'npm' }} | |
| name: ${{ inputs.dry_run == true && 'Dry Run - NPM Packages' || 'Publish NPM Packages' }} | |
| needs: [build] | |
| runs-on: ubuntu-22.04 | |
| environment: release | |
| permissions: | |
| # For push git tags | |
| contents: write | |
| # For Trusted Publish | |
| id-token: write | |
| steps: | |
| - name: Show dry-run status | |
| run: | | |
| if [ "${{ inputs.dry_run }}" = "true" ]; then | |
| echo "🏃♂️ RUNNING IN DRY-RUN MODE - No packages will be published to npm registry" | |
| echo "==================================================" | |
| else | |
| echo "🚀 LIVE MODE - Packages will be published to npm registry" | |
| echo "========================================" | |
| fi | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 1 | |
| ref: ${{ github.event.inputs.branch }} | |
| submodules: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: '24' | |
| # Update npm to the latest version to enable OIDC | |
| - name: Update npm | |
| run: | | |
| npm install -g npm@latest | |
| npm --version | |
| - name: Install pnpm | |
| run: corepack enable | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Download Artifact | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: binaries | |
| - name: Move binaries | |
| uses: ./.github/actions/move-artifacts | |
| - name: Publish npm packages | |
| if: ${{ inputs.dry_run == false }} | |
| run: | | |
| pnpm -r publish --no-git-checks --tag ${{ github.event.inputs.npm_tag }} --publish-branch ${{ github.event.inputs.branch }} | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "github-actions" | |
| version=$(jq -r .version package.json) | |
| git tag v$version -m "v$version" | |
| git push origin v$version | |
| publish-extension-vscode: | |
| if: ${{ inputs.to_release == 'all' || inputs.to_release == 'extension' }} | |
| name: ${{ inputs.dry_run == true && 'Dry Run - VSCode Extensions' || 'Publish VSCode Extensions' }} | |
| needs: [build] | |
| runs-on: rspack-ubuntu-22.04-large | |
| environment: release | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 1 | |
| ref: ${{ github.event.inputs.branch }} | |
| submodules: true | |
| - name: Setup Node.js | |
| uses: ./.github/actions/setup-node | |
| - name: Download Artifact | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: binaries | |
| - name: Build and publish to Microsoft VS Code Marketplace | |
| env: | |
| VSCE_PAT: ${{ secrets.RSLINT_VSCE_PAT }} | |
| run: | | |
| if [ "${{ inputs.dry_run }}" = "true" ]; then | |
| echo "🚀 DRY RUN: Building and packaging VS Code extension without publishing..." | |
| if [ "${{ inputs.extension_type }}" = "pre-release" ]; then | |
| pnpm publish:vsce --prerelease --dry-run | |
| else | |
| pnpm publish:vsce --dry-run | |
| fi | |
| else | |
| if [ "${{ inputs.extension_type }}" = "pre-release" ]; then | |
| pnpm publish:vsce --prerelease | |
| else | |
| pnpm publish:vsce | |
| fi | |
| fi | |
| - name: Upload VSCE artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| path: packages/vscode-extension/rslint-*.vsix | |
| publish-extension-open-vsx: | |
| if: ${{ inputs.to_release == 'all' || inputs.to_release == 'extension' }} | |
| name: ${{ inputs.dry_run == true && 'Dry Run - Open VSX Extensions' || 'Publish Open VSX Extensions' }} | |
| needs: [build] | |
| runs-on: ubuntu-22.04 | |
| environment: release | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 1 | |
| ref: ${{ github.event.inputs.branch }} | |
| submodules: true | |
| - name: Setup Node | |
| uses: ./.github/actions/setup-node | |
| - name: Download Artifact | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: binaries | |
| - name: Build and publish to Open VSX Registry | |
| env: | |
| OVSX_PAT: ${{ secrets.RSLINT_OVSX_PAT }} | |
| run: | | |
| if [ "${{ inputs.dry_run }}" = "true" ]; then | |
| echo "🚀 DRY RUN: Building and packaging for Open VSX Registry without publishing..." | |
| if [ "${{ inputs.extension_type }}" = "pre-release" ]; then | |
| pnpm publish:ovsx --prerelease --dry-run | |
| else | |
| pnpm publish:ovsx --dry-run | |
| fi | |
| else | |
| if [ "${{ inputs.extension_type }}" = "pre-release" ]; then | |
| pnpm publish:ovsx --prerelease | |
| else | |
| pnpm publish:ovsx | |
| fi | |
| fi | |
| check: | |
| name: Test | |
| if: ${{ inputs.dry_run == false }} | |
| needs: [build] | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| include: | |
| - goos: linux | |
| goarch: amd64 | |
| node_arch: x64 | |
| node_os: linux | |
| runs-on: rspack-ubuntu-22.04-large | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 1 | |
| ref: ${{ github.event.inputs.branch }} | |
| submodules: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: '24' | |
| - name: Setup Go | |
| uses: ./.github/actions/setup-go | |
| with: | |
| go-version: 1.25.0 | |
| cache-name: ${{ matrix.node_os }}-${{ matrix.node_arch }} | |
| - name: Install pnpm | |
| run: corepack enable | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Download Artifact | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: binaries | |
| - name: Move binaries | |
| uses: ./.github/actions/move-artifacts | |
| - name: Format code | |
| run: pnpm format:check | |
| - name: Build | |
| run: pnpm run build | |
| - name: TypeCheck | |
| run: pnpm typecheck | |
| - name: Lint code | |
| run: pnpm lint | |
| - name: Install xvfb and dependencies | |
| if: ${{ runner.os == 'Linux' && runner.environment == 'self-hosted' }} | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y xvfb libxss1 libgtk-3-0 libgconf-2-4 libnss3 libxrandr2 libasound2 libpangocairo-1.0-0 libatk1.0-0 libcairo-gobject2 libgtk-3-0 libgdk-pixbuf2.0-0 | |
| - name: Test on Linux | |
| run: xvfb-run -a npm run test | |
| build: | |
| env: | |
| GOMAXPROCS: 8 | |
| name: Build-Binaries | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - goos: darwin | |
| goarch: amd64 | |
| node_arch: x64 | |
| node_os: darwin | |
| - goos: darwin | |
| goarch: arm64 | |
| node_arch: arm64 | |
| node_os: darwin | |
| - goos: linux | |
| goarch: amd64 | |
| node_arch: x64 | |
| node_os: linux | |
| - goos: linux | |
| goarch: arm64 | |
| node_arch: arm64 | |
| node_os: linux | |
| - goos: windows | |
| goarch: amd64 | |
| node_arch: x64 | |
| node_os: win32 | |
| - goos: windows | |
| goarch: arm64 | |
| node_arch: arm64 | |
| node_os: win32 | |
| runs-on: rspack-ubuntu-22.04-large | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 1 | |
| ref: ${{ github.event.inputs.branch }} | |
| submodules: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: '24' | |
| - name: Setup Go | |
| uses: ./.github/actions/setup-go | |
| with: | |
| go-version: 1.25.0 | |
| cache-name: ${{ matrix.node_os }}-${{ matrix.node_arch }} | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: true | |
| - name: Install pnpm | |
| run: corepack enable | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Go Build rslint | |
| run: | | |
| GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${{ matrix.node_os }}-${{ matrix.node_arch }}-rslint ./cmd/rslint | |
| - name: Go Build tsgo | |
| run: | | |
| GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${{ matrix.node_os }}-${{ matrix.node_arch }}-tsgo ./cmd/tsgo | |
| - name: Upload rslint artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: ${{ matrix.node_os }}-${{ matrix.node_arch }}-rslint | |
| path: ${{ matrix.node_os }}-${{ matrix.node_arch }}-rslint | |
| - name: Upload tsgo artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: ${{ matrix.node_os }}-${{ matrix.node_arch }}-tsgo | |
| path: ${{ matrix.node_os }}-${{ matrix.node_arch }}-tsgo | |
| - name: Build typescript-go | |
| run: | | |
| cd typescript-go | |
| npm ci | |
| npm run build | |
| # Remove tsgo binary from typescript-go build, we use our own ./cmd/tsgo build | |
| rm -f built/local/tsgo built/local/tsgo.exe | |
| - name: Upload typescript-go built artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: ${{ matrix.node_os }}-${{ matrix.node_arch }}-tsgo-built | |
| path: typescript-go/built |