feat: Introduce duplicated_error option
This commit is contained in:
parent
4e5de20777
commit
ade2c57f28
@ -17,6 +17,7 @@ Optional Arguments
|
||||
This is not used if `file_glob` is set to `true`.
|
||||
- `file_glob`: If set to true, the file argument can be a glob pattern (`asset_name` is ignored in this case) (Default: `false`)
|
||||
- `overwrite`: If an asset with the same name already exists, overwrite it (Default: `false`).
|
||||
- `duplicated_error`: If an asset with the same name already exists, throw error (Default: `true`).
|
||||
- `prerelease`: Mark the release as a pre-release (Default: `false`).
|
||||
- `release_name`: Explicitly set a release name. (Defaults: implicitly same as `tag` via GitHub API).
|
||||
- `body`: Content of the release text (Default: `""`).
|
||||
|
@ -17,7 +17,10 @@ inputs:
|
||||
asset_name:
|
||||
description: 'Name of the asset. When not provided will use the file name. Unused if file_glob is set to "true".'
|
||||
overwrite:
|
||||
description: 'Overwrite the release in case it already exists.'
|
||||
description: 'If an asset with the same name already exists, overwrite it.'
|
||||
duplicated_error:
|
||||
description: 'If an asset with the same name already exists, throw error.'
|
||||
default: "true"
|
||||
file_glob:
|
||||
description: 'If true the file can be a glob pattern, asset_name is ignored if this is true.'
|
||||
prerelease:
|
||||
|
10
src/main.ts
10
src/main.ts
@ -49,6 +49,7 @@ async function upload_to_release(
|
||||
asset_name: string,
|
||||
tag: string,
|
||||
overwrite: boolean,
|
||||
duplicated_error: boolean,
|
||||
octokit: Octokit
|
||||
): Promise<undefined | string> {
|
||||
const stat = fs.statSync(file)
|
||||
@ -78,7 +79,12 @@ async function upload_to_release(
|
||||
asset_id: duplicate_asset.id
|
||||
})
|
||||
} else {
|
||||
core.setFailed(`An asset called ${asset_name} already exists.`)
|
||||
if (duplicated_error) {
|
||||
core.setFailed(`An asset called ${asset_name} already exists.`)
|
||||
return duplicate_asset.browser_download_url
|
||||
}
|
||||
|
||||
core.warn(`An asset called ${asset_name} already exists.`)
|
||||
return duplicate_asset.browser_download_url
|
||||
}
|
||||
} else {
|
||||
@ -134,6 +140,7 @@ async function run(): Promise<void> {
|
||||
|
||||
const file_glob = core.getInput('file_glob') == 'true' ? true : false
|
||||
const overwrite = core.getInput('overwrite') == 'true' ? true : false
|
||||
const duplicated_error = core.getInput('duplicated_error') == 'true' ? true : false
|
||||
const prerelease = core.getInput('prerelease') == 'true' ? true : false
|
||||
const release_name = core.getInput('release_name')
|
||||
const body = core.getInput('body')
|
||||
@ -158,6 +165,7 @@ async function run(): Promise<void> {
|
||||
asset_name,
|
||||
tag,
|
||||
overwrite,
|
||||
duplicated_error,
|
||||
octokit
|
||||
)
|
||||
core.setOutput('browser_download_url', asset_download_url)
|
||||
|
Loading…
Reference in New Issue
Block a user