Skip to content

Commit

Permalink
chore: update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ErKeLost committed Oct 18, 2024
1 parent 9508572 commit 7aa7c68
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/nightly-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Nightly Release
on:
push:
branches:
- refactor/node

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
call-rust-build:
uses: ./.github/workflows/rust-build.yaml

nightly-release:
name: Nightly 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@v4
with:
path: /tmp/artifacts
- name: Copy Farm Core Binary
run: cp /tmp/artifacts/${{ github.sha }}-linux-x64-gnu/* ./packages/core/binding
- 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}/* ./packages/core/npm/${abi}
mv /tmp/artifacts/${{ github.sha }}-${abi}-plugin-react/* ./rust-plugins/react/npm/${abi}
mv /tmp/artifacts/${{ github.sha }}-${abi}-plugin-sass/* ./rust-plugins/sass/npm/${abi}
mv /tmp/artifacts/${{ github.sha }}-${abi}-create-farm/* ./packages/create-farm/npm/${abi}
test -f ./packages/core/npm/${abi}/farm.${abi}.node
test -f ./packages/create-farm/npm/${abi}/create-farm.${abi}.node
test -f ./rust-plugins/react/npm/${abi}/index.farm
test -f ./rust-plugins/sass/npm/${abi}/index.farm
done
for abi in android-arm-eabi linux-arm-gnueabihf android-arm64
do
mv /tmp/artifacts/${{ github.sha }}-${abi}-create-farm/* ./packages/create-farm/npm/${abi}
test -f ./packages/create-farm/npm/${abi}/create-farm.${abi}.node
done
- name: Install Dependencies
run: npm install -g [email protected] && pnpm i --frozen-lockfile
- name: Build Plugin Tools
run: pnpm --filter @farmfe/plugin-tools run build

# - name: Set Nightly Version
# run: |
# NIGHTLY_VERSION="2.0.0-nightly.$(date +'%Y%m%d%H%M%S')"
# pnpm version $NIGHTLY_VERSION --no-git-tag-version

# - name: Publish Nightly to npm
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# run: |
# echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
# pnpm publish --tag nightly --no-git-checks

- name: Create Nightly Release Pull Request or Publish Nightly Version to npm
id: changesets
uses: changesets/action@v1
with:
version: pnpm run bump:nightly
publish: npm run release:nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
},
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"build:core": "pnpm --filter @farmfe/core build",
"doc": "pnpm --filter farm-docs dev",
"release": "node scripts/release.mjs",
"release:nightly": "node scripts/release-nightly.mjs",
"check": "biome check . --diagnostic-level=warn --apply",
"bump": "node scripts/bump.mjs",
"bump:nightly": "node scripts/bump-nightly.mjs",
"bump:create-farm": "node scripts/bump-create-farm-version.mjs",
"test:rs:update": "cross-env FARM_UPDATE_SNAPSHOTS=1 cargo test -p farmfe_compiler",
"ready": "node scripts/ready.mjs",
Expand Down
10 changes: 10 additions & 0 deletions scripts/bump-nightly.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { execSync } from "child_process";

// generate nightly version
const nightlyVersion = `0.0.0-nightly.${Date.now()}`;

execSync(`npx changeset version --snapshot nightly`, { stdio: "inherit" });

execSync("pnpm install --no-frozen-lockfile", { stdio: "inherit" });

console.log(`Nightly version bump completed. Version: ${nightlyVersion}`);
21 changes: 21 additions & 0 deletions scripts/release-nightly.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { execSync } from "child_process";
import { buildCli, buildCoreCjs, buildJsPlugins } from "./build.mjs";

// Generate nightly version number
const nightlyVersion = `0.0.0-nightly.${Date.now()}`;

// Build node packages
await buildCli();
await buildCoreCjs();
await buildJsPlugins();

// Set npm config to public access
execSync("npm config set access public", { stdio: "inherit" });

// Update versions to nightly
execSync(`npx changeset version --snapshot nightly`, { stdio: "inherit" });

// Publish nightly packages
execSync("npx changeset publish --tag nightly", { stdio: "inherit" });

console.log(`Nightly version ${nightlyVersion} published successfully.`);

0 comments on commit 7aa7c68

Please sign in to comment.