-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
18 changed files
with
723 additions
and
10 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,39 @@ | ||
version: 2 | ||
updates: | ||
# Fetch and update latest `npm` packages | ||
- package-ecosystem: npm | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "00:00" | ||
open-pull-requests-limit: 10 | ||
reviewers: | ||
- terwer | ||
assignees: | ||
- terwer | ||
commit-message: | ||
prefix: fix | ||
prefix-development: chore | ||
include: scope | ||
labels: | ||
- "npm dependencies" | ||
- "npm" | ||
|
||
# Fetch and update latest `github-actions` pkgs | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "00:00" | ||
open-pull-requests-limit: 10 | ||
reviewers: | ||
- terwer | ||
assignees: | ||
- terwer | ||
commit-message: | ||
prefix: fix | ||
prefix-development: chore | ||
include: scope | ||
labels: | ||
- "github actions" | ||
- "ci" |
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,37 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- uses: pnpm/action-setup@v2.2.4 | ||
with: | ||
version: 8 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build | ||
run: pnpm build | ||
|
||
- name: Package | ||
run: pnpm package |
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,103 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
name: release-please | ||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Create release | ||
- name: Create release | ||
uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: node | ||
package-name: release-please-action | ||
## 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: false | ||
## 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":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Code Refactoring","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"perf","section":"Performance Improvements","hidden":false}]' | ||
|
||
# Checkout | ||
- name: Checkout | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: actions/checkout@v3 | ||
|
||
# Install Node.js | ||
- name: Install Node.js | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
# Install pnpm | ||
- name: Install pnpm | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: pnpm/action-setup@v2 | ||
id: pnpm-install | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
# Get pnpm store directory | ||
- name: Get pnpm store directory | ||
if: ${{ steps.release.outputs.release_created }} | ||
id: pnpm-cache | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
# Setup pnpm cache | ||
- name: Setup pnpm cache | ||
if: ${{ steps.release.outputs.release_created }} | ||
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 | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: pnpm install | ||
|
||
# Prepare new version | ||
# https://github.com/google-github-actions/release-please-action#outputs | ||
- name: Prepare new version | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: | | ||
pnpm prepareRelease | ||
# Build for production | ||
- name: Build for production | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: pnpm build | ||
|
||
# Archive package | ||
- name: Archive package | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: pnpm package | ||
|
||
# Upload package to release | ||
# https://github.com/philips-labs/terraform-aws-github-runner/blob/main/.github/workflows/release.yml#L46 | ||
- name: Upload package.zip to the release | ||
if: ${{ steps.release.outputs.releases_created }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
run: | | ||
ls -l ./build | ||
for f in $(find ./build -name '*.zip'); do | ||
gh release upload ${{ steps.release.outputs.tag_name }} $f | ||
done |
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 |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
.cache | ||
dist | ||
.env.docker | ||
build | ||
__pycache__ | ||
|
||
# Node dependencies | ||
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
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
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
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
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
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
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,7 @@ | ||
# scripts | ||
|
||
## Usage | ||
|
||
```bash | ||
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple | ||
``` |
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,27 @@ | ||
#!/usr/bin/sh | ||
|
||
pnpm siyuanBuild | ||
echo "Nuxt build finished." | ||
pnpm pluginBuild | ||
echo "Plugin build finished." | ||
|
||
# 使用 `sed` 命令替换内容 | ||
find ./dist/_nuxt -type f -name 'entry.*.js' -exec \ | ||
sed -i '' -E 's/\/__i18n__\/prerender/\/plugins\/siyuan-blog\/__i18n__\/prerender/g' {} \; | ||
echo "The i18n path has been replaced" | ||
|
||
# 添加 html 版本号 | ||
function replace_file_name() { | ||
timestamp="$(date +%s)" | ||
sed -i '' -E \ | ||
-e "s/(<script[^>]*src=[\"'][^\"']+\.js)[^\"']*(\"[^>]*>)/\1?v=${timestamp}\2/g" \ | ||
-e "s/(<link[^>]*href=[\"'][^\"']+\.js)[^\"']*(\"[^>]*>)/\1?v=${timestamp}\2/g" \ | ||
-e "s/(<link[^>]*href=[\"'][^\"']+\.css)[^\"']*(\"[^>]*>)/\1?v=${timestamp}\2/g" \ | ||
-e "s/(<link[^>]*href=[\"'][^\"']+\.(svg|png|jpe?g|gif|webp)[^\"']*[\"'][^>]*>)/\1?v=${timestamp}\"/g" \ | ||
"./dist/index.html" | ||
} | ||
|
||
replace_file_name | ||
echo "The html version number has been added" | ||
|
||
echo "Siyuan build success." |
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,31 @@ | ||
#!/usr/bin/sh | ||
|
||
DEBUG_MODE=true pnpm siyuanBuild | ||
echo "Nuxt build finished." | ||
pnpm pluginBuild | ||
echo "Plugin build finished." | ||
|
||
# 使用 `sed` 命令替换内容 | ||
find ./dist/_nuxt -type f -name 'entry.*.js' -exec \ | ||
sed -i '' -E 's/\/__i18n__\/prerender/\/plugins\/siyuan-blog\/__i18n__\/prerender/g' {} \; | ||
echo "The i18n path has been replaced" | ||
|
||
# 添加 html 版本号 | ||
function replace_file_name() { | ||
timestamp="$(date +%s)" | ||
sed -i '' -E \ | ||
-e "s/(<script[^>]*src=[\"'][^\"']+\.js)[^\"']*(\"[^>]*>)/\1?v=${timestamp}\2/g" \ | ||
-e "s/(<link[^>]*href=[\"'][^\"']+\.js)[^\"']*(\"[^>]*>)/\1?v=${timestamp}\2/g" \ | ||
-e "s/(<link[^>]*href=[\"'][^\"']+\.css)[^\"']*(\"[^>]*>)/\1?v=${timestamp}\2/g" \ | ||
-e "s/(<link[^>]*href=[\"'][^\"']+\.(svg|png|jpe?g|gif|webp)[^\"']*[\"'][^>]*>)/\1?v=${timestamp}\"/g" \ | ||
"./dist/index.html" | ||
} | ||
|
||
replace_file_name | ||
echo "The html version number has been added" | ||
|
||
# 复制最终文件 | ||
rsync -av ./dist/ /Users/terwer/Documents/mydocs/SiYuanWorkspace/public/data/plugins/siyuan-blog/ | ||
echo "All assets are copied。" | ||
|
||
echo "Siyuan build success." |
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,2 @@ | ||
pnpm nodeBuild | ||
docker compose up --build |
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,27 @@ | ||
import os | ||
|
||
import scriptutils | ||
|
||
if __name__ == "__main__": | ||
# 切换工作空间 | ||
scriptutils.switch_workdir() | ||
|
||
# 获取当前工作空间 | ||
cwd = scriptutils.get_workdir() | ||
|
||
dist_folder = "./dist" | ||
data = scriptutils.read_json_file(cwd + "package.json") | ||
v = data["version"] | ||
|
||
src_folder = dist_folder | ||
tmp_folder_name = "./siyuan-plugin-blog" | ||
build_zip_path = "./build" | ||
build_zip_name = "siyuan-plugin-blog-" + v + ".zip" | ||
|
||
try: | ||
# 压缩dist为zip | ||
scriptutils.zip_folder(src_folder, tmp_folder_name, build_zip_path, build_zip_name) | ||
scriptutils.cp_file(os.path.join(build_zip_path, build_zip_name), os.path.join(build_zip_path, "package.zip")) | ||
except Exception as e: | ||
print(f"打包错误,{str(e)}") | ||
print("插件打包完毕.") |
Oops, something went wrong.