Skip to content

Update SWC and Build WASM #2

Update SWC and Build WASM

Update SWC and Build WASM #2

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
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
- 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 <github-bot@iojs.org>
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 <github-bot@iojs.org>
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