Update SWC and Build WASM #33
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
persist-credentials: false | |
- name: Set up Node.js | |
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | |
- 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@b65137ca591da0b9f43bad7b24df13050ea45d1b # v1.10.1 | |
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 | |
update-pull-request-title-and-body: true | |
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@b65137ca591da0b9f43bad7b24df13050ea45d1b # v1.10.1 | |
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 |