This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
1.7.0 #22
Workflow file for this run
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
name: release | |
on: | |
push: | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
workflow_dispatch: | |
env: | |
PLUGIN_NAME: obsidian-dida-sync | |
jobs: | |
build: | |
name: 构建 | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: 源仓库切换分支 | |
uses: actions/checkout@v3 | |
id: checkout | |
with: | |
fetch-depth: 0 | |
- name: 获得源仓库tag名称 | |
shell: bash | |
# 去掉tag的v前缀 | |
run: echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1 | sed 's/^v//')" | |
id: get_tag | |
- name: 创建release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_tag.outputs.tag_name }} | |
release_name: ${{ steps.get_tag.outputs.tag_name }} | |
draft: true | |
prerelease: false | |
- name: 设置node环境 | |
uses: actions/setup-node@v3.6.0 | |
with: | |
node-version: 14 | |
- name: 设置pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 7 | |
run_install: false | |
- name: 获得pnpm存储区地址 | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- name: 设置pnpm缓存地址 | |
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- | |
- name: 安装与构建 | |
run: | | |
cd ${{github.workspace}} | |
pnpm install | |
pnpm run build | |
- name: 打ZIP包 | |
id: zip | |
run: | | |
mkdir ${{ env.PLUGIN_NAME }} | |
cp ./dist/main.js ./dist/manifest.json ${{ env.PLUGIN_NAME }} | |
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }} | |
ls | |
- name: 上传zip 到release | |
id: upload-zip | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.PLUGIN_NAME }}.zip | |
asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.get_tag.outputs.tag_name }}.zip | |
asset_content_type: application/zip | |
- name: 上传 main.js 到release | |
id: upload-main | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/main.js | |
asset_name: main.js | |
asset_content_type: text/javascript | |
- name: 上传 manifest.json 到release | |
id: upload-manifest | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/manifest.json | |
asset_name: manifest.json | |
asset_content_type: application/json |