-
Notifications
You must be signed in to change notification settings - Fork 15
86 lines (74 loc) · 3.6 KB
/
update-swc.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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 <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
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@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
- 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 <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