Skip to content

Commit

Permalink
feat: init project
Browse files Browse the repository at this point in the history
  • Loading branch information
brightwwu committed Feb 9, 2024
1 parent a8fd4d3 commit 9dbf078
Show file tree
Hide file tree
Showing 43 changed files with 2,608 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build.yaml
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

8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
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
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

node_modules/
12 changes: 12 additions & 0 deletions Cargo.toml
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 = "*" }
8 changes: 8 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Local
.DS_Store
*.local
*.log*

# Dist
node_modules
dist/
5 changes: 5 additions & 0 deletions example/farm.config.ts
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']
});
13 changes: 13 additions & 0 deletions example/index.html
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>
26 changes: 26 additions & 0 deletions example/package.json
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"
}
}
Loading

0 comments on commit 9dbf078

Please sign in to comment.