3 Commits
v1.3.3 ... main

Author SHA1 Message Date
fe8e032280 Merge pull request #7 from n08i40k/main
Declare missing body_path input in action.yml
2025-07-28 09:19:09 +08:00
3dbdc45d61 docs: declare body_path input 2025-07-26 14:35:12 +04:00
f66c1c98f1 fix: deletion of old releases
Duplicate deletions occur when users generate their own .md5 and .sha256 files and do not use action's built-in md5sum and sha256sum functions.
issue: https://github.com/akkuman/gitea-release-action/issues/5
2025-06-25 10:53:06 +08:00
3 changed files with 40 additions and 23 deletions

View File

@ -10,6 +10,9 @@ inputs:
body:
description: "Note-worthy description of changes in release"
required: false
body_path:
description: "Path to load description of changes in this release"
required: false
name:
description: "Gives the release a custom name. Defaults to tag name"
required: false

13
dist/index.js vendored
View File

@ -48279,10 +48279,18 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
id: release_id,
})
// deleted old release attachment
const will_deleted = new Set();
for (const filepath of all_files) {
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) {
let will_deleted = [external_path_.basename(filepath), `${external_path_.basename(filepath)}.md5`, `${external_path_.basename(filepath)}.sha256`]
if (will_deleted.includes(attachment.name)) {
if (will_deleted.has(attachment.name)) {
await client.repository.repoDeleteReleaseAttachment({
owner: owner,
repo: repo,
@ -48292,7 +48300,6 @@ 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);

13
main.js
View File

@ -143,10 +143,18 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
id: release_id,
})
// deleted old release attachment
const will_deleted = new Set();
for (const filepath of all_files) {
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) {
let will_deleted = [path.basename(filepath), `${path.basename(filepath)}.md5`, `${path.basename(filepath)}.sha256`]
if (will_deleted.includes(attachment.name)) {
if (will_deleted.has(attachment.name)) {
await client.repository.repoDeleteReleaseAttachment({
owner: owner,
repo: repo,
@ -156,7 +164,6 @@ 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);