5 Commits

2 changed files with 25 additions and 8 deletions

17
dist/index.js vendored
View File

@ -48144,6 +48144,10 @@ var crypto_js = __nccwpck_require__(4134);
function getIsTrue(v) {
const trueValue = ['true', 'True', 'TRUE']
return trueValue.includes(v)
}
async function run() {
try {
@ -48151,14 +48155,14 @@ async function run() {
const name = core.getInput("name")
const body = getReleaseBody(core.getInput("body"), core.getInput("body_path"))
const tag_name = core.getInput("tag_name")
const draft = Boolean(core.getInput("draft"))
const prerelease = Boolean(core.getInput("prerelease"))
const draft = getIsTrue(core.getInput("draft"))
const prerelease = getIsTrue(core.getInput("prerelease"))
const files = core.getInput("files")
const repository = core.getInput("repository")
const token = core.getInput("token")
const target_commitish = core.getInput("target_commitish")
const md5sum = core.getInput("md5sum")
const sha256sum = core.getInput("sha256sum")
const md5sum = getIsTrue(core.getInput("md5sum"))
const sha256sum = getIsTrue(core.getInput("sha256sum"))
const [owner, repo] = (repository).split("/")
@ -48265,6 +48269,7 @@ function paths(patterns) {
* @param {String} repo
* @param {Number} release_id
* @param {Array<String>} all_files
* @param {Map<String, Any>} additional parameters
*/
async function uploadFiles(client, owner, repo, release_id, all_files, params) {
params = params || {};
@ -48273,6 +48278,7 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
repo: repo,
id: release_id,
})
// deleted old release attachment
for (const filepath of all_files) {
for (const attachment of attachments) {
let will_deleted = [external_path_.basename(filepath), `${external_path_.basename(filepath)}.md5`, `${external_path_.basename(filepath)}.sha256`]
@ -48286,6 +48292,9 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
console.log(`Successfully deleted old release attachment ${attachment.name}`)
}
}
}
// upload new release attachment
for (const filepath of all_files) {
const content = external_fs_.readFileSync(filepath);
let blob = new external_buffer_.Blob([content]);
await client.repository.repoCreateReleaseAttachment({

16
main.js
View File

@ -8,6 +8,10 @@ import gitea from "gitea-api";
import path from 'path';
import CryptoJS from 'crypto-js';
function getIsTrue(v) {
const trueValue = ['true', 'True', 'TRUE']
return trueValue.includes(v)
}
async function run() {
try {
@ -15,14 +19,14 @@ async function run() {
const name = core.getInput("name")
const body = getReleaseBody(core.getInput("body"), core.getInput("body_path"))
const tag_name = core.getInput("tag_name")
const draft = Boolean(core.getInput("draft"))
const prerelease = Boolean(core.getInput("prerelease"))
const draft = getIsTrue(core.getInput("draft"))
const prerelease = getIsTrue(core.getInput("prerelease"))
const files = core.getInput("files")
const repository = core.getInput("repository")
const token = core.getInput("token")
const target_commitish = core.getInput("target_commitish")
const md5sum = core.getInput("md5sum")
const sha256sum = core.getInput("sha256sum")
const md5sum = getIsTrue(core.getInput("md5sum"))
const sha256sum = getIsTrue(core.getInput("sha256sum"))
const [owner, repo] = (repository).split("/")
@ -138,6 +142,7 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
repo: repo,
id: release_id,
})
// deleted old release attachment
for (const filepath of all_files) {
for (const attachment of attachments) {
let will_deleted = [path.basename(filepath), `${path.basename(filepath)}.md5`, `${path.basename(filepath)}.sha256`]
@ -151,6 +156,9 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
console.log(`Successfully deleted old release attachment ${attachment.name}`)
}
}
}
// upload new release attachment
for (const filepath of all_files) {
const content = fs.readFileSync(filepath);
let blob = new Blob([content]);
await client.repository.repoCreateReleaseAttachment({