Skip to content

Update SWC and Build WASM #16

Update SWC and Build WASM

Update SWC and Build WASM #16

Workflow file for this run

name: Update SWC and Build WASM
on:
workflow_dispatch:
inputs:
swc_version:
description: 'SWC version to update to (e.g., 1.7.5)'
required: false
schedule:
- cron: '0 0 * * 1' # Every Monday at 00:00 UTC
env:
NODE_VERSION: lts/*
jobs:
update-swc:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
- name: Check if SWC update is required
id: version-check
run: |
CURRENT_SWC_VERSION=$(cat lib/package.json | jq -r '.version')
if [[ -n "${{ github.event.inputs.swc_version }}" ]]; then
NEW_SWC_VERSION="${{ github.event.inputs.swc_version }}"
else
NEW_SWC_VERSION=$(npm view @swc/core version)
fi
echo "CURRENT_SWC_VERSION=$CURRENT_SWC_VERSION" >> $GITHUB_OUTPUT
echo "NEW_SWC_VERSION=$NEW_SWC_VERSION" >> $GITHUB_OUTPUT
if [[ "$CURRENT_SWC_VERSION" != "$NEW_SWC_VERSION" ]]; then
echo "UPDATE_REQUIRED=true" >> $GITHUB_OUTPUT
else
echo "UPDATE_REQUIRED=false" >> $GITHUB_OUTPUT
fi
- name: Update SWC
if: steps.version-check.outputs.UPDATE_REQUIRED == 'true'
run: ./tools/update-swc.sh
- name: Create Pull Request with first commit
if: steps.version-check.outputs.UPDATE_REQUIRED == 'true'
uses: gr2m/create-or-update-pull-request-action@86ec1766034c8173518f61d2075cc2a173fb8c97 # v1.9.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
author: Node.js GitHub Bot <[email protected]>
title: "chore(deps): update SWC to v${{ github.event.inputs.swc_version || steps.version-check.outputs.NEW_SWC_VERSION }}"
branch: "chore/update-swc-${{ github.event.inputs.swc_version || steps.version-check.outputs.NEW_SWC_VERSION }}"
commit-message: "chore: update swc to v${{ github.event.inputs.swc_version || steps.version-check.outputs.NEW_SWC_VERSION }}"
path: deps
body: |
This PR updates SWC to v${{ github.event.inputs.swc_version || steps.version-check.outputs.NEW_SWC_VERSION }}.
View the [SWC changelog](https://github.com/swc-project/swc/releases/tag/v${{ github.event.inputs.swc_version || steps.version-check.outputs.NEW_SWC_VERSION }}) for more information.
- name: Set up Docker
if: steps.version-check.outputs.UPDATE_REQUIRED == 'true'
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
- name: Build WASM
if: steps.version-check.outputs.UPDATE_REQUIRED == 'true'
run: node ./tools/build-wasm.js
- name: Create second commit
if: steps.version-check.outputs.UPDATE_REQUIRED == 'true'
uses: gr2m/create-or-update-pull-request-action@86ec1766034c8173518f61d2075cc2a173fb8c97 # v1.9.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
author: Node.js GitHub Bot <[email protected]>
branch: "chore/update-swc-${{ github.event.inputs.swc_version || steps.version-check.outputs.NEW_SWC_VERSION }}"
commit-message: "chore: build wasm from swc v${{ github.event.inputs.swc_version || steps.version-check.outputs.NEW_SWC_VERSION }}"
path: lib