Merge pull request #100 from brandonkelly/make-latest
Add `make_latest` param
This commit is contained in:
commit
37a32b0167
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -31,6 +31,7 @@ jobs:
|
|||||||
tag: ci-test-${{ matrix.os }}-${{ github.run_id }}
|
tag: ci-test-${{ matrix.os }}-${{ github.run_id }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
prerelease: true
|
prerelease: true
|
||||||
|
make_latest: true
|
||||||
body: "rofl lol test%0Aianal %25 fubar"
|
body: "rofl lol test%0Aianal %25 fubar"
|
||||||
- name: Check that the uploaded asset is readable
|
- name: Check that the uploaded asset is readable
|
||||||
uses: actions/github-script@v2
|
uses: actions/github-script@v2
|
||||||
@ -47,6 +48,7 @@ jobs:
|
|||||||
tag: "ci-test-${{ matrix.os }}-${{ github.run_id }}",
|
tag: "ci-test-${{ matrix.os }}-${{ github.run_id }}",
|
||||||
})
|
})
|
||||||
assert.deepStrictEqual(release.data.prerelease, true)
|
assert.deepStrictEqual(release.data.prerelease, true)
|
||||||
|
assert.deepStrictEqual(release.data.make_latest, true)
|
||||||
assert.deepStrictEqual(release.data.body, "rofl lol test\nianal % fubar")
|
assert.deepStrictEqual(release.data.body, "rofl lol test\nianal % fubar")
|
||||||
assert.deepStrictEqual(release.data.assets[0].name, "TEST.md")
|
assert.deepStrictEqual(release.data.assets[0].name, "TEST.md")
|
||||||
const actual = child_process.execSync(`curl -Ls ${release.data.assets[0].browser_download_url}`)
|
const actual = child_process.execSync(`curl -Ls ${release.data.assets[0].browser_download_url}`)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
- 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.
|
||||||
|
|
||||||
## [2.5.0] - 2023-02-21
|
## [2.5.0] - 2023-02-21
|
||||||
- Add retry to upload release [#96](https://github.com/svenstaro/upload-release-action/pull/96) (thanks @sonphantrung)
|
- Add retry to upload release [#96](https://github.com/svenstaro/upload-release-action/pull/96) (thanks @sonphantrung)
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ 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`).
|
||||||
- `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`).
|
||||||
- `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).
|
||||||
- `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: '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. Defaults to "false".'
|
description: 'Mark the release as a pre-release. Defaults to "false".'
|
||||||
|
make_latest:
|
||||||
|
description: 'Mark the release the latest release for the repository. Defaults to "true".'
|
||||||
release_name:
|
release_name:
|
||||||
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:
|
||||||
|
7
dist/index.js
vendored
7
dist/index.js
vendored
@ -50,7 +50,7 @@ const createRelease = 'POST /repos/{owner}/{repo}/releases';
|
|||||||
const repoAssets = 'GET /repos/{owner}/{repo}/releases/{release_id}/assets';
|
const repoAssets = 'GET /repos/{owner}/{repo}/releases/{release_id}/assets';
|
||||||
const uploadAssets = 'POST {origin}/repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}';
|
const uploadAssets = 'POST {origin}/repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}';
|
||||||
const deleteAssets = 'DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}';
|
const deleteAssets = 'DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}';
|
||||||
function get_release_by_tag(tag, prerelease, release_name, body, octokit) {
|
function get_release_by_tag(tag, prerelease, make_latest, release_name, body, octokit) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
core.debug(`Getting release by tag ${tag}.`);
|
core.debug(`Getting release by tag ${tag}.`);
|
||||||
@ -60,7 +60,7 @@ function get_release_by_tag(tag, prerelease, release_name, body, octokit) {
|
|||||||
// If this returns 404, we need to create the release first.
|
// If this returns 404, we need to create the release first.
|
||||||
if (error.status === 404) {
|
if (error.status === 404) {
|
||||||
core.debug(`Release for tag ${tag} doesn't exist yet so we'll create it now.`);
|
core.debug(`Release for tag ${tag} doesn't exist yet so we'll create it now.`);
|
||||||
return yield octokit.request(createRelease, Object.assign(Object.assign({}, repo()), { tag_name: tag, prerelease: prerelease, name: release_name, body: body }));
|
return yield octokit.request(createRelease, Object.assign(Object.assign({}, repo()), { tag_name: tag, prerelease: prerelease, make_latest: make_latest, name: release_name, body: body }));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw error;
|
throw error;
|
||||||
@ -137,6 +137,7 @@ function run() {
|
|||||||
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 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 release_name = core.getInput('release_name');
|
const release_name = core.getInput('release_name');
|
||||||
const body = core
|
const body = core
|
||||||
.getInput('body')
|
.getInput('body')
|
||||||
@ -144,7 +145,7 @@ function run() {
|
|||||||
.replace(/%0D/gi, '\r')
|
.replace(/%0D/gi, '\r')
|
||||||
.replace(/%25/g, '%');
|
.replace(/%25/g, '%');
|
||||||
const octokit = github.getOctokit(token);
|
const octokit = github.getOctokit(token);
|
||||||
const release = yield get_release_by_tag(tag, prerelease, release_name, body, octokit);
|
const release = yield get_release_by_tag(tag, prerelease, make_latest, release_name, body, octokit);
|
||||||
if (file_glob) {
|
if (file_glob) {
|
||||||
const files = glob.sync(file);
|
const files = glob.sync(file);
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
|
@ -24,6 +24,7 @@ type UploadAssetResp = Endpoints[typeof uploadAssets]['response']
|
|||||||
async function get_release_by_tag(
|
async function get_release_by_tag(
|
||||||
tag: string,
|
tag: string,
|
||||||
prerelease: boolean,
|
prerelease: boolean,
|
||||||
|
make_latest: boolean,
|
||||||
release_name: string,
|
release_name: string,
|
||||||
body: string,
|
body: string,
|
||||||
octokit: Octokit
|
octokit: Octokit
|
||||||
@ -44,6 +45,7 @@ async function get_release_by_tag(
|
|||||||
...repo(),
|
...repo(),
|
||||||
tag_name: tag,
|
tag_name: tag,
|
||||||
prerelease: prerelease,
|
prerelease: prerelease,
|
||||||
|
make_latest: make_latest,
|
||||||
name: release_name,
|
name: release_name,
|
||||||
body: body
|
body: body
|
||||||
})
|
})
|
||||||
@ -153,6 +155,7 @@ 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 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 release_name = core.getInput('release_name')
|
const release_name = core.getInput('release_name')
|
||||||
const body = core
|
const body = core
|
||||||
.getInput('body')
|
.getInput('body')
|
||||||
@ -164,6 +167,7 @@ async function run(): Promise<void> {
|
|||||||
const release = await get_release_by_tag(
|
const release = await get_release_by_tag(
|
||||||
tag,
|
tag,
|
||||||
prerelease,
|
prerelease,
|
||||||
|
make_latest,
|
||||||
release_name,
|
release_name,
|
||||||
body,
|
body,
|
||||||
octokit
|
octokit
|
||||||
|
Loading…
Reference in New Issue
Block a user