Skip to content

Commit

Permalink
chore: #7 全自动化发布流程
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed May 9, 2023
1 parent 5e7f9c1 commit 75d83f5
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 116 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ updates:
prefix: fix
prefix-development: chore
include: scope
labels:
- "npm dependencies"
- "npm"

# Fetch and update latest `github-actions` pkgs
- package-ecosystem: github-actions
directory: "/"
Expand All @@ -30,3 +34,6 @@ updates:
prefix: fix
prefix-development: chore
include: scope
labels:
- "github actions"
- "ci"
5 changes: 0 additions & 5 deletions .github/semantic.yml

This file was deleted.

24 changes: 10 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
name: ci

name: CI
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
build:
runs-on: ubuntu-latest

ci:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
version: 8
run_install: false

- name: Get pnpm store directory
Expand All @@ -44,5 +37,8 @@ jobs:
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies and build for production
run: pnpm install && pnpm new && pnpm run build
- name: Install dependencies
run: pnpm install

- name: Build for production
run: pnpm build
109 changes: 87 additions & 22 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,101 @@ on:
push:
branches:
- main

name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
# create release pr
- uses: google-github-actions/release-please-action@v3
# Create release
- name: Create release
uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: release-please-action
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'
- run: echo "A release was created."
if: ${{ steps.release.outputs.releases_created }}
# For root level packages: ${{ steps.release.outputs.package-a--tag_name }}
- run: echo "Release ${{ steps.release.outputs['packages/package-a--tag_name'] }} created for package-a."
if: ${{ steps.release.outputs['packages/package-a--release_created'] }}
## 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: true
## Should feat changes before 1.0.0 produce patch bumps instead of minor bumps? Default false
bump-patch-for-minor-pre-major: true
## 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":"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

# create tag
- uses: actions/checkout@v3
- name: tag major and minor versions
# 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 new ${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
git config user.name terwer[bot]
git config user.email youweics@163.com
git remote add gh-token "https://${{ secrets.GH_TOKEN }}@github.com/terwer/sy-post-publisher.git"
git add -A
git push origin main
# Build for production and Archive package
- name: Build for production
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.GITHUB_TOKEN }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
git tag -d v${{ steps.release.outputs.major }} || true
git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git push origin :v${{ steps.release.outputs.major }} || true
git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}"
git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}"
git push origin v${{ steps.release.outputs.major }}
git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}
for f in $(find ./build -name '*.zip'); do
gh release upload ${{ steps.release.outputs.tag_name }} $f
done
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ out
public/lib/picgo/picgo.cfg.json
public/lib/picgo/picgo.cfg.dev.json

