Default asset_name to the original file name (fixes #4)
This commit is contained in:
parent
c0f4101399
commit
588487bf09
@ -9,11 +9,12 @@ You must provide:
|
|||||||
|
|
||||||
- `repo_token`: Usually you'll want to set this to `${{ secrets.GITHUB_TOKEN }}`.
|
- `repo_token`: Usually you'll want to set this to `${{ secrets.GITHUB_TOKEN }}`.
|
||||||
- `file`: A local file to be uploaded as the asset.
|
- `file`: A local file to be uploaded as the asset.
|
||||||
- `asset_name`: The name the file gets as an asset on a release. Use `$tag` to include the tag name.
|
|
||||||
- `tag`: The tag to upload into. If you want the current event's tag, use `${{ github.ref }}` (the `refs/tags/` prefix will be automatically stripped).
|
- `tag`: The tag to upload into. If you want the current event's tag, use `${{ github.ref }}` (the `refs/tags/` prefix will be automatically stripped).
|
||||||
|
|
||||||
Optional Arguments
|
Optional Arguments
|
||||||
|
|
||||||
|
- `asset_name`: The name the file gets as an asset on a release. Use `$tag` to include the tag name. When not provided it will default to the filename.
|
||||||
|
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`)
|
- `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`).
|
- `overwrite`: If an asset with the same name already exists, overwrite it (Default: `false`).
|
||||||
- `prerelease`: Mark the release as a pre-release (Default: `false`).
|
- `prerelease`: Mark the release as a pre-release (Default: `false`).
|
||||||
|
19
action.yml
19
action.yml
@ -6,25 +6,24 @@ branding:
|
|||||||
color: orange
|
color: orange
|
||||||
inputs:
|
inputs:
|
||||||
repo_token:
|
repo_token:
|
||||||
description: 'GitHub token'
|
description: 'GitHub token.'
|
||||||
required: true
|
required: true
|
||||||
file:
|
file:
|
||||||
description: 'Local file to upload'
|
description: 'Local file to upload.'
|
||||||
required: true
|
|
||||||
asset_name:
|
|
||||||
description: 'Name of the asset'
|
|
||||||
required: true
|
required: true
|
||||||
tag:
|
tag:
|
||||||
description: 'Tag to use as a release'
|
description: 'Tag to use as a release.'
|
||||||
required: true
|
required: true
|
||||||
|
asset_name:
|
||||||
|
description: 'Name of the asset. When not provided will use the file name. Unused if file_glob is set to "true".'
|
||||||
overwrite:
|
overwrite:
|
||||||
description: 'Overwrite the release in case it already exists'
|
description: 'Overwrite the release in case it already exists.'
|
||||||
file_glob:
|
file_glob:
|
||||||
description: 'If true the file can be a glob pattern, asset_name is ignored if this is true'
|
description: 'If true the file can be a glob pattern, asset_name is ignored if this is true.'
|
||||||
prerelease:
|
prerelease:
|
||||||
description: 'Mark the release as a pre-release'
|
description: 'Mark the release as a pre-release.'
|
||||||
body:
|
body:
|
||||||
description: 'Content of the release text'
|
description: 'Content of the release text.'
|
||||||
outputs:
|
outputs:
|
||||||
browser_download_url:
|
browser_download_url:
|
||||||
description: 'The publicly available URL of the asset.'
|
description: 'The publicly available URL of the asset.'
|
||||||
|
6
dist/index.js
vendored
6
dist/index.js
vendored
@ -2284,9 +2284,9 @@ function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const asset_name = core
|
const asset_name = core.getInput('asset_name') !== ''
|
||||||
.getInput('asset_name', { required: true })
|
? core.getInput('asset_name').replace(/\$tag/g, tag)
|
||||||
.replace(/\$tag/g, tag);
|
: path.basename(file);
|
||||||
const asset_download_url = yield upload_to_release(release, file, asset_name, tag, overwrite, octokit);
|
const asset_download_url = yield upload_to_release(release, file, asset_name, tag, overwrite, octokit);
|
||||||
core.setOutput('browser_download_url', asset_download_url);
|
core.setOutput('browser_download_url', asset_download_url);
|
||||||
}
|
}
|
||||||
|
@ -131,9 +131,10 @@ async function run(): Promise<void> {
|
|||||||
core.setFailed('No files matching the glob pattern found.')
|
core.setFailed('No files matching the glob pattern found.')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const asset_name = core
|
const asset_name =
|
||||||
.getInput('asset_name', {required: true})
|
core.getInput('asset_name') !== ''
|
||||||
.replace(/\$tag/g, tag)
|
? core.getInput('asset_name').replace(/\$tag/g, tag)
|
||||||
|
: path.basename(file)
|
||||||
const asset_download_url = await upload_to_release(
|
const asset_download_url = await upload_to_release(
|
||||||
release,
|
release,
|
||||||
file,
|
file,
|
||||||
|
Loading…
Reference in New Issue
Block a user