Merge pull request #46 from Spikatrix/master
Allow setting an explicit target_commitish
This commit is contained in:
commit
80d7a7e41c
@ -21,6 +21,7 @@ Optional Arguments
|
||||
- `prerelease`: Mark the release as a pre-release (Default: `false`).
|
||||
- `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).
|
||||
- `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: `""`).
|
||||
- `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).
|
||||
|
||||
|
@ -32,6 +32,8 @@ inputs:
|
||||
description: 'Explicitly set a release name. Defaults to empty which will cause the release to take the tag as name on GitHub.'
|
||||
body:
|
||||
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:
|
||||
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:
|
||||
|
2613
dist/index.js
vendored
2613
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
24
src/main.ts
24
src/main.ts
@ -7,6 +7,7 @@ import * as path from 'path'
|
||||
import * as glob from 'glob'
|
||||
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 createRelease = 'POST /repos/{owner}/{repo}/releases' as const
|
||||
const updateRelease =
|
||||
@ -33,7 +34,8 @@ async function get_release_by_tag(
|
||||
body: string,
|
||||
octokit: Octokit,
|
||||
overwrite: boolean,
|
||||
promote: boolean
|
||||
promote: boolean,
|
||||
target_commit: string
|
||||
): Promise<ReleaseByTagResp | CreateReleaseResp | UpdateReleaseResp> {
|
||||
let release: ReleaseByTagResp
|
||||
try {
|
||||
@ -48,13 +50,27 @@ async function get_release_by_tag(
|
||||
core.debug(
|
||||
`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, {
|
||||
...repo(),
|
||||
tag_name: tag,
|
||||
prerelease: prerelease,
|
||||
make_latest: make_latest ? 'true' : 'false',
|
||||
name: release_name,
|
||||
body: body
|
||||
body: body,
|
||||
target_commitish: target_commit
|
||||
})
|
||||
} else {
|
||||
throw error
|
||||
@ -194,6 +210,7 @@ async function run(): Promise<void> {
|
||||
const prerelease = core.getInput('prerelease') == 'true' ? true : false
|
||||
const make_latest = core.getInput('make_latest') != 'false' ? true : false
|
||||
const release_name = core.getInput('release_name')
|
||||
const target_commit = core.getInput('target_commit')
|
||||
const body = core
|
||||
.getInput('body')
|
||||
.replace(/%0A/gi, '\n')
|
||||
@ -209,7 +226,8 @@ async function run(): Promise<void> {
|
||||
body,
|
||||
octokit,
|
||||
overwrite,
|
||||
promote
|
||||
promote,
|
||||
target_commit
|
||||
)
|
||||
|
||||
if (file_glob) {
|
||||
|
Loading…
Reference in New Issue
Block a user