You've already forked gitea-release-action
mirror of
https://gitea.com/actions/gitea-release-action.git
synced 2025-07-01 08:03:11 +07:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
f66c1c98f1 | |||
65a502e85c | |||
f119011bd6 |
45
dist/index.js
vendored
45
dist/index.js
vendored
@ -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 = core.getInput("draft") === 'true'
|
||||
const prerelease = core.getInput("prerelease") === 'true'
|
||||
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("/")
|
||||
|
||||
@ -48274,19 +48278,30 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
|
||||
repo: repo,
|
||||
id: release_id,
|
||||
})
|
||||
// deleted old release attachment
|
||||
const will_deleted = new Set();
|
||||
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`]
|
||||
if (will_deleted.includes(attachment.name)) {
|
||||
await client.repository.repoDeleteReleaseAttachment({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
id: release_id,
|
||||
attachmentId: attachment.id,
|
||||
})
|
||||
console.log(`Successfully deleted old release attachment ${attachment.name}`)
|
||||
}
|
||||
will_deleted.add(external_path_.basename(filepath));
|
||||
if (params.md5sum) {
|
||||
will_deleted.add(`${external_path_.basename(filepath)}.md5`);
|
||||
}
|
||||
if (params.sha256sum) {
|
||||
will_deleted.add(`${external_path_.basename(filepath)}.sha256`);
|
||||
}
|
||||
}
|
||||
for (const attachment of attachments) {
|
||||
if (will_deleted.has(attachment.name)) {
|
||||
await client.repository.repoDeleteReleaseAttachment({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
id: release_id,
|
||||
attachmentId: attachment.id,
|
||||
})
|
||||
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({
|
||||
|
45
main.js
45
main.js
@ -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 = core.getInput("draft") === 'true'
|
||||
const prerelease = core.getInput("prerelease") === 'true'
|
||||
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,19 +142,30 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
|
||||
repo: repo,
|
||||
id: release_id,
|
||||
})
|
||||
// deleted old release attachment
|
||||
const will_deleted = new Set();
|
||||
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`]
|
||||
if (will_deleted.includes(attachment.name)) {
|
||||
await client.repository.repoDeleteReleaseAttachment({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
id: release_id,
|
||||
attachmentId: attachment.id,
|
||||
})
|
||||
console.log(`Successfully deleted old release attachment ${attachment.name}`)
|
||||
}
|
||||
will_deleted.add(path.basename(filepath));
|
||||
if (params.md5sum) {
|
||||
will_deleted.add(`${path.basename(filepath)}.md5`);
|
||||
}
|
||||
if (params.sha256sum) {
|
||||
will_deleted.add(`${path.basename(filepath)}.sha256`);
|
||||
}
|
||||
}
|
||||
for (const attachment of attachments) {
|
||||
if (will_deleted.has(attachment.name)) {
|
||||
await client.repository.repoDeleteReleaseAttachment({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
id: release_id,
|
||||
attachmentId: attachment.id,
|
||||
})
|
||||
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({
|
||||
|
Reference in New Issue
Block a user