-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
brightwwu
committed
Feb 9, 2024
1 parent
a8fd4d3
commit 9dbf078
Showing
43 changed files
with
2,608 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Building Rust Binding And Upload Artifacts | ||
on: workflow_call | ||
|
||
env: | ||
DEBUG: 'napi:*' | ||
MACOSX_DEPLOYMENT_TARGET: '10.13' | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
settings: | ||
- target: x86_64-unknown-linux-gnu | ||
abi: linux-x64-gnu | ||
- target: x86_64-unknown-linux-musl | ||
abi: linux-x64-musl | ||
- target: x86_64-apple-darwin | ||
abi: darwin-x64 | ||
- target: x86_64-pc-windows-msvc | ||
abi: win32-x64-msvc | ||
- target: i686-pc-windows-msvc | ||
abi: win32-ia32-msvc | ||
- target: aarch64-pc-windows-msvc | ||
abi: win32-arm64-msvc | ||
- target: aarch64-unknown-linux-gnu | ||
abi: linux-arm64-gnu | ||
- target: aarch64-unknown-linux-musl | ||
abi: linux-arm64-musl | ||
- target: aarch64-apple-darwin | ||
abi: darwin-arm64 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Cache rust artifacts | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
shared-key: rust-build-${{ matrix.settings.abi }} | ||
- run: rustup target add ${{ matrix.settings.target }} | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
cache: 'pnpm' | ||
- name: Install ziglang | ||
uses: goto-bus-stop/setup-zig@v1 | ||
with: | ||
version: 0.11.0 | ||
- run: cargo install cargo-xwin | ||
- run: pnpm install | ||
- run: pnpm build --target ${{ matrix.settings.target }} | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ github.sha }}-${{ matrix.settings.abi }} | ||
path: npm/**/index.farm | ||
if-no-files-found: error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: Cross Build On Linux | ||
on: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
call-rust-build: | ||
uses: ./.github/workflows/build.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Publish packages and crates | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
call-rust-build: | ||
uses: ./.github/workflows/rust-build.yaml | ||
|
||
release: | ||
name: Release | ||
needs: [call-rust-build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js 18.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
|
||
# batch download artifacts | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
path: /tmp/artifacts | ||
- name: Move Artifacts | ||
run: | | ||
for abi in linux-x64-gnu linux-x64-musl darwin-x64 win32-x64-msvc linux-arm64-musl linux-arm64-gnu darwin-arm64 win32-ia32-msvc win32-arm64-msvc | ||
do | ||
mv /tmp/artifacts/${{ github.sha }}-${abi}/* ./npm/${abi} | ||
test -f ./npm/${abi}/index.farm | ||
done | ||
- name: Install Dependencies | ||
run: npm install -g pnpm@8.15.1 && pnpm i --frozen-lockfile | ||
|
||
- name: Publish to npm | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
publish: pnpm publish --access public | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ Cargo.lock | |
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
|
||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
edition = "2021" | ||
name = "farm_plugin_example" | ||
version = "0.0.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
farmfe_core = { version = "*" } | ||
farmfe_toolkit_plugin_types = { version = "*" } | ||
farmfe_macro_plugin = { version = "*" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Local | ||
.DS_Store | ||
*.local | ||
*.log* | ||
|
||
# Dist | ||
node_modules | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { defineConfig } from '@farmfe/core'; | ||
|
||
export default defineConfig({ | ||
plugins: ['@farmfe/plugin-react'] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script src="./src/index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "example", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"clsx": "^1.2.1", | ||
"react": "18", | ||
"react-dom": "18" | ||
}, | ||
"devDependencies": { | ||
"@farmfe/cli": "^0.6.1", | ||
"@farmfe/core": "^0.16.5", | ||
"@farmfe/plugin-react": "^0.6.0", | ||
"@types/react": "18", | ||
"core-js": "^3.30.1", | ||
"@types/react-dom": "18", | ||
"react-refresh": "^0.14.0", | ||
"farm-plugin-example": "../" | ||
}, | ||
"scripts": { | ||
"dev": "farm start", | ||
"start": "farm start", | ||
"build": "farm build", | ||
"preview": "farm preview", | ||
"clean": "farm clean" | ||
} | ||
} |
Oops, something went wrong.