Update SWC and Build WASM #23
This file contains 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: 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@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | |
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@488876a65a2ca38b7eb05e9086166337087f5323 # v1.10.0 | |
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@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.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@488876a65a2ca38b7eb05e9086166337087f5323 # v1.10.0 | |
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 |