Skip to content

Commit

Permalink
build: rspack
Browse files Browse the repository at this point in the history
  • Loading branch information
VirgilClyne committed Oct 23, 2024
1 parent 4f77862 commit 40e5ba1
Show file tree
Hide file tree
Showing 37 changed files with 6,742 additions and 1,549 deletions.
14 changes: 14 additions & 0 deletions .github/RELEASE-TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### 🆕 New Features
* none

### 🛠️ Bug Fixes
* none

### 🔣 Dependencies
* none

### ‼️ Breaking Changes
* none

### 🔄 Other Changes
* none
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build
on:
workflow_call:
workflow_dispatch:

permissions:
actions: read
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
with:
submodules: recursive
token: ${{ secrets.SUBMODULE_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@main
with:
node-version: 'latest'
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Update local package.json version from release tag
if: github.ref_type == 'tag'
uses: BellCubeDev/update-package-version-by-release-tag@v2
with:
version: ${{ github.ref_name }}
keep-v: "false" # If set to "true", will not remove any 'v' prefix from the version number.
ignore-semver-check: "false" # If set to "true", will not check if the version number is a valid semver version.
- name: Build scripts
run: npm run build
- name: Generate modules
run: npm run build:args
- name: Upload artifact
uses: actions/upload-artifact@master
with:
name: artifact
path: |
CHANGELOG.md
rulesets
dist
30 changes: 30 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy
on:
push:
# Sequence of patterns matched against refs/heads
branches:
- dev

permissions:
actions: read
contents: read

jobs:
debug:
uses: ./.github/workflows/dev.yml
secrets: inherit
deploy:
needs: debug
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@master
with:
name: artifact
- name: Deploy
uses: exuanbo/actions-deploy-gist@main
with:
token: ${{ secrets.GIST_TOKEN }}
gist_id: c7d70898da568b0a3bbee5bfd3c07f95
gist_description: "🍿️ DualSubs: ➕ AddOn (Microsoft Translate)"
file_path: dist/Microsoft.Translate.bundle.js
36 changes: 36 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Dev
on:
workflow_call:
workflow_dispatch:

permissions:
actions: read
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
with:
submodules: recursive
token: ${{ secrets.SUBMODULE_TOKEN }}
ref: dev
- name: Set up Node.js
uses: actions/setup-node@main
with:
node-version: 'latest'
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build:dev
- name: Upload artifact
uses: actions/upload-artifact@master
with:
name: artifact
path: |
CHANGELOG.md
rulesets
dist
32 changes: 32 additions & 0 deletions .github/workflows/draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Draft
on:
push:
# Sequence of patterns matched against refs/heads
branches:
- main

permissions:
actions: read
contents: write

jobs:
build:
uses: ./.github/workflows/build.yml
secrets: inherit
draft:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@master
with:
name: artifact
- name: Publish Draft
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
files: |
rulesets/*
dist/*
draft: true
33 changes: 33 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Pre-Release
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+

permissions:
actions: read
contents: write

jobs:
build:
uses: ./.github/workflows/build.yml
secrets: inherit
pre-release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@master
with:
name: artifact
- name: Publish Pre-Release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
files: |
rulesets/*
dist/*
prerelease: true
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- v[0-9]+.[0-9]+.[0-9]+

permissions:
actions: read
contents: write

jobs:
build:
uses: ./.github/workflows/build.yml
secrets: inherit
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@master
with:
name: artifact
- name: Publish Release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
files: |
rulesets/*
dist/*
make_latest: "true"
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### 🔄 Other Changes
* 打包器由 `rollup` 更改为 `rspack`
40 changes: 40 additions & 0 deletions arguments-builder.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { defineConfig } from "@iringo/arguments-builder";

export default defineConfig({
output: {
surge: {
path: "./dist/Microsoft.Translate.sgmodule",
},
loon: {
path: "./dist/Microsoft.Translate.plugin",
},
customItems: [
{
path: "./dist/Microsoft.Translate.stoverride",
template: "./template/stash.handlebars",
},
{
path: "./dist/Microsoft.Translate.yaml",
template: "./template/egern.handlebars",
},
],
dts: {
isExported: true,
path: "./src/types.d.ts",
},
boxjsSettings: {
path: "./template/boxjs.settings.json",
scope: "@DualSubs.AddOn.Settings",
},
},
args: [
{
key: "Switch",
name: "总功能开关",
defaultValue: true,
type: "boolean",
description: "是否启用此APP修改",
exclude: ["surge", "loon"],
},
],
});
72 changes: 72 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"files": {
"ignore": [
"**/*.bundle.js"
],
"ignoreUnknown": false
},
"formatter": {
"enabled": true,
"indentStyle": "tab",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 240
},
"javascript": {
"formatter": {
"arrowParentheses": "asNeeded",
"bracketSameLine": true,
"quoteStyle": "double"
}
},
"json": {
"parser": {
"allowComments": true,
"allowTrailingCommas": true
}
},
"linter": {
"enabled": true,
"rules": {
"complexity": {
"noForEach": "off",
"noStaticOnlyClass": "off",
"noUselessSwitchCase": "off",
"useArrowFunction": "info",
"useFlatMap": "off",
"useLiteralKeys": "info"
},
"correctness": {
"noInnerDeclarations": "info",
"noSelfAssign": "off",
"noSwitchDeclarations": "info"
},
"recommended": true,
"style": {
"noNegationElse": "off",
"noParameterAssign": "off",
"noUselessElse": "off",
"noVar": "info",
"useDefaultParameterLast": "info",
"useForOf": "error",
"useNodejsImportProtocol": "error",
"useNumberNamespace": "error",
"useSingleVarDeclarator": "off"
},
"suspicious": {
"noAssignInExpressions": "info",
"noFallthroughSwitchClause": "info",
"useDefaultSwitchClauseLast": "off"
}
}
},
"organizeImports": {
"enabled": true
},
"vcs": {
"clientKind": "git",
"enabled": true,
"useIgnoreFile": true
}
}
Loading

0 comments on commit 40e5ba1

Please sign in to comment.