Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 166 additions & 0 deletions .github/workflows/release-fellowapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: release-fellowapp
# Build platform-specific .node binaries and publish the Fellow fork to
# GitHub Packages as @fellowapp/lightningcss + @fellowapp/lightningcss-<platform>.
# Triggered manually via workflow_dispatch.
on:
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: aarch64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
strip: strip -x

name: build-${{ matrix.target }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: dtolnay/rust-toolchain@stable
- run: rustup target add ${{ matrix.target }}
- uses: bahmutov/npm-install@v1.8.32
- name: Build release
run: yarn build-release
env:
RUST_TARGET: ${{ matrix.target }}
- name: Strip debug symbols
if: ${{ matrix.strip }}
run: ${{ matrix.strip }} *.node
- uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: '*.node'

build-apple-silicon:
name: build-apple-silicon
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: dtolnay/rust-toolchain@stable
- run: rustup target add aarch64-apple-darwin
- uses: bahmutov/npm-install@v1.8.32
- name: Build release
run: yarn build-release
env:
RUST_TARGET: aarch64-apple-darwin
JEMALLOC_SYS_WITH_LG_PAGE: 14
- name: Strip debug symbols
run: strip -x *.node
- uses: actions/upload-artifact@v4
with:
name: bindings-aarch64-apple-darwin
path: '*.node'

build-linux:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
strip: strip
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
setup: npm install --global yarn@1
- target: aarch64-unknown-linux-gnu
strip: llvm-strip
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
- target: aarch64-linux-android
strip: llvm-strip
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
- target: armv7-unknown-linux-gnueabihf
strip: llvm-strip
image: ghcr.io/napi-rs/napi-rs/nodejs-rust@sha256:c22284b2d79092d3e885f64ede00f6afdeb2ccef7e2b6e78be52e7909091cd57
- target: aarch64-unknown-linux-musl
image: ghcr.io/napi-rs/napi-rs/nodejs-rust@sha256:78c9ab1f117f8c535b93c4b91a2f19063dda6e4dba48a6187df49810625992c1
strip: aarch64-linux-musl-strip
- target: x86_64-unknown-linux-musl
image: ghcr.io/napi-rs/napi-rs/nodejs-rust@sha256:78c9ab1f117f8c535b93c4b91a2f19063dda6e4dba48a6187df49810625992c1
strip: strip

name: build-${{ matrix.target }}
runs-on: ubuntu-latest
container:
image: ${{ matrix.image }}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: dtolnay/rust-toolchain@stable
- name: Setup Android NDK
if: ${{ matrix.target == 'aarch64-linux-android' }}
run: |
sudo apt update && sudo apt install unzip -y
cd /tmp
wget -q https://dl.google.com/android/repository/android-ndk-r28-linux.zip -O /tmp/ndk.zip
unzip ndk.zip
- name: Setup cross compile toolchain
if: ${{ matrix.setup }}
run: ${{ matrix.setup }}
- run: rustup target add ${{ matrix.target }}
- uses: bahmutov/npm-install@v1.8.32
- name: Build release
run: yarn build-release
env:
ANDROID_NDK_LATEST_HOME: /tmp/android-ndk-r28
RUST_TARGET: ${{ matrix.target }}
- name: Strip debug symbols
if: ${{ matrix.strip }}
run: ${{ matrix.strip }} *.node
- uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: '*.node'

release:
runs-on: ubuntu-latest
name: Publish to GitHub Packages
needs:
- build
- build-linux
- build-apple-silicon
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://npm.pkg.github.com
scope: '@fellowapp'
- uses: bahmutov/npm-install@v1.8.32
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Show artifacts
run: ls -R artifacts
- name: Build npm packages
run: node scripts/build-npm.js
- name: Publish platform packages
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for pkg in npm/*; do
echo "Publishing $pkg..."
(cd "$pkg" && npm publish)
done
- name: Publish main package
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Publishing @fellowapp/lightningcss..."
npm publish
2 changes: 1 addition & 1 deletion node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (process.platform === 'linux') {

let native;
try {
native = require(`lightningcss-${parts.join('-')}`);
native = require(`@fellowapp/lightningcss-${parts.join('-')}`);
} catch (err) {
native = require(`../lightningcss.${parts.join('-')}.node`);
}
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "lightningcss",
"version": "1.32.0",
"name": "@fellowapp/lightningcss",
"version": "1.32.0-fellow.0",
"license": "MPL-2.0",
"description": "A CSS parser, transformer, and minifier written in Rust",
"description": "Fellow fork of lightningcss — a CSS parser, transformer, and minifier written in Rust, with css-loader/postcss-modules-compatible scoped-name hashing.",
"main": "node/index.js",
"types": "node/index.d.ts",
"exports": {
Expand All @@ -16,15 +16,16 @@
"types": false
},
"publishConfig": {
"access": "public"
"access": "public",
"registry": "https://npm.pkg.github.com"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"repository": {
"type": "git",
"url": "https://github.com/parcel-bundler/lightningcss.git"
"url": "https://github.com/fellowapp/lightningcss.git"
},
"engines": {
"node": ">= 12.0.0"
Expand Down Expand Up @@ -66,7 +67,7 @@
"parcel": "^2.8.2",
"patch-package": "^6.5.0",
"path-browserify": "^1.0.1",
"postcss": "^8.3.11",
"postcss": "^8.5.10",
"posthtml-include": "^1.7.4",
"posthtml-markdownit": "^1.3.1",
"posthtml-prism": "^1.0.4",
Expand All @@ -79,7 +80,7 @@
"uvu": "^0.5.6"
},
"resolutions": {
"lightningcss": "link:."
"@fellowapp/lightningcss": "link:."
},
"scripts": {
"prepare": "patch-package",
Expand Down
59 changes: 3 additions & 56 deletions scripts/build-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const sysToNodePlatform = {
};

let optionalDependencies = {};
let cliOptionalDependencies = {};

try {
fs.mkdirSync(dir + '/npm');
Expand All @@ -78,38 +77,17 @@ for (let triple of triples) {
}

buildNode(triple.name, cpu, os, libc, t);
buildCLI(triple.name, cpu, os, libc, t);
}

pkg.optionalDependencies = optionalDependencies;
fs.writeFileSync(`${dir}/package.json`, JSON.stringify(pkg, false, 2) + '\n');

let cliPkg = { ...pkg };
cliPkg.name += '-cli';
cliPkg.bin = {
'lightningcss': 'lightningcss'
};
delete cliPkg.main;
delete cliPkg.napi;
delete cliPkg.exports;
delete cliPkg.devDependencies;
delete cliPkg.targets;
delete cliPkg.types;
cliPkg.files = ['lightningcss', 'postinstall.js'];
cliPkg.optionalDependencies = cliOptionalDependencies;
cliPkg.scripts = {
postinstall: 'node postinstall.js'
};

fs.writeFileSync(`${dir}/cli/package.json`, JSON.stringify(cliPkg, false, 2) + '\n');
fs.copyFileSync(`${dir}/README.md`, `${dir}/cli/README.md`);
fs.copyFileSync(`${dir}/LICENSE`, `${dir}/cli/LICENSE`);

function buildNode(triple, cpu, os, libc, t) {
let name = `lightningcss.${t}.node`;

let pkg2 = { ...pkg };
pkg2.name += '-' + t;
// Each platform package is published as @fellowapp/lightningcss-<platform>.
pkg2.name = '@fellowapp/lightningcss-' + t;
pkg2.os = [os];
pkg2.cpu = [cpu];
if (libc) {
Expand All @@ -133,38 +111,7 @@ function buildNode(triple, cpu, os, libc, t) {
} catch (err) { }
fs.writeFileSync(`${dir}/npm/node-${t}/package.json`, JSON.stringify(pkg2, false, 2) + '\n');
fs.copyFileSync(`${dir}/artifacts/bindings-${triple}/${name}`, `${dir}/npm/node-${t}/${name}`);
fs.writeFileSync(`${dir}/npm/node-${t}/README.md`, `This is the ${triple} build of lightningcss. See https://github.com/parcel-bundler/lightningcss for details.`);
fs.writeFileSync(`${dir}/npm/node-${t}/README.md`, `This is the ${triple} build of @fellowapp/lightningcss. See https://github.com/fellowapp/lightningcss for details.`);
fs.copyFileSync(`${dir}/LICENSE`, `${dir}/npm/node-${t}/LICENSE`);
}

function buildCLI(triple, cpu, os, libc, t) {
let binary = os === 'win32' ? 'lightningcss.exe' : 'lightningcss';
let pkg2 = { ...pkg };
pkg2.name += '-cli-' + t;
pkg2.os = [os];
pkg2.cpu = [cpu];
pkg2.files = [binary];
if (libc) {
pkg2.libc = [libc];
}
delete pkg2.main;
delete pkg2.exports;
delete pkg2.napi;
delete pkg2.devDependencies;
delete pkg2.dependencies;
delete pkg2.optionalDependencies;
delete pkg2.targets;
delete pkg2.scripts;
delete pkg2.types;

cliOptionalDependencies[pkg2.name] = pkg.version;

try {
fs.mkdirSync(dir + '/npm/cli-' + t);
} catch (err) { }
fs.writeFileSync(`${dir}/npm/cli-${t}/package.json`, JSON.stringify(pkg2, false, 2) + '\n');
fs.copyFileSync(`${dir}/artifacts/bindings-${triple}/${binary}`, `${dir}/npm/cli-${t}/${binary}`);
fs.chmodSync(`${dir}/npm/cli-${t}/${binary}`, 0o755); // Ensure execute bit is set.
fs.writeFileSync(`${dir}/npm/cli-${t}/README.md`, `This is the ${triple} build of lightningcss-cli. See https://github.com/parcel-bundler/lightningcss for details.`);
fs.copyFileSync(`${dir}/LICENSE`, `${dir}/npm/cli-${t}/LICENSE`);
}
Loading
Loading