__pycache__
__pycache__
package.zip
test.sh
28 changes: 28 additions & 0 deletions assets/key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDj3/UVjTAUCBl1
FVe4N2tEYY0NIZ06IWFA/d7wfI7iZoJlb6uY9tFlh/I2Zydih/bDh02UhyXSKb1C
lT8xQ8fWg6pNFuUGFDqOXGG5/Vl0ngE97SeAcUffOCangHmHChjudo5EoGnQ+wfI
IiUAJ9nQsAfotuf6HZTzD+mz1wUvUNamw61IHmFZfGrb34x1HaGFazh+9+xg01g6
rYSK+e7VjAFcCEEPPy+BlnzfbrevbGt9qATW4JG+Rv3IF6j1zqknC2MptUaQmPxc
GT+J8Ufngss03/V/sqDvmW3gWQUk9iBK0rDLwlg7JufNtAAEnOoNVDt3YCNqWCNy
KZgTzXV3AgMBAAECggEAWG4KRYVHYZatDmcsZeQ3v88ddjmTssHOZHLAh9HGfyxp
sOSPkmpB42VIxPzt50o9JC7HF/sEXdTtyb9ySPN1QxVQSt82HFBQUvudvxgGlX9V
mwsDt8/+JK09LuZoAtQTzcJ7Pj2EIuGv6OX7Nt7AI8CUKSaFymWdbl/AARbRv8Sj
KeX8SX/J+zE9VFVPKkT+qtDMMyrdcexmogoAUjrwScsCb5uBS7beSjrBFt8LxWfM
CsyeJmMcM7QvegPr6Beh+u8aXFY9HmWUK+aLQBkCb9Pyk1nPI6y5wDzkK2Acqg/z
LLklhjctevxHYrZjHCcv5b5gD23U60Va5KBlKZyP3QKBgQD39HnAlAS/HUG4Doyi
LGz7zP7ZuyeixC3RcLJ3GHiigePkpsYRmcqb9c/lXgfUjYx/6QtnCZ1cNtX0wihf
kBSjx3J6eSuFvOUaclDS5pJrwSQK64e+VBJpE/I8A4AsFzLX8ffE3dYYrks0z5Er
sAl8DnJ96HcLkRxUdlJz/K5+XQKBgQDrRLH5OwrTuWlAuZQL3OSjXe0yq/eJyfby
3eJyrBq2NQ2wgP9HUVZg9DlE2np2wju00PR7WKgwXLP597kFvpzidt+vH6EEEMfD
CVEsL15zsrWitHi/m7h7kklhw3AglcWGYE+MFWoKEZQ5CjUSDxFxlGwpwhYhHPgV
cej4QOB94wKBgDm/HyfhkSVtS+Pwx4HxdMRD3sqYkseOhtkzNO0Vruqx84BJ8vEg
bxZZbjyN5Kb0/FbB0J0DmTljr/qbyUlQRe5KwfeSBrfT4UuCeh5UAp/D0IAWkHuc
GtmMAqtFaXFbScUPHlQkEfuXg/5dpQKWse7JcpKuNCNmfUGSeOt4Wq8lAoGBANet
sjp5FgPjBcqAVmhJqJDbmofJfrSiofEj2GSnwhUnrdURbPVEa5uWSKoGYB5fEb1B
kd9B923ejl+p6cSKaehycb1pkYLYn0j9UZzgEAag3kK6j7eYWhdulDc7o587rkjy
IfqZ5wwz8V4ZLW3Qwn0NQ9tEQmU42XVPZ/OuBh9hAoGAUcowfgpqkqKW/NDvzxeX
Yoq92mKeYXHeqAMvjhcZ6lPIbP0zkb+rGUCTWJpDw9MPZBeT+ntj7VOWT/WOalzk
nSISVYgGZo8GRXWCfzRKQJwS3nzYqdlyi7tdmSUS6ID/5YZmm54EClw5PqAsA7Qm
QlWFqSr06lSyXe1+6vBSR7g=
-----END PRIVATE KEY-----
76 changes: 38 additions & 38 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,46 @@ import '@vue/runtime-core'

export {}

