Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84f3aed823 | ||
|
|
f9770cdf31 | ||
|
|
1b2bf5c959 | ||
|
|
265508bc9f | ||
|
|
04733e069f | ||
|
|
7b5b755e5b | ||
|
|
17449a21ea | ||
|
|
ec2ff03a5a | ||
|
|
ff23fb2574 | ||
|
|
8e438350b0 | ||
|
|
fe68892921 | ||
|
|
a13e7b5d40 | ||
|
|
a4bae284e7 | ||
|
|
c19ddf4c20 | ||
|
|
2d9c0f4337 | ||
|
|
615015f76e | ||
|
|
e3374ce5b6 | ||
|
|
1beeb572c1 | ||
|
|
5206d34958 | ||
|
|
80d7a7e41c | ||
|
|
5eb2ffd70b | ||
|
|
07af2f374a | ||
|
|
5164410c7d | ||
|
|
f47fb36ff1 | ||
|
|
212d4babf8 | ||
|
|
7670b98fa0 | ||
|
|
ac438791c4 | ||
|
|
545e4c402b | ||
|
|
7d304ee154 | ||
|
|
3cff01dd32 | ||
|
|
a724093295 |
@ -24,6 +24,7 @@
|
|||||||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||||
"@typescript-eslint/no-array-constructor": "error",
|
"@typescript-eslint/no-array-constructor": "error",
|
||||||
"@typescript-eslint/no-empty-interface": "error",
|
"@typescript-eslint/no-empty-interface": "error",
|
||||||
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
"@typescript-eslint/no-extraneous-class": "error",
|
"@typescript-eslint/no-extraneous-class": "error",
|
||||||
"@typescript-eslint/no-for-in-array": "error",
|
"@typescript-eslint/no-for-in-array": "error",
|
||||||
"@typescript-eslint/no-inferrable-types": "error",
|
"@typescript-eslint/no-inferrable-types": "error",
|
||||||
|
|||||||
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,7 +1,17 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [2.9.0] - 2024-02-22
|
||||||
|
- Allow seeting a release as draft [#112](https://github.com/svenstaro/upload-release-action/pull/112) (thanks @ShonP40)
|
||||||
|
|
||||||
|
## [2.8.0] - 2024-02-21
|
||||||
|
- Bump all deps
|
||||||
|
- Update to node 20
|
||||||
|
|
||||||
|
## [2.7.0] - 2023-07-28
|
||||||
|
- Allow setting an explicit target_commitish [#46](https://github.com/svenstaro/upload-release-action/pull/46) (thanks @Spikatrix)
|
||||||
|
|
||||||
## [2.6.1] - 2023-05-31
|
## [2.6.1] - 2023-05-31
|
||||||
- Do not overwrite body or name if empty [#108](https://github.com/svenstaro/upload-release-action/pull/108) (thanks regevbr)
|
- Do not overwrite body or name if empty [#108](https://github.com/svenstaro/upload-release-action/pull/108) (thanks @regevbr)
|
||||||
|
|
||||||
## [2.6.0] - 2023-05-23
|
## [2.6.0] - 2023-05-23
|
||||||
- Add `make_latest` input parameter. Can be set to `false` to prevent the created release from being marked as the latest release for the repository [#100](https://github.com/svenstaro/upload-release-action/pull/100) (thanks @brandonkelly)
|
- Add `make_latest` input parameter. Can be set to `false` to prevent the created release from being marked as the latest release for the repository [#100](https://github.com/svenstaro/upload-release-action/pull/100) (thanks @brandonkelly)
|
||||||
|
|||||||
@ -18,9 +18,11 @@ Optional Arguments
|
|||||||
- `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`).
|
||||||
- `promote`: If a prerelease already exists, promote it to a release (Default: `false`).
|
- `promote`: If a prerelease already exists, promote it to a release (Default: `false`).
|
||||||
|
- `draft`: Sets the release as a draft instead of publishing it, allowing you to make any edits needed before releasing (Default: `false`).
|
||||||
- `prerelease`: Mark the release as a pre-release (Default: `false`).
|
- `prerelease`: Mark the release as a pre-release (Default: `false`).
|
||||||
- `make_latest`: Mark the release as the latest release for the repository (Default: `true`).
|
- `make_latest`: Mark the release as the latest release for the repository (Default: `true`).
|
||||||
- `release_name`: Explicitly set a release name. (Defaults: implicitly same as `tag` via GitHub API).
|
- `release_name`: Explicitly set a release name. (Defaults: implicitly same as `tag` via GitHub API).
|
||||||
|
- `target_commit`: Sets the commit hash or branch for the tag to be based on (Default: the default branch, usually `main`).
|
||||||
- `body`: Content of the release text (Default: `""`).
|
- `body`: Content of the release text (Default: `""`).
|
||||||
- `repo_name`: Specify the name of the GitHub repository in which the GitHub release will be created, edited, and deleted. If the repository is other than the current, it is required to create a personal access token with `repo`, `user`, `admin:repo_hook` scopes to the foreign repository and add it as a secret. (Default: current repository).
|
- `repo_name`: Specify the name of the GitHub repository in which the GitHub release will be created, edited, and deleted. If the repository is other than the current, it is required to create a personal access token with `repo`, `user`, `admin:repo_hook` scopes to the foreign repository and add it as a secret. (Default: current repository).
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,8 @@ inputs:
|
|||||||
description: 'Promote a prerelease to release. Defaults to "false".'
|
description: 'Promote a prerelease to release. Defaults to "false".'
|
||||||
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.'
|
||||||
|
draft:
|
||||||
|
description: 'Mark the release as a draft. Defaults to "false".'
|
||||||
prerelease:
|
prerelease:
|
||||||
description: 'Mark the release as a pre-release. Defaults to "false".'
|
description: 'Mark the release as a pre-release. Defaults to "false".'
|
||||||
make_latest:
|
make_latest:
|
||||||
@ -32,11 +34,13 @@ inputs:
|
|||||||
description: 'Explicitly set a release name. Defaults to empty which will cause the release to take the tag as name on GitHub.'
|
description: 'Explicitly set a release name. Defaults to empty which will cause the release to take the tag as name on GitHub.'
|
||||||
body:
|
body:
|
||||||
description: 'Content of the release text. Empty by default.'
|
description: 'Content of the release text. Empty by default.'
|
||||||
|
target_commit:
|
||||||
|
description: 'Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository\"s default branch (usually `main`).'
|
||||||
repo_name:
|
repo_name:
|
||||||
description: 'Specify the name of the GitHub repository in which the GitHub release will be created, edited, and deleted. If the repository is other than the current, it is required to create a personal access token with `repo`, `user`, `admin:repo_hook` scopes to the foreign repository and add it as a secret. Defaults to the current repository'
|
description: 'Specify the name of the GitHub repository in which the GitHub release will be created, edited, and deleted. If the repository is other than the current, it is required to create a personal access token with `repo`, `user`, `admin:repo_hook` scopes to the foreign repository and add it as a secret. Defaults to the current repository'
|
||||||
outputs:
|
outputs:
|
||||||
browser_download_url:
|
browser_download_url:
|
||||||
description: 'The publicly available URL of the asset.'
|
description: 'The publicly available URL of the asset.'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
37313
dist/index.js
vendored
37313
dist/index.js
vendored
File diff suppressed because one or more lines are too long
9171
package-lock.json
generated
9171
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "upload-release-action",
|
"name": "upload-release-action",
|
||||||
"version": "2.6.1",
|
"version": "2.9.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Upload files to a GitHub release",
|
"description": "Upload files to a GitHub release",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
@ -27,26 +27,26 @@
|
|||||||
"author": "Sven-Hendrik Haase",
|
"author": "Sven-Hendrik Haase",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^6.0.0",
|
||||||
"@lifeomic/attempt": "^3.0.3",
|
"@lifeomic/attempt": "^3.0.3",
|
||||||
"@octokit/core": "^4.2.1",
|
"@octokit/core": "^5.1.0",
|
||||||
"glob": "^10"
|
"glob": "^10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@octokit/types": "^9.2.3",
|
"@octokit/types": "^12.5.0",
|
||||||
"@types/glob": "^8",
|
|
||||||
"@types/jest": "^29",
|
"@types/jest": "^29",
|
||||||
"@types/node": "^16",
|
"@types/node": "^20",
|
||||||
"@typescript-eslint/parser": "^5",
|
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
||||||
"@vercel/ncc": "^0.36.1",
|
"@typescript-eslint/parser": "^7",
|
||||||
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint": "^8",
|
"eslint": "^8",
|
||||||
"eslint-plugin-github": "^4.7",
|
"eslint-plugin-github": "^4.10",
|
||||||
"eslint-plugin-jest": "^27",
|
"eslint-plugin-jest": "^27",
|
||||||
"jest": "^29",
|
"jest": "^29",
|
||||||
"jest-circus": "^29",
|
"jest-circus": "^29",
|
||||||
"js-yaml": "^4",
|
"js-yaml": "^4",
|
||||||
"prettier": "^2.8",
|
"prettier": "^3.2",
|
||||||
"ts-jest": "^29",
|
"ts-jest": "^29",
|
||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
}
|
}
|
||||||
|
|||||||
30
src/main.ts
30
src/main.ts
@ -7,6 +7,7 @@ import * as path from 'path'
|
|||||||
import * as glob from 'glob'
|
import * as glob from 'glob'
|
||||||
import {retry} from '@lifeomic/attempt'
|
import {retry} from '@lifeomic/attempt'
|
||||||
|
|
||||||
|
const getRef = 'GET /repos/{owner}/{repo}/git/ref/{ref}' as const
|
||||||
const releaseByTag = 'GET /repos/{owner}/{repo}/releases/tags/{tag}' as const
|
const releaseByTag = 'GET /repos/{owner}/{repo}/releases/tags/{tag}' as const
|
||||||
const createRelease = 'POST /repos/{owner}/{repo}/releases' as const
|
const createRelease = 'POST /repos/{owner}/{repo}/releases' as const
|
||||||
const updateRelease =
|
const updateRelease =
|
||||||
@ -27,13 +28,15 @@ type UpdateReleaseParams = Endpoints[typeof updateRelease]['parameters']
|
|||||||
|
|
||||||
async function get_release_by_tag(
|
async function get_release_by_tag(
|
||||||
tag: string,
|
tag: string,
|
||||||
|
draft: boolean,
|
||||||
prerelease: boolean,
|
prerelease: boolean,
|
||||||
make_latest: boolean,
|
make_latest: boolean,
|
||||||
release_name: string,
|
release_name: string,
|
||||||
body: string,
|
body: string,
|
||||||
octokit: Octokit,
|
octokit: Octokit,
|
||||||
overwrite: boolean,
|
overwrite: boolean,
|
||||||
promote: boolean
|
promote: boolean,
|
||||||
|
target_commit: string
|
||||||
): Promise<ReleaseByTagResp | CreateReleaseResp | UpdateReleaseResp> {
|
): Promise<ReleaseByTagResp | CreateReleaseResp | UpdateReleaseResp> {
|
||||||
let release: ReleaseByTagResp
|
let release: ReleaseByTagResp
|
||||||
try {
|
try {
|
||||||
@ -48,13 +51,30 @@ async function get_release_by_tag(
|
|||||||
core.debug(
|
core.debug(
|
||||||
`Release for tag ${tag} doesn't exist yet so we'll create it now.`
|
`Release for tag ${tag} doesn't exist yet so we'll create it now.`
|
||||||
)
|
)
|
||||||
|
if (target_commit) {
|
||||||
|
try {
|
||||||
|
await octokit.request(getRef, {
|
||||||
|
...repo(),
|
||||||
|
ref: `tags/${tag}`
|
||||||
|
})
|
||||||
|
core.warning(
|
||||||
|
`Ignoring target_commit as the tag ${tag} already exists`
|
||||||
|
)
|
||||||
|
} catch (tagError: any) {
|
||||||
|
if (tagError.status !== 404) {
|
||||||
|
throw tagError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return await octokit.request(createRelease, {
|
return await octokit.request(createRelease, {
|
||||||
...repo(),
|
...repo(),
|
||||||
tag_name: tag,
|
tag_name: tag,
|
||||||
|
draft: draft,
|
||||||
prerelease: prerelease,
|
prerelease: prerelease,
|
||||||
make_latest: make_latest ? 'true' : 'false',
|
make_latest: make_latest ? 'true' : 'false',
|
||||||
name: release_name,
|
name: release_name,
|
||||||
body: body
|
body: body,
|
||||||
|
target_commitish: target_commit
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
throw error
|
throw error
|
||||||
@ -191,9 +211,11 @@ async function run(): Promise<void> {
|
|||||||
const file_glob = core.getInput('file_glob') == 'true' ? true : false
|
const file_glob = core.getInput('file_glob') == 'true' ? true : false
|
||||||
const overwrite = core.getInput('overwrite') == 'true' ? true : false
|
const overwrite = core.getInput('overwrite') == 'true' ? true : false
|
||||||
const promote = core.getInput('promote') == 'true' ? true : false
|
const promote = core.getInput('promote') == 'true' ? true : false
|
||||||
|
const draft = core.getInput('draft') == 'true' ? true : false
|
||||||
const prerelease = core.getInput('prerelease') == 'true' ? true : false
|
const prerelease = core.getInput('prerelease') == 'true' ? true : false
|
||||||
const make_latest = core.getInput('make_latest') != 'false' ? true : false
|
const make_latest = core.getInput('make_latest') != 'false' ? true : false
|
||||||
const release_name = core.getInput('release_name')
|
const release_name = core.getInput('release_name')
|
||||||
|
const target_commit = core.getInput('target_commit')
|
||||||
const body = core
|
const body = core
|
||||||
.getInput('body')
|
.getInput('body')
|
||||||
.replace(/%0A/gi, '\n')
|
.replace(/%0A/gi, '\n')
|
||||||
@ -203,13 +225,15 @@ async function run(): Promise<void> {
|
|||||||
const octokit = github.getOctokit(token)
|
const octokit = github.getOctokit(token)
|
||||||
const release = await get_release_by_tag(
|
const release = await get_release_by_tag(
|
||||||
tag,
|
tag,
|
||||||
|
draft,
|
||||||
prerelease,
|
prerelease,
|
||||||
make_latest,
|
make_latest,
|
||||||
release_name,
|
release_name,
|
||||||
body,
|
body,
|
||||||
octokit,
|
octokit,
|
||||||
overwrite,
|
overwrite,
|
||||||
promote
|
promote,
|
||||||
|
target_commit
|
||||||
)
|
)
|
||||||
|
|
||||||
if (file_glob) {
|
if (file_glob) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user