Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
tag: ci-test-${{ matrix.os }}-${{ github.run_id }}
overwrite: true
prerelease: true
make_latest: true
body: "rofl lol test%0Aianal %25 fubar"
- name: Check that the uploaded asset is readable
uses: actions/github-script@v2
Expand All @@ -47,6 +48,7 @@ jobs:
tag: "ci-test-${{ matrix.os }}-${{ github.run_id }}",
})
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.assets[0].name, "TEST.md")
const actual = child_process.execSync(`curl -Ls ${release.data.assets[0].browser_download_url}`)
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 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
- Add retry to upload release [#96](https://github.com/svenstaro/upload-release-action/pull/96) (thanks @sonphantrung)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
- `overwrite`: If an asset with the same name already exists, overwrite it (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).
- `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).
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ inputs:
description: 'If true the file can be a glob pattern, asset_name is ignored if this is true.'
prerelease:
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:
description: 'Explicitly set a release name. Defaults to empty which will cause the release to take the tag as name on GitHub.'
body:
Expand Down
7 changes: 4 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const createRelease = 'POST /repos/{owner}/{repo}/releases';
const repoAssets = 'GET /repos/{owner}/{repo}/releases/{release_id}/assets';
const uploadAssets = 'POST {origin}/repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}';
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* () {
try {
core.debug(`Getting release by tag ${tag}.`);
Expand All @@ -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 (error.status === 404) {
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 {
throw error;
Expand Down Expand Up @@ -137,14 +137,15 @@ function run() {
const file_glob = core.getInput('file_glob') == 'true' ? true : false;
const overwrite = core.getInput('overwrite') == '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 body = core
.getInput('body')
.replace(/%0A/gi, '\n')
.replace(/%0D/gi, '\r')
.replace(/%25/g, '%');
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) {
const files = glob.sync(file);
if (files.length > 0) {
Expand Down
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type UploadAssetResp = Endpoints[typeof uploadAssets]['response']
async function get_release_by_tag(
tag: string,
prerelease: boolean,
make_latest: boolean,
release_name: string,
body: string,
octokit: Octokit
Expand All @@ -44,6 +45,7 @@ async function get_release_by_tag(
...repo(),
tag_name: tag,
prerelease: prerelease,
make_latest: make_latest,
name: release_name,
body: body
})
Expand Down Expand Up @@ -149,6 +151,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 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 body = core
.getInput('body')
Expand All @@ -160,6 +163,7 @@ async function run(): Promise<void> {
const release = await get_release_by_tag(
tag,
prerelease,
make_latest,
release_name,
body,
octokit
Expand Down