mirror of
https://gitea.com/actions/gitea-release-action.git
synced 2026-01-12 02:22:06 +00:00
Compare commits
No commits in common. "main" and "v1.3.0" have entirely different histories.
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
An action to support publishing release to Gitea.
|
An action to support publishing release to Gitea.
|
||||||
|
|
||||||
Preserves the fields body, prerelease and name when pushing the release if no value is given.
|
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
The following are optional as `step.with` keys
|
The following are optional as `step.with` keys
|
||||||
|
|||||||
@ -10,14 +10,10 @@ inputs:
|
|||||||
body:
|
body:
|
||||||
description: "Note-worthy description of changes in release"
|
description: "Note-worthy description of changes in release"
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.event.release.body != '' && github.event.release.body || null }}
|
|
||||||
body_path:
|
|
||||||
description: "Path to load description of changes in this release"
|
|
||||||
required: false
|
|
||||||
name:
|
name:
|
||||||
description: "Gives the release a custom name. Defaults to tag name"
|
description: "Gives the release a custom name. Defaults to tag name"
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.event.release.name != '' && github.event.release.name || github.ref_name }}
|
default: ${{ github.ref_name }}
|
||||||
tag_name:
|
tag_name:
|
||||||
description: "Gives a tag name. Defaults to github.GITHUB_REF"
|
description: "Gives a tag name. Defaults to github.GITHUB_REF"
|
||||||
required: false
|
required: false
|
||||||
@ -25,11 +21,9 @@ inputs:
|
|||||||
draft:
|
draft:
|
||||||
description: "Creates a draft release. Defaults to false"
|
description: "Creates a draft release. Defaults to false"
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.event.release.draft || false }}
|
|
||||||
prerelease:
|
prerelease:
|
||||||
description: "Identify the release as a prerelease. Defaults to false"
|
description: "Identify the release as a prerelease. Defaults to false"
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.event.release.prerelease || false }}
|
|
||||||
files:
|
files:
|
||||||
description: "Newline-delimited list of path globs for asset files to upload"
|
description: "Newline-delimited list of path globs for asset files to upload"
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
28
dist/index.js
vendored
28
dist/index.js
vendored
@ -48144,10 +48144,6 @@ var crypto_js = __nccwpck_require__(4134);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getIsTrue(v) {
|
|
||||||
const trueValue = ['true', 'True', 'TRUE']
|
|
||||||
return trueValue.includes(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
@ -48155,14 +48151,14 @@ async function run() {
|
|||||||
const name = core.getInput("name")
|
const name = core.getInput("name")
|
||||||
const body = getReleaseBody(core.getInput("body"), core.getInput("body_path"))
|
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 = getIsTrue(core.getInput("draft"))
|
const draft = Boolean(core.getInput("draft"))
|
||||||
const prerelease = getIsTrue(core.getInput("prerelease"))
|
const prerelease = Boolean(core.getInput("prerelease"))
|
||||||
const files = core.getInput("files")
|
const files = core.getInput("files")
|
||||||
const repository = core.getInput("repository")
|
const repository = core.getInput("repository")
|
||||||
const token = core.getInput("token")
|
const token = core.getInput("token")
|
||||||
const target_commitish = core.getInput("target_commitish")
|
const target_commitish = core.getInput("target_commitish")
|
||||||
const md5sum = getIsTrue(core.getInput("md5sum"))
|
const md5sum = core.getInput("md5sum")
|
||||||
const sha256sum = getIsTrue(core.getInput("sha256sum"))
|
const sha256sum = core.getInput("sha256sum")
|
||||||
|
|
||||||
const [owner, repo] = (repository).split("/")
|
const [owner, repo] = (repository).split("/")
|
||||||
|
|
||||||
@ -48269,7 +48265,6 @@ function paths(patterns) {
|
|||||||
* @param {String} repo
|
* @param {String} repo
|
||||||
* @param {Number} release_id
|
* @param {Number} release_id
|
||||||
* @param {Array<String>} all_files
|
* @param {Array<String>} all_files
|
||||||
* @param {Map<String, Any>} additional parameters
|
|
||||||
*/
|
*/
|
||||||
async function uploadFiles(client, owner, repo, release_id, all_files, params) {
|
async function uploadFiles(client, owner, repo, release_id, all_files, params) {
|
||||||
params = params || {};
|
params = params || {};
|
||||||
@ -48278,19 +48273,10 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
|
|||||||
repo: repo,
|
repo: repo,
|
||||||
id: release_id,
|
id: release_id,
|
||||||
})
|
})
|
||||||
// deleted old release attachment
|
|
||||||
const will_deleted = new Set();
|
|
||||||
for (const filepath of all_files) {
|
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) {
|
for (const attachment of attachments) {
|
||||||
if (will_deleted.has(attachment.name)) {
|
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({
|
await client.repository.repoDeleteReleaseAttachment({
|
||||||
owner: owner,
|
owner: owner,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
@ -48300,8 +48286,6 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
|
|||||||
console.log(`Successfully deleted old release attachment ${attachment.name}`)
|
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);
|
const content = external_fs_.readFileSync(filepath);
|
||||||
let blob = new external_buffer_.Blob([content]);
|
let blob = new external_buffer_.Blob([content]);
|
||||||
await client.repository.repoCreateReleaseAttachment({
|
await client.repository.repoCreateReleaseAttachment({
|
||||||
|
|||||||
27
main.js
27
main.js
@ -8,10 +8,6 @@ import gitea from "gitea-api";
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import CryptoJS from 'crypto-js';
|
import CryptoJS from 'crypto-js';
|
||||||
|
|
||||||
function getIsTrue(v) {
|
|
||||||
const trueValue = ['true', 'True', 'TRUE']
|
|
||||||
return trueValue.includes(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
@ -19,14 +15,14 @@ async function run() {
|
|||||||
const name = core.getInput("name")
|
const name = core.getInput("name")
|
||||||
const body = getReleaseBody(core.getInput("body"), core.getInput("body_path"))
|
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 = getIsTrue(core.getInput("draft"))
|
const draft = Boolean(core.getInput("draft"))
|
||||||
const prerelease = getIsTrue(core.getInput("prerelease"))
|
const prerelease = Boolean(core.getInput("prerelease"))
|
||||||
const files = core.getInput("files")
|
const files = core.getInput("files")
|
||||||
const repository = core.getInput("repository")
|
const repository = core.getInput("repository")
|
||||||
const token = core.getInput("token")
|
const token = core.getInput("token")
|
||||||
const target_commitish = core.getInput("target_commitish")
|
const target_commitish = core.getInput("target_commitish")
|
||||||
const md5sum = getIsTrue(core.getInput("md5sum"))
|
const md5sum = core.getInput("md5sum")
|
||||||
const sha256sum = getIsTrue(core.getInput("sha256sum"))
|
const sha256sum = core.getInput("sha256sum")
|
||||||
|
|
||||||
const [owner, repo] = (repository).split("/")
|
const [owner, repo] = (repository).split("/")
|
||||||
|
|
||||||
@ -142,19 +138,10 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
|
|||||||
repo: repo,
|
repo: repo,
|
||||||
id: release_id,
|
id: release_id,
|
||||||
})
|
})
|
||||||
// deleted old release attachment
|
|
||||||
const will_deleted = new Set();
|
|
||||||
for (const filepath of all_files) {
|
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) {
|
for (const attachment of attachments) {
|
||||||
if (will_deleted.has(attachment.name)) {
|
let will_deleted = [path.basename(filepath), `${path.basename(filepath)}.md5`, `${path.basename(filepath)}.sha256`]
|
||||||
|
if (will_deleted.includes(attachment.name)) {
|
||||||
await client.repository.repoDeleteReleaseAttachment({
|
await client.repository.repoDeleteReleaseAttachment({
|
||||||
owner: owner,
|
owner: owner,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
@ -164,8 +151,6 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
|
|||||||
console.log(`Successfully deleted old release attachment ${attachment.name}`)
|
console.log(`Successfully deleted old release attachment ${attachment.name}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// upload new release attachment
|
|
||||||
for (const filepath of all_files) {
|
|
||||||
const content = fs.readFileSync(filepath);
|
const content = fs.readFileSync(filepath);
|
||||||
let blob = new Blob([content]);
|
let blob = new Blob([content]);
|
||||||
await client.repository.repoCreateReleaseAttachment({
|
await client.repository.repoCreateReleaseAttachment({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user