Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(all): 增加 js-plugins #74

Merged
merged 7 commits into from
Sep 25, 2024
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 20 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
set -e &&
unset CC_x86_64_unknown_linux_gnu &&
unset CC &&
pnpm --filter "[HEAD^]" --sequential build --target x86_64-unknown-linux-gnu --abi linux-x64-gnu
pnpm --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 @@ -26,7 +26,7 @@ jobs:
set -e &&
unset CC_x86_64_unknown_linux_musl &&
unset CC &&
pnpm --filter "[HEAD^]" --sequential build --target x86_64-unknown-linux-musl --abi linux-x64-musl
pnpm --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 @@ -41,15 +41,16 @@ jobs:
build: |
export CARGO_PROFILE_RELEASE_LTO=false
cargo install cargo-xwin --locked
pnpm --filter "[HEAD^]" --sequential build --target i686-pc-windows-msvc --abi win32-ia32-msvc --cargo-flags="--no-default-features"
pnpm --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
pnpm --filter "[HEAD^]" --sequential build --target aarch64-pc-windows-msvc --abi win32-arm64-msvc --cargo-flags="--no-default-features"
pnpm --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 @@ -63,10 +64,14 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/main:refs/remotes/origin/main

- name: Cache rust artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: rust-build-${{ matrix.settings.abi }}

- uses: actions/setup-node@v3
with:
node-version: 18
Expand All @@ -91,8 +96,8 @@ jobs:
run: ${{ matrix.settings.build }}
- name: Default Build
if: ${{ !matrix.settings.docker && !matrix.settings.build }}
run: >-
pnpm --filter "[HEAD^]" --sequential build --abi ${{ matrix.settings.abi }} ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }}
run: |
pnpm --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 All @@ -102,53 +107,53 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-dsv
path: ./packages/dsv/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/dsv/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin react-components
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-react-components
path: ./packages/react-components/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/react-components/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin virtual
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-virtual
path: ./packages/virtual/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/virtual/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin yaml
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-yaml
path: ./packages/yaml/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/yaml/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin strip
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-strip
path: ./packages/strip/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/strip/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin image
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-image
path: ./packages/image/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/image/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin url
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-url
path: ./packages/url/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/url/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin icons
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-icons
path: ./packages/icons/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/icons/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin auto-import
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-auto-import
path: ./packages/auto-import/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/auto-import/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ on:

jobs:
call-rust-build:
uses: ./.github/workflows/plugin-build.yaml
if: github.event_name == 'pull_request' && (contains(github.event.pull_request.title, 'rust-plugins') || contains(github.event.pull_request.title, 'all'))
uses: ./.github/workflows/build.yaml
call-js-build:
if: github.event_name == 'pull_request' && (contains(github.event.pull_request.title, 'js-plugins') || contains(github.event.pull_request.title, 'all'))
uses: ./.github/workflows/js-plugin-build.yaml
35 changes: 35 additions & 0 deletions .github/workflows/js-plugin-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PR build plugins
on: workflow_call

jobs:
build:
runs-on: ubuntu-latest
name: release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/main:refs/remotes/origin/main
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Enable Corepack
id: pnpm-setup
run: |
corepack enable

- name: Initliaze .npmrc
run: >
echo -e "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}\n$(cat .npmrc)" > .npmrc
&& cat -n .npmrc

- name: pnpm install
run: pnpm install --frozen-lockfile

- name: Build Packages
run: |
pnpm --filter "{js-plugins}[origin/main]" build
100 changes: 0 additions & 100 deletions .github/workflows/plugin-build.yaml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/release-js-plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release Packages

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
name: release
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2

- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/main:refs/remotes/origin/main

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Enable Corepack
id: pnpm-setup
run: |
corepack enable

- name: Initliaze .npmrc
run: >
echo -e "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}\n$(cat .npmrc)" > .npmrc
&& cat -n .npmrc

- name: pnpm install
run: pnpm install --frozen-lockfile

- name: Build Packages
run: |
pnpm --filter "{js-plugins}[origin/main]" build

- name: Release and Publish Packages
run: |
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} && npm config set access public && pnpm --filter "{js-plugins}[origin/main]" publish --no-git-checks
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 2
- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/main:refs/remotes/origin/main

- name: Setup Node.js 18.x
uses: actions/setup-node@v3
Expand Down Expand Up @@ -51,4 +53,6 @@ jobs:
run: npm install -g [email protected] && pnpm i --frozen-lockfile

- name: Publish to npm
run: npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} && npm config set access public && pnpm --filter "[HEAD^]" publish --no-git-checks
run: |
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} && npm config set access public && pnpm --filter "{rust-plugins}[origin/main]" publish --no-git-checks

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,5 @@ $RECYCLE.BIN/
!.yarn/versions

*.farm

build
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
Empty file added .husky/pre-commit
Empty file.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = [
"packages/*",
"rust-plugins/*",
]
resolver = "2"
[workspace.dependencies]
Expand Down
Loading
Loading