forked from leolee9086/browserTab
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(custom-block): 添加 CD 脚本 | Add CD scripts.
- Loading branch information
1 parent
f96d37c
commit 128bcb7
Showing
4 changed files
with
312 additions
and
37 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,93 @@ | ||
# 构建并部署 | Build and deploy | ||
|
||
name: build | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
# REF https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
|
||
env: | ||
PACKAGE_PATH: ./workspace/plugins/custom-block | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout | ||
# REF https://github.com/marketplace/actions/checkout | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
## 将要拉取的仓库 | repository will to pull | ||
repository: Zuoqiu-Yingyi/siyuan-packages-monorepo | ||
|
||
# Install Node.js | ||
# REF https://github.com/marketplace/actions/setup-node-js-environment | ||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
## Node.js 版本号 | Node.js version | ||
node-version: 20 | ||
|
||
## Node.js 源 | Node.js registry | ||
registry-url: https://registry.npmjs.org | ||
|
||
# Install pnpm | ||
# REF https://github.com/marketplace/actions/setup-pnpm | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
id: pnpm-install | ||
with: | ||
## pnpm 版本号 | pnpm version | ||
version: 8 | ||
|
||
## 是否安装 npm 包 | if install npm package? | ||
run_install: false | ||
|
||
# Get pnpm store directory | ||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
# Setup pnpm cache | ||
# REF https://github.com/marketplace/actions/cache | ||
- name: Setup pnpm cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
# Install dependencies | ||
- name: Install dependencies | ||
run: | | ||
cd $GITHUB_WORKSPACE | ||
cd ./workspace | ||
pnpm install | ||
# Build package | ||
- name: Build package | ||
run: | | ||
cd $GITHUB_WORKSPACE | ||
cd $PACKAGE_PATH | ||
pnpm build | ||
# Deploy to publish branch | ||
# REF https://github.com/marketplace/actions/github-pages | ||
- name: Deploy to publish branch | ||
if: success() | ||
uses: crazy-max/ghaction-github-pages@v3 | ||
with: | ||
## 构建产物目录 | directory of build artifacts | ||
build_dir: ${{ env.PACKAGE_PATH }}/dist | ||
|
||
## 提交到目标分支 | ||
target_branch: publish | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT_ACTIONS }} |
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,81 @@ | ||
# 发行构建产物 | Release the distribution | ||
|
||
name: release-distribution | ||
|
||
on: | ||
workflow_dispatch: | ||
# REF https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run | ||
workflow_run: | ||
workflows: | ||
- build | ||
types: | ||
- completed | ||
push: | ||
branches: | ||
- publish | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release-distribution: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout | ||
# REF https://github.com/marketplace/actions/checkout | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: publish | ||
|
||
# Package | ||
- name: Package | ||
run: | | ||
git archive -o ./package.zip HEAD | ||
# Get latest release | ||
# REF https://github.com/marketplace/actions/get-latest-release | ||
- name: Get latest release | ||
uses: pozetroninc/github-action-get-latest-release@v0.7.0 | ||
id: latest-release | ||
with: | ||
## 仓库所有者/仓库名 | owner/name | ||
repository: ${{ github.repository }} | ||
|
||
## 排除的发行类型 | Excluded types of release | ||
# excludes: prerelease, draft | ||
excludes: draft | ||
|
||
# Get timestamp | ||
# REF https://github.com/marketplace/actions/get-timestamp-action | ||
- name: Get timestamp | ||
uses: nanzm/get-time-action@v1.1 | ||
id: timestamp | ||
with: | ||
## 时区 | time zone | ||
timeZone: 8 | ||
|
||
## 时间戳格式 | timestamp format | ||
format: "YYYYMMDDHHmmss" | ||
|
||
# Release distribution | ||
# REF https://github.com/marketplace/actions/gh-release | ||
- name: Release distribution | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
## 发行描述 | description of release | ||
body: ${{ steps.latest-release.outputs.description }} | ||
|
||
## 是否为预发行 | is prelease? | ||
prerelease: true | ||
|
||
## 标签名称 | tag name | ||
# REF https://semver.org/ | ||
tag_name: ${{ steps.latest-release.outputs.release }}+${{ steps.timestamp.outputs.time }} | ||
|
||
## 标签关联的提交/分支 | The commit/branch associated with the tag | ||
target_commitish: publish | ||
|
||
## 附件列表 | attachment list | ||
files: | | ||
package.zip |
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,108 @@ | ||
# 发行源码 | Release the source code | ||
|
||
name: release-please | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Create release | ||
# REF https://github.com/marketplace/actions/release-please-action | ||
- name: Create release | ||
uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: node | ||
package-name: release-please-action | ||
|
||
## A GitHub secret token, the action defaults to using the special secrets.GITHUB_TOKEN | ||
## REF https://github.com/marketplace/actions/release-please-action#github-credentials | ||
token: ${{ secrets.PAT_ACTIONS }} | ||
|
||
## branch to open pull release PR against (detected by default) | ||
default-branch: main | ||
|
||
## Should breaking changes before 1.0.0 produce minor bumps? Default false | ||
bump-minor-pre-major: false | ||
|
||
## Should feat changes before 1.0.0 produce patch bumps instead of minor bumps? Default false | ||
bump-patch-for-minor-pre-major: false | ||
|
||
## If set, create releases that are pre-major or pre-release version marked as pre-release on GitHub. Defaults false | ||
prerelease: true | ||
|
||
## header used within the release PR body, defaults to using :robot: I have created a release *beep* *boop* | ||
pull-request-header: ":robot: A new release will be created" | ||
|
||
## A JSON formatted String containing to override the outputted changelog sections | ||
changelog-types: |- | ||
[ | ||
{ | ||
"type": "build", | ||
"section": "Build System", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "chore", | ||
"section": "Miscellaneous", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "ci", | ||
"section": "Continuous Integration", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "docs", | ||
"section": "Documentation" | ||
}, | ||
{ | ||
"type": "feat", | ||
"section": "Features", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "fix", | ||
"section": "Bug Fixes", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "perf", | ||
"section": "Performance Improvements" | ||
}, | ||
{ | ||
"type": "refactor", | ||
"section": "Code Refactoring", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "revert", | ||
"section": "Reverts" | ||
}, | ||
{ | ||
"type": "style", | ||
"section": "Styles", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "test", | ||
"section": "Tests", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "", | ||
"section": "Other Changes", | ||
"hidden": false | ||
} | ||
] |
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 |
---|---|---|
@@ -1,47 +1,40 @@ | ||
# Svelte + TS + Vite | ||
> **[READ ONLY] Subtree split of the [siyuan-packages-monorepo](https://github.com/Zuoqiu-Yingyi/siyuan-packages-monorepo) [/workspace/plugins/custom-block](https://github.com/Zuoqiu-Yingyi/siyuan-packages-monorepo/tree/main/workspace/plugins/custom-block)** | ||
This template should help get you started developing with Svelte and TypeScript in Vite. | ||
<div align="center"> | ||
<img alt="icon" src="./public/icon.png" style="width: 8em; height: 8em;"> | ||
|
||
## Recommended IDE Setup | ||
--- | ||
[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/Zuoqiu-Yingyi/siyuan-plugin-custom-block?include_prereleases&style=flat-square)](https://github.com/Zuoqiu-Yingyi/siyuan-plugin-custom-block/releases/latest) | ||
[![GitHub Release Date](https://img.shields.io/github/release-date/Zuoqiu-Yingyi/siyuan-plugin-custom-block?style=flat-square)](https://github.com/Zuoqiu-Yingyi/siyuan-plugin-custom-block/releases/latest) | ||
[![GitHub License](https://img.shields.io/github/license/Zuoqiu-Yingyi/siyuan-plugin-custom-block?style=flat-square)](https://github.com/Zuoqiu-Yingyi/siyuan-plugin-custom-block/blob/main/LICENSE) | ||
[![GitHub last commit](https://img.shields.io/github/last-commit/Zuoqiu-Yingyi/siyuan-plugin-custom-block?style=flat-square)](https://github.com/Zuoqiu-Yingyi/siyuan-plugin-custom-block/commits/main) | ||
![GitHub repo size](https://img.shields.io/github/repo-size/Zuoqiu-Yingyi/siyuan-plugin-custom-block?style=flat-square) | ||
![hits](https://hits.b3log.org/Zuoqiu-Yingyi/siyuan-plugin-custom-block.svg) | ||
[![GitHub all releases](https://img.shields.io/github/downloads/Zuoqiu-Yingyi/siyuan-plugin-custom-block/total?style=flat-square)](https://github.com/Zuoqiu-Yingyi/siyuan-plugin-custom-block/releases) | ||
|
||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). | ||
--- | ||
</div> | ||
|
||
## Need an official Svelte framework? | ||
## USER GUIDE | ||
|
||
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more. | ||
[简体中文](./public/README_zh_CN.md) \| [English](./public/README.md) | ||
|
||
## Technical considerations | ||
## DEVELOPMENT GUIDE | ||
|
||
**Why use this over SvelteKit?** | ||
### RELEASE STEPS | ||
|
||
- It brings its own routing solution which might not be preferable for some users. | ||
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app. | ||
1. Update the version number in `<subrepo-root-dir>/package.json` and `<subrepo-root-dir>/public/plugin.json`, then commit the changes in [monorepo](https://github.com/Zuoqiu-Yingyi/siyuan-packages-monorepo). | ||
2. Run script `./scripts/git-subtree/custom-block/push.ps1` with the folowing command in **monorepo root dir** to push the subtree to sub-repository (`dev` branch). | ||
```powershell | ||
pwsh -f "./scripts/git-subtree/custom-block/push.ps1" | ||
``` | ||
3. Create a pull request from `dev` branch to `main` branch in sub-repository. | ||
4. Merge the pull request. | ||
5. Await for the CD workflow `release-please.yml` to complete, it will create a *release pull request* in sub-repository. | ||
6. Merge the *release pull request*, it will create a new *pre-release* with current [changelog](./CHANGELOG.md) and a new *tag* with [semantic version](https://semver.org/) in sub-repository. | ||
7. Await for the CD workflow `build.yml` to complete, it will update the distribution files to `publish` branch in sub-repository. | ||
8. Await for the CD workflow `release-distribution.yml` to complete, it will create a new *pre-release* with an asset named `package.zip` and a new *tag* with timestamp in sub-repository. | ||
|
||
This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project. | ||
## CHANGELOG | ||
|
||
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate. | ||
|
||
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?** | ||
|
||
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information. | ||
|
||
**Why include `.vscode/extensions.json`?** | ||
|
||
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project. | ||
|
||
**Why enable `allowJs` in the TS template?** | ||
|
||
While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant. | ||
|
||
**Why is HMR not preserving my local component state?** | ||
|
||
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr). | ||
|
||
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR. | ||
|
||
```ts | ||
// store.ts | ||
// An extremely simple external store | ||
import { writable } from 'svelte/store' | ||
export default writable(0) | ||
``` | ||
[CHANGE LOG](./CHANGELOG.md) |