3 Commits

Author SHA1 Message Date
74c59ef00c fix: Add npm install command 2023-12-04 10:17:21 +08:00
d2833c6905 feat: Add github workflow 2023-12-04 10:12:59 +08:00
1def5c9f21 feat: add body_path support 2023-12-04 09:43:35 +08:00
2 changed files with 39 additions and 2 deletions

31
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Build and Publish
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
runs-on: ubuntu-latest
name: 构建
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
cache: 'npm'
cache-dependency-path: package-lock.json
- run: npm install -D
- run: npm run package
- run: |
git config user.name github-actions
git config user.email github-actions@github.com
- run: |
git add .
git commit -m "Auto Build"
- id: get_version
uses: battila7/get-version-action@v2
- run: git tag -f "v${{ steps.get_version.outputs.major }}"
- run: git push -f --follow-tags

10
main.js
View File

@ -11,7 +11,7 @@ async function run() {
try { try {
const server_url = core.getInput("server_url") const server_url = core.getInput("server_url")
const name = core.getInput("name") const name = core.getInput("name")
const body = core.getInput("body") const body = getReleaseBody(core.getInput("body"), core.getInput("body_path"))
const tag_name = core.getInput("tag_name") const tag_name = core.getInput("tag_name")
const draft = Boolean(core.getInput("draft")) const draft = Boolean(core.getInput("draft"))
const prerelease = Boolean(core.getInput("prerelease")) const prerelease = Boolean(core.getInput("prerelease"))
@ -128,4 +128,10 @@ async function uploadFiles(client, owner, repo, release_id, all_files) {
} }
} }
run(); function getReleaseBody(body, body_path) {
return (
(body_path && fs.readFileSync(body_path).toString("utf8")) || body
)
}
run()