declare module "@vue/runtime-core" {
declare module '@vue/runtime-core' {
export interface GlobalComponents {
ElAlert: typeof import("element-plus/es")["ElAlert"]
ElAutocomplete: typeof import("element-plus/es")["ElAutocomplete"]
ElButton: typeof import("element-plus/es")["ElButton"]
ElButtonGroup: typeof import("element-plus/es")["ElButtonGroup"]
ElCard: typeof import("element-plus/es")["ElCard"]
ElCheckbox: typeof import("element-plus/es")["ElCheckbox"]
ElCheckboxGroup: typeof import("element-plus/es")["ElCheckboxGroup"]
ElCol: typeof import("element-plus/es")["ElCol"]
ElColorPicker: typeof import("element-plus/es")["ElColorPicker"]
ElContainer: typeof import("element-plus/es")["ElContainer"]
ElDatePicker: typeof import("element-plus/es")["ElDatePicker"]
ElDialog: typeof import("element-plus/es")["ElDialog"]
ElDivider: typeof import("element-plus/es")["ElDivider"]
ElForm: typeof import("element-plus/es")["ElForm"]
ElFormItem: typeof import("element-plus/es")["ElFormItem"]
ElHeader: typeof import("element-plus/es")["ElHeader"]
ElIcon: typeof import("element-plus/es")["ElIcon"]
ElInput: typeof import("element-plus/es")["ElInput"]
ElMain: typeof import("element-plus/es")["ElMain"]
ElOption: typeof import("element-plus/es")["ElOption"]
ElPageHeader: typeof import("element-plus/es")["ElPageHeader"]
ElPagination: typeof import("element-plus/es")["ElPagination"]
ElPopover: typeof import("element-plus/es")["ElPopover"]
ElRadio: typeof import("element-plus/es")["ElRadio"]
ElRadioGroup: typeof import("element-plus/es")["ElRadioGroup"]
ElRow: typeof import("element-plus/es")["ElRow"]
ElSelect: typeof import("element-plus/es")["ElSelect"]
ElSkeleton: typeof import("element-plus/es")["ElSkeleton"]
ElSwitch: typeof import("element-plus/es")["ElSwitch"]
ElTable: typeof import("element-plus/es")["ElTable"]
ElTableColumn: typeof import("element-plus/es")["ElTableColumn"]
ElTabPane: typeof import("element-plus/es")["ElTabPane"]
ElTabs: typeof import("element-plus/es")["ElTabs"]
ElTag: typeof import("element-plus/es")["ElTag"]
ElTooltip: typeof import("element-plus/es")["ElTooltip"]
ElTreeSelect: typeof import("element-plus/es")["ElTreeSelect"]
ElAlert: typeof import('element-plus/es')['ElAlert']
ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
ElButton: typeof import('element-plus/es')['ElButton']
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
ElCard: typeof import('element-plus/es')['ElCard']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
ElCol: typeof import('element-plus/es')['ElCol']
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElInput: typeof import('element-plus/es')['ElInput']
ElMain: typeof import('element-plus/es')['ElMain']
ElOption: typeof import('element-plus/es')['ElOption']
ElPageHeader: typeof import('element-plus/es')['ElPageHeader']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
}
export interface ComponentCustomProperties {
vLoading: typeof import("element-plus/es")["ElLoadingDirective"]
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview",
"test": "vitest --watch",
"docs": "jsdoc -c jsdoc.json utils/api.ts",
"new": "python scripts/version.py 0.8.0",
"new": "python scripts/version.py",
"widget": "python scripts/widget.py",
"ext": "python scripts/ext.py",
"package": "pnpm widget && pnpm ext"
Expand Down
2 changes: 1 addition & 1 deletion scripts/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def do_firefox_package(df):

# 复制浏览器插件需要的其他文件
scriptutils.cp_file("./LICENSE", dist_folder)
scriptutils.cp_file("../backup/key.pem", dist_folder)
scriptutils.cp_file("./assets/key.pem", dist_folder)
print("复制浏览器插件需要的其他文件.")

# 删除siyuan挂件专属文件
Expand Down
13 changes: 11 additions & 2 deletions scripts/scriptutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,15 @@ def cp_folder(src, dst, remove_folder=False):

if not os.path.exists(dst):
mkdir(dst)
shutil.copytree(src, dst, ignore_dangling_symlinks=True, dirs_exist_ok=True)

try:
shutil.copytree(src, dst)
except FileExistsError:
# 如果目标文件夹已经存在,则删除它并重试
shutil.rmtree(dst)
shutil.copytree(src, dst)
except Exception as e:
print(f"无法拷贝文件夹:{e}")


def mkdir(dirname):
Expand Down Expand Up @@ -213,6 +221,7 @@ def iter_subtree(path, layer=0):
iter_subtree(root_path)
zipf.close()


def get_filename_from_time():
"""
根据时间命名文件
Expand All @@ -222,4 +231,4 @@ def get_filename_from_time():
now_time = time.localtime()
# 使用strftime函数把时间转换成想要的格式
filename = time.strftime("%Y%m%d%H%M%S", now_time) # 输出结果为:20210126095555
return filename
return filename
Loading

0 comments on commit 75d83f5

Please sign in to comment.