Skip to content

Commit

Permalink
feat(all): 🎸 增加 js-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Maidang1 authored Sep 25, 2024
1 parent b5e4446 commit d951ebc
Show file tree
Hide file tree
Showing 7 changed files with 4,182 additions and 233 deletions.
45 changes: 10 additions & 35 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ jobs:
set -e &&
unset CC_x86_64_unknown_linux_gnu &&
unset CC &&
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --target x86_64-unknown-linux-gnu --abi linux-x64-gnu
done
pnpm --filter "{packages/**}[origin/main]" --filter "{rust-plugins/**}[origin/main]" --sequential build --target x86_64-unknown-linux-gnu --abi linux-x64-gnu
- os: ubuntu-latest
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
abi: linux-x64-musl
Expand All @@ -30,10 +27,7 @@ jobs:
set -e &&
unset CC_x86_64_unknown_linux_musl &&
unset CC &&
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --target x86_64-unknown-linux-musl --abi linux-x64-musl
done
pnpm --filter "{packages/**}[origin/main]" --filter "{rust-plugins/**}[origin/main]" --sequential build --target x86_64-unknown-linux-musl --abi linux-x64-musl
- os: windows-latest
abi: win32-x64-msvc
- os: macos-latest
Expand All @@ -48,21 +42,16 @@ jobs:
build: |
export CARGO_PROFILE_RELEASE_LTO=false
cargo install cargo-xwin --locked
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --target i686-pc-windows-msvc --abi win32-ia32-msvc --cargo-flags="--no-default-features"
done
pnpm --filter "{packages/**}[origin/main]" --filter "{rust-plugins/**}[origin/main]" --sequential build --target i686-pc-windows-msvc --abi win32-ia32-msvc --cargo-flags="--no-default-features"
- os: windows-latest
abi: win32-arm64-msvc
target: aarch64-pc-windows-msvc
build: |
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=256
export CARGO_PROFILE_RELEASE_LTO=false
cargo install cargo-xwin --locked
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --target aarch64-pc-windows-msvc --abi win32-arm64-msvc --cargo-flags="--no-default-features"
done
pnpm --filter "{packages/**}[origin/main]" --filter "{rust-plugins/**}[origin/main]" --sequential build --target aarch64-pc-windows-msvc --abi win32-arm64-msvc --cargo-flags="--no-default-features"
# linux
- os: ubuntu-latest
abi: linux-arm64-musl
Expand All @@ -76,25 +65,14 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- name: Cache rust artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: rust-build-${{ matrix.settings.abi }}

- name: Get changed packages
id: get_changed_packages
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
$RUST_CHANGED_PACKAGES = git diff --name-only HEAD HEAD~1 | findstr /R /C:"^rust-plugins/" /C:"^packages/" | for /F "tokens=2 delims=/" %i in ('sort /unique') do @echo %i
$RUST_CHANGED_PACKAGES = echo %RUST_CHANGED_PACKAGES:~0,-1%
echo "rust_changed_packages=$RUST_CHANGED_PACKAGES" >> $env:GITHUB_ENV
else
RUST_ORIGIN_CHANGED_PACKAGES=$(git diff --name-only HEAD HEAD~1 | grep -E '^(rust-plugins|packages)/' | awk -F'/' '{print $2}' | sort -u)
RUST_CHANGED_PACKAGES=$(echo "$RUST_CHANGED_PACKAGES" | paste -sd " " -)
echo "rust_changed_packages=$RUST_CHANGED_PACKAGES" >> "$GITHUB_ENV"
fi
- uses: actions/setup-node@v3
with:
node-version: 18
Expand All @@ -119,11 +97,8 @@ jobs:
run: ${{ matrix.settings.build }}
- name: Default Build
if: ${{ !matrix.settings.docker && !matrix.settings.build }}
run: >-
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --abi ${{ matrix.settings.abi }} ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }}
done
run: |
pnpm --filter "{packages/**}[origin/main]" --filter "{rust-plugins/**}[origin/main]" --sequential build --abi ${{ matrix.settings.abi }} ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }}
shell: bash
- name: Build
if: ${{ !matrix.settings.docker && matrix.settings.build }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ on:

jobs:
call-rust-build:
uses: ./.github/workflows/plugin-build.yaml
uses: ./.github/workflows/build.yaml
call-js-build:
uses: ./.github/workflows/js-plugin-build.yaml
13 changes: 4 additions & 9 deletions .github/workflows/js-plugin-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- name: Setup Node
uses: actions/setup-node@v3
with:
Expand All @@ -29,14 +31,7 @@ jobs:
- name: pnpm install
run: pnpm install --frozen-lockfile

- name: Get changed packages
id: get_changed_packages
run: |
JS_CHANGED_PACKAGES=$(git diff --name-only HEAD HEAD~1 | grep -E '^(js-plugins)/' | awk -F'/' '{print $2}' | sort -u)
echo "js_changed_packages=$JS_CHANGED_PACKAGES" >> "$GITHUB_ENV"
- name: Build Packages
run: |
for package in $js_changed_packages; do
pnpm --filter "@farmfe/js-plugin-$package" build
done
pnp
pnpm --filter "{js-plugins/**}[origin/main]" build
173 changes: 0 additions & 173 deletions .github/workflows/plugin-build.yaml

This file was deleted.

17 changes: 5 additions & 12 deletions .github/workflows/release-js-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
fetch-depth: 2
token: ${{ secrets.GH_TOKEN }}

- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- name: Update Master
run: |
git pull --force --no-tags origin main:main
Expand Down Expand Up @@ -53,21 +56,11 @@ jobs:
- name: pnpm install
run: pnpm install --frozen-lockfile

- name: Get changed packages
id: get_changed_packages
run: |
JS_CHANGED_PACKAGES=$(git diff --name-only HEAD HEAD~1 | grep -E '^(js-plugins)/' | awk -F'/' '{print $2}' | sort -u)
echo "js_changed_packages=$JS_CHANGED_PACKAGES" >> "$GITHUB_ENV"
- name: Build Packages
run: |
for package in $js_changed_packages; do
pnpm --filter "@farmfe/js-plugin-$package" build
done
pnpm --filter "{js-plugins}[origin/main]" build
- name: Release and Publish Packages
run: |
for package in $js_changed_packages; do
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} && npm config set access public && pnpm --filter "@farmfe/js-plugin-$package" publish
done
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} && npm config set access public && pnpm --filter "{js-plugins}[origin/main]" publish --no-git-checks
8 changes: 5 additions & 3 deletions .github/workflows/release-rust-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 2
- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- name: Setup Node.js 18.x
uses: actions/setup-node@v3
Expand Down Expand Up @@ -53,6 +55,6 @@ jobs:
run: npm install -g pnpm@9.1.0 && pnpm i --frozen-lockfile

- name: Publish to npm
run: for package in ${{ env.rust_changed_packages }}; do
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} && npm config set access public && pnpm --filter "@farmfe/plugin-$package" publish --no-git-checks
done
run: |
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} && npm config set access public && pnpm --filter "{rust-plugins/**}[origin/main]" --filtr "{packages/**}[origin/main]" publish --no-git-checks
Loading

0 comments on commit d951ebc

Please sign in to comment.