mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
Previously...
- Smoke tests on Windows suddenly started failing
- This was because `npx oxlint@${VER}` should be `npx oxlint@$env:VER`
on Windows
- Tried to fix this by using `bash` by default
- But `bash` does not exist on Alpine 👈🏻 Current status
- Fixed by using the default shell again, but splitting the Windows job
248 lines
7.8 KiB
YAML
248 lines
7.8 KiB
YAML
name: Release Oxfmt
|
|
|
|
permissions: {}
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- npm/oxfmt/package.json # Please only commit this file, so we don't need to wait for all the other CI jobs to finish.
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
check:
|
|
name: Check version
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version_changed: ${{ steps.check.outputs.version_changed }}
|
|
version: ${{ steps.check.outputs.version }}
|
|
steps:
|
|
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
|
|
- uses: ./.github/actions/check-version
|
|
id: check
|
|
with:
|
|
file-name: npm/oxfmt/package.json
|
|
file-url: https://unpkg.com/oxfmt@latest/package.json
|
|
|
|
build:
|
|
needs: check
|
|
if: needs.check.outputs.version_changed == 'true'
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
code-target: win32-x64
|
|
build-oxfmt-args: ""
|
|
|
|
- os: windows-latest
|
|
target: aarch64-pc-windows-msvc
|
|
code-target: win32-arm64
|
|
build-oxfmt-args: ""
|
|
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
code-target: linux-x64-gnu
|
|
build-oxfmt-args: --use-napi-cross
|
|
|
|
- os: ubuntu-latest
|
|
target: aarch64-unknown-linux-gnu
|
|
code-target: linux-arm64-gnu
|
|
build-oxfmt-args: --use-napi-cross
|
|
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-musl
|
|
code-target: linux-x64-musl
|
|
build-oxfmt-args: -x
|
|
|
|
- os: ubuntu-latest
|
|
target: aarch64-unknown-linux-musl
|
|
code-target: linux-arm64-musl
|
|
build-oxfmt-args: -x
|
|
|
|
- os: macos-latest
|
|
target: x86_64-apple-darwin
|
|
code-target: darwin-x64
|
|
build-oxfmt-args: ""
|
|
|
|
- os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
code-target: darwin-arm64
|
|
build-oxfmt-args: ""
|
|
|
|
name: Package ${{ matrix.code-target }}
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
env:
|
|
OXC_VERSION: ${{ needs.check.outputs.version }}
|
|
steps:
|
|
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
|
|
|
|
- name: Install cross
|
|
uses: taiki-e/install-action@81ee1d48d9194cdcab880cbdc7d36e87d39874cb # v2.62.45
|
|
with:
|
|
tool: cross
|
|
|
|
- name: Rust Cache
|
|
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
|
|
# Please do not set a cache for release builds; they are evicted before they can be re-used, yet they consume significant cache storage before eviction.
|
|
|
|
- name: Add Rust Target
|
|
run: rustup target add ${{ matrix.target }}
|
|
|
|
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
|
|
|
|
- uses: goto-bus-stop/setup-zig@abea47f85e598557f500fa1fd2ab7464fcb39406 # v2.2.1
|
|
if: ${{ contains(matrix.target, 'musl') }}
|
|
with:
|
|
version: 0.13.0
|
|
|
|
- name: Build oxfmt
|
|
working-directory: apps/oxfmt
|
|
run: pnpm run build-napi-release --target ${{ matrix.target }} ${{ matrix.build-oxfmt-args }}
|
|
shell: bash
|
|
env:
|
|
TARGET_CC: clang # for mimalloc
|
|
|
|
# The binaries are zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss
|
|
- name: Archive Binaries
|
|
if: runner.os == 'Windows'
|
|
# Windows `.node` files have `-msvc` postfix e.g. `oxfmt.win32-x64-msvc.node`. Remove the postfix.
|
|
run: |
|
|
OXFMT_BIN_SRC_NAME=oxfmt.${{ matrix.code-target }}-msvc.node
|
|
OXFMT_BIN_NAME=oxfmt.${{ matrix.code-target }}.node
|
|
mv apps/oxfmt/src-js/$OXFMT_BIN_SRC_NAME $OXFMT_BIN_NAME
|
|
7z a oxfmt-${{ matrix.code-target }}.zip $OXFMT_BIN_NAME
|
|
|
|
# The binaries are zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss
|
|
- name: Archive Binaries
|
|
if: runner.os != 'Windows'
|
|
run: |
|
|
OXFMT_BIN_NAME=oxfmt.${{ matrix.code-target }}.node
|
|
mv apps/oxfmt/src-js/$OXFMT_BIN_NAME .
|
|
tar czf oxfmt-${{ matrix.code-target }}.tar.gz $OXFMT_BIN_NAME
|
|
|
|
- name: Upload Binary
|
|
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
with:
|
|
if-no-files-found: error
|
|
name: binaries-${{ matrix.code-target }}
|
|
path: |
|
|
*.zip
|
|
*.tar.gz
|
|
|
|
publish:
|
|
name: Publish
|
|
needs: [check, build]
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write # for softprops/action-gh-release@v1.3.1
|
|
id-token: write # for `pnpm publish --provenance`
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
with:
|
|
fetch-depth: 0 # for changelog
|
|
persist-credentials: false
|
|
|
|
- uses: oxc-project/setup-rust@f03aedf4620c1d3aa169a2510e24787d362bbe0b # v1.0.8
|
|
with:
|
|
restore-cache: false
|
|
tools: cargo-release-oxc
|
|
|
|
- name: Run
|
|
id: run
|
|
run: |
|
|
mkdir -p target
|
|
cargo release-oxc changelog --release oxfmt
|
|
{
|
|
echo 'CHANGELOG<<EOF'
|
|
cat ./target/OXC_CHANGELOG
|
|
echo EOF
|
|
} >> $GITHUB_OUTPUT
|
|
|
|
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
|
|
with:
|
|
merge-multiple: true
|
|
|
|
- name: Unzip
|
|
uses: montudor/action-zip@0852c26906e00f8a315c704958823928d8018b28 # v1.0.0
|
|
with:
|
|
args: unzip -qq *.zip -d .
|
|
|
|
- name: Untar
|
|
run: ls *.gz | xargs -i tar xf {}
|
|
|
|
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
|
|
|
|
- name: Generate oxfmt JS build
|
|
working-directory: apps/oxfmt
|
|
run: pnpm run build-js
|
|
|
|
- name: Generate npm packages
|
|
run: |
|
|
node npm/oxfmt/scripts/generate-packages.js
|
|
cat npm/oxfmt/package.json
|
|
for package in npm/oxfmt*; do cat $package/package.json ; echo ; done
|
|
|
|
- run: npm install -g npm@latest # For trusted publishing support
|
|
|
|
- name: Publish npm packages as latest
|
|
# NOTE: The trailing slash on $package/ changes it to publishing the directory
|
|
run: |
|
|
for package in npm/oxfmt*
|
|
do
|
|
pnpm publish $package/ --provenance --access public --no-git-checks
|
|
echo '----'
|
|
done
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
|
|
with:
|
|
body: ${{ steps.run.outputs.CHANGELOG }}
|
|
prerelease: true
|
|
draft: false
|
|
name: oxfmt v${{ needs.check.outputs.version }}
|
|
tag_name: oxfmt_v${{ needs.check.outputs.version }}
|
|
target_commitish: ${{ github.sha }}
|
|
|
|
- name: wait 3 minutes for smoke test
|
|
run: sleep 180s
|
|
|
|
smoke:
|
|
needs: [check, publish]
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: windows-latest
|
|
is-windows: true
|
|
- os: ubuntu-latest
|
|
- os: ubuntu-latest
|
|
container: node:18-alpine # musl
|
|
- os: macos-latest
|
|
name: Smoke Test ${{ matrix.os }} ${{ matrix.container }}
|
|
runs-on: ${{ matrix.os }}
|
|
container: ${{ matrix.container }}
|
|
steps:
|
|
- run: touch test.js
|
|
|
|
- name: Test (Unix)
|
|
if: ${{ !matrix.is-windows }}
|
|
env:
|
|
OXFMT_VERSION: ${{ needs.check.outputs.version }}
|
|
run: |
|
|
ldd --version || true
|
|
npx oxfmt@${OXFMT_VERSION} ./test.js
|
|
|
|
- name: Test (Windows)
|
|
if: ${{ matrix.is-windows }}
|
|
env:
|
|
OXFMT_VERSION: ${{ needs.check.outputs.version }}
|
|
run: npx oxfmt@$env:OXFMT_VERSION ./test.js
|