mirror of
https://github.com/certd/certd.git
synced 2026-04-14 12:30:54 +08:00
chore: publish github
This commit is contained in:
@@ -66,7 +66,7 @@ async function createRelease(versionTitle, content) {
|
||||
tag_name: `v${versionTitle}`,
|
||||
name: `v${versionTitle}`,
|
||||
body: content,
|
||||
target_commitish: 'v2'
|
||||
target_commitish: 'v2-dev'
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@ async function createRelease(versionTitle, content) {
|
||||
tag_name: `v${versionTitle}`,
|
||||
name: `v${versionTitle}`,
|
||||
body: content,
|
||||
target_commitish: 'v2'
|
||||
target_commitish: 'v2-dev'
|
||||
},
|
||||
})
|
||||
console.log("createRelease success")
|
||||
|
||||
44
scripts/publish-github.js
Normal file
44
scripts/publish-github.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import axios from 'axios'
|
||||
import { getVersionContent } from './get-new-version.js'
|
||||
|
||||
|
||||
const GithubAccessToken = process.env.GITHUB_TOKEN
|
||||
if (!GithubAccessToken) {
|
||||
console.log("GithubAccessToken is empty")
|
||||
throw new Error("GithubAccessToken is empty")
|
||||
}
|
||||
// 创建release
|
||||
async function createRelease(versionTitle, content) {
|
||||
const response = await axios.request({
|
||||
method: 'POST',
|
||||
url: `https://api.github.com/repos/certd/certd/releases`,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${GithubAccessToken}`,
|
||||
},
|
||||
data: {
|
||||
tag_name: `v${versionTitle}`,
|
||||
name: `v${versionTitle}`,
|
||||
body: content,
|
||||
target_commitish: 'v2-dev'
|
||||
},
|
||||
})
|
||||
console.log("createRelease success")
|
||||
return response.data
|
||||
}
|
||||
|
||||
async function publishToGithub() {
|
||||
try{
|
||||
const { versionTitle, content } = getVersionContent()
|
||||
const release = await createRelease(versionTitle, content)
|
||||
console.log("publishToGithub success")
|
||||
} catch (error) {
|
||||
if (error?.response?.data){
|
||||
console.log("publishToGithub error:",error.response.data)
|
||||
}else{
|
||||
console.log("publishToGithub error:",error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishToGithub()
|
||||
Reference in New Issue
Block a user