43 Commits
2.1.0 ... 2.3.0

Author SHA1 Message Date
Sven-Hendrik Haase
133984371c 2.3.0 2022-06-05 19:04:28 +02:00
Sven-Hendrik Haase
c2b649c57e Merge pull request #72 from svenstaro/dependabot/npm_and_yarn/node-fetch-2.6.7
Bump node-fetch from 2.6.1 to 2.6.7
2022-05-28 07:07:29 +02:00
Sven-Hendrik Haase
eb625cd0ad Merge pull request #71 from svenstaro/dependabot/npm_and_yarn/ansi-regex-4.1.1
Bump ansi-regex from 4.1.0 to 4.1.1
2022-05-28 07:07:19 +02:00
dependabot[bot]
99cbd251b2 Bump node-fetch from 2.6.1 to 2.6.7
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-28 05:05:58 +00:00
dependabot[bot]
a6824c9e54 Bump ansi-regex from 4.1.0 to 4.1.1
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-28 05:05:57 +00:00
Sven-Hendrik Haase
6eb74c809d Merge pull request #67 from svenstaro/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-05-28 07:05:23 +02:00
Sven-Hendrik Haase
8ec375d911 Merge pull request #69 from leighmcculloch/patch-1
Add defaults to commonly set fields to reduce setup
2022-05-28 07:04:25 +02:00
Leigh McCulloch
8d45355ac2 Update README.md 2022-04-04 00:56:40 -07:00
Leigh McCulloch
7d269bd712 Add defaults to commonly set fields to reduce setup 2022-04-04 00:54:54 -07:00
dependabot[bot]
c71fb95114 Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-24 13:12:37 +00:00
Sven-Hendrik Haase
1d71c233f7 Merge pull request #47 from svenstaro/dependabot/npm_and_yarn/y18n-4.0.1
Bump y18n from 4.0.0 to 4.0.1
2021-11-18 06:45:47 +01:00
Sven-Hendrik Haase
78ec101a88 Merge pull request #58 from svenstaro/dependabot/npm_and_yarn/tmpl-1.0.5
Bump tmpl from 1.0.4 to 1.0.5
2021-11-18 06:45:36 +01:00
dependabot[bot]
d8cafc3c87 Bump tmpl from 1.0.4 to 1.0.5
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-21 12:11:16 +00:00
Sven-Hendrik Haase
a70d06e688 Merge pull request #55 from svenstaro/dependabot/npm_and_yarn/path-parse-1.0.7
Bump path-parse from 1.0.6 to 1.0.7
2021-08-24 05:10:49 +02:00
dependabot[bot]
072f986a7c Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-11 09:35:24 +00:00
Sven-Hendrik Haase
2f88c7710e Merge pull request #53 from svenstaro/dependabot/npm_and_yarn/glob-parent-5.1.2
Bump glob-parent from 5.1.1 to 5.1.2
2021-06-13 08:08:56 +02:00
dependabot[bot]
ee200cfabc Bump glob-parent from 5.1.1 to 5.1.2
Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.1 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gulpjs/glob-parent/compare/v5.1.1...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 23:29:23 +00:00
Sven-Hendrik Haase
82b6f4a2ea Merge pull request #52 from svenstaro/dependabot/npm_and_yarn/ws-7.4.6
Bump ws from 7.3.1 to 7.4.6
2021-05-29 19:55:57 +02:00
dependabot[bot]
3f585610ac Bump ws from 7.3.1 to 7.4.6
Bumps [ws](https://github.com/websockets/ws) from 7.3.1 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.3.1...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-29 13:48:38 +00:00
Sven-Hendrik Haase
61a0748878 Merge pull request #51 from svenstaro/dependabot/npm_and_yarn/hosted-git-info-2.8.9
Bump hosted-git-info from 2.8.8 to 2.8.9
2021-05-10 23:51:40 +02:00
dependabot[bot]
743e8a90bd Bump hosted-git-info from 2.8.8 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-10 21:23:58 +00:00
Sven-Hendrik Haase
15ebdecb60 Merge pull request #50 from svenstaro/dependabot/npm_and_yarn/lodash-4.17.21
Bump lodash from 4.17.19 to 4.17.21
2021-05-10 23:23:15 +02:00
dependabot[bot]
57649ec774 Bump lodash from 4.17.19 to 4.17.21
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-10 09:07:37 +00:00
Sven-Hendrik Haase
f9dffdf5a6 Merge pull request #49 from pranjal-joshi/docs-update
Example added for feeding a file to the body tag
2021-05-02 07:48:42 +02:00
Pranjal Joshi
71756ac6ec Example added for feeding a file to the body tag 2021-05-02 10:28:27 +05:30
Pranjal Joshi
2b6c678b07 Example added for feeding file to body tag 2021-05-02 10:24:18 +05:30
dependabot[bot]
a95c4e7c33 Bump y18n from 4.0.0 to 4.0.1
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-30 23:00:12 +00:00
Sven-Hendrik Haase
4e5de20777 Merge pull request #40 from svenstaro/dependabot/npm_and_yarn/node-notifier-8.0.1
Bump node-notifier from 8.0.0 to 8.0.1
2020-12-22 10:40:51 +01:00
dependabot[bot]
3f38d56a41 Bump node-notifier from 8.0.0 to 8.0.1
Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/mikaelbr/node-notifier/releases)
- [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md)
- [Commits](https://github.com/mikaelbr/node-notifier/compare/v8.0.0...v8.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-22 08:20:52 +00:00
Sven-Hendrik Haase
483c1e56f9 This is 2.2.1 2020-12-16 05:19:13 +01:00
Sven-Hendrik Haase
1899a6bd0d Merge pull request #36 from djpohly/paginate-assets
Use octokit.paginate to get all release assets
2020-12-16 05:12:32 +01:00
Devin J. Pohly
bf76499b98 Use octokit.paginate to get all release assets
Fixes #35, in which assets not on the first page would not be detected
and deleted when trying to overwrite, resulting in an "already_exists"
error.
2020-12-02 16:25:13 -06:00
Sven-Hendrik Haase
e74ff71f7d Prepare 2.2.0 2020-10-07 18:46:11 +02:00
Sven-Hendrik Haase
697a9f190e Merge pull request #25 from kittaakos/GH-24--custom-owner-repo
GH-24: Support for creating a new GH release in a foreign repository.
2020-10-07 18:41:33 +02:00
Akos Kitta
011f7957ff GH-24: Support for custom owner/repo config.
To be able to manage foreign repositories.
The `owner` and `repo` is extracted from the `repo_name`.
Otherwise, it uses the current repository.

Closes #24

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
2020-10-05 15:33:05 +02:00
Sven-Hendrik Haase
4f71b6d30b Merge pull request #31 from svenstaro/dependabot/npm_and_yarn/actions/core-1.2.6
Bump @actions/core from 1.2.4 to 1.2.6
2020-10-01 19:24:21 +02:00
dependabot[bot]
24b1cacbb1 Bump @actions/core from 1.2.4 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.4 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 17:17:42 +00:00
Sven-Hendrik Haase
4ce0a13e83 This is 2.1.1 2020-09-25 05:40:59 +02:00
Sven-Hendrik Haase
6ca3eb1422 Add CHANGELOG entry for 2.1.1 2020-09-25 05:40:29 +02:00
Sven-Hendrik Haase
54a6699008 Merge pull request #27 from kittaakos/GH-26
GH-26: Fixed ignored `release_name` option.
2020-09-25 05:18:30 +02:00
Sven-Hendrik Haase
afb12c9a16 Merge pull request #29 from svenstaro/dependabot/npm_and_yarn/node-fetch-2.6.1
Bump node-fetch from 2.6.0 to 2.6.1
2020-09-12 15:18:12 +02:00
dependabot[bot]
89767936cf Bump node-fetch from 2.6.0 to 2.6.1
Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/bitinn/node-fetch/compare/v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-12 07:26:42 +00:00
Akos Kitta
d3d2e8da76 GH-26: Fixed ignored release_name option.
`name` should be used when creating a new release.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
2020-09-02 16:57:09 +02:00
7 changed files with 1845 additions and 1142 deletions

View File

@@ -1,5 +1,18 @@
# Changelog
## [2.3.0] - 2022-06-05
- Now defaults `repo_token` to `${{ github.token }}` and `tag` to `${{ github.ref }}` [#69](https://github.com/svenstaro/upload-release-action/pull/69) (thanks @leighmcculloch)
## [2.2.1] - 2020-12-16
- Added support for the GitHub pagination API for repositories with many releases [#36](https://github.com/svenstaro/upload-release-action/pull/36) (thanks @djpohly)
## [2.2.0] - 2020-10-07
- Add support for ceating a new release in a foreign repository [#25](https://github.com/svenstaro/upload-release-action/pull/25) (thanks @kittaakos)
- Upgrade all deps
## [2.1.1] - 2020-09-25
- Fix `release_name` option [#27](https://github.com/svenstaro/upload-release-action/pull/27) (thanks @kittaakos)
## [2.1.0] - 2020-08-10
- Strip refs/heads/ from the input tag [#23](https://github.com/svenstaro/upload-release-action/pull/23) (thanks @OmarEmaraDev)

View File

@@ -7,19 +7,20 @@ It runs on all operating systems types offered by GitHub.
You must provide:
- `repo_token`: Usually you'll want to set this to `${{ secrets.GITHUB_TOKEN }}`.
- `file`: A local file to be uploaded as the asset.
- `tag`: The tag to upload into. If you want the current event's tag or branch name, use `${{ github.ref }}` (the `refs/tags/` and `refs/heads/` prefixes will be automatically stripped).
Optional Arguments
- `repo_token`: Defaults to `github.token`.
- `tag`: The tag to upload into. If you want the current event's tag or branch name, use `${{ github.ref }}` (the `refs/tags/` and `refs/heads/` prefixes will be automatically stripped). Defaults to `github.ref`.
- `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`)
- `overwrite`: If an asset with the same name already exists, overwrite it (Default: `false`).
- `prerelease`: Mark the release as a pre-release (Default: `false`).
- `release_name`: Explicitly set a release name. (Defaults: implicitly same as `tag` via GitHub API).
- `body`: Content of the release text (Defaut: `""`).
- `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).
## Output variables
@@ -101,12 +102,14 @@ jobs:
```
Example with `file_glob`:
```yaml
name: Publish
on:
push:
tags:
- '*'
jobs:
build:
name: Publish binaries
@@ -125,6 +128,85 @@ jobs:
file_glob: true
```
Example for creating a release in a foreign repository using `repo_name`:
```yaml
name: Publish
on:
push:
tags:
- '*'
jobs:
build:
name: Publish binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --release
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_name: owner/repository-name
# A personal access token for the GitHub repository in which the release will be created and edited.
# It is recommended to create the access token with the following scopes: `repo, user, admin:repo_hook`.
repo_token: ${{ secrets.YOUR_PERSONAL_ACCESS_TOKEN }}
file: target/release/mything
asset_name: mything
tag: ${{ github.ref }}
overwrite: true
body: "This is my release text"
```
**Example for feeding a file from repo to the `body` tag:**
This example covers following points:
* Reading a file present on the repo. For example, `release.md` which is placed in root directory of the repo.
* Modify & push the `release.md` file before triggering this action (create tag for this example) to dynamically change the body of the release.
```yaml
name: Publish
on:
push:
tags:
- '*'
jobs:
build:
name: Publish binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# This step reads a file from repo and use it for body of the release
# This works on any self-hosted runner OS
- name: Read release.md and use it as a body of new release
id: read_release
shell: bash
run: |
r=$(cat path/to/release.md) # <--- Read release.md (Provide correct path as per your repo)
r="${r//'%'/'%25'}" # Multiline escape sequences for %
r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n'
r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r'
echo "::set-output name=RELEASE_BODY::$r" # <--- Set environment variable
- name: Upload Binaries to Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
body: |
${{ steps.read_release.outputs.RELEASE_BODY }} # <--- Use environment variables that was created earlier
```
## Releasing
To release this Action:

View File

@@ -8,12 +8,14 @@ inputs:
repo_token:
description: 'GitHub token.'
required: true
default: ${{ github.token }}
file:
description: 'Local file to upload.'
required: true
tag:
description: 'Tag to use as a release.'
required: true
default: ${{ github.ref }}
asset_name:
description: 'Name of the asset. When not provided will use the file name. Unused if file_glob is set to "true".'
overwrite:
@@ -26,6 +28,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.'
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:
browser_download_url:
description: 'The publicly available URL of the asset.'

144
dist/index.js vendored
View File

@@ -385,6 +385,32 @@ const windowsRelease = release => {
module.exports = windowsRelease;
/***/ }),
/***/ 82:
/***/ (function(__unusedmodule, exports) {
"use strict";
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
//# sourceMappingURL=utils.js.map
/***/ }),
/***/ 87:
@@ -1322,6 +1348,42 @@ function regExpEscape (s) {
}
/***/ }),
/***/ 102:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
// For internal use, subject to change.
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__webpack_require__(747));
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
function issueCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`);
}
if (!fs.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`);
}
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
encoding: 'utf8'
});
}
exports.issueCommand = issueCommand;
//# sourceMappingURL=file-command.js.map
/***/ }),
/***/ 117:
@@ -2205,13 +2267,13 @@ function get_release_by_tag(tag, prerelease, release_name, body, octokit) {
return __awaiter(this, void 0, void 0, function* () {
try {
core.debug(`Getting release by tag ${tag}.`);
return yield octokit.repos.getReleaseByTag(Object.assign(Object.assign({}, github.context.repo), { tag: tag }));
return yield octokit.repos.getReleaseByTag(Object.assign(Object.assign({}, repo()), { tag: tag }));
}
catch (error) {
// 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.repos.createRelease(Object.assign(Object.assign({}, github.context.repo), { tag_name: tag, prerelease: prerelease, release_name: release_name, body: body }));
return yield octokit.repos.createRelease(Object.assign(Object.assign({}, repo()), { tag_name: tag, prerelease: prerelease, name: release_name, body: body }));
}
else {
throw error;
@@ -2229,12 +2291,12 @@ function upload_to_release(release, file, asset_name, tag, overwrite, octokit) {
const file_size = stat.size;
const file_bytes = fs.readFileSync(file);
// Check for duplicates.
const assets = yield octokit.repos.listReleaseAssets(Object.assign(Object.assign({}, github.context.repo), { release_id: release.data.id }));
const duplicate_asset = assets.data.find(a => a.name === asset_name);
const assets = yield octokit.paginate(octokit.repos.listReleaseAssets, Object.assign(Object.assign({}, repo()), { release_id: release.data.id }));
const duplicate_asset = assets.find(a => a.name === asset_name);
if (duplicate_asset !== undefined) {
if (overwrite) {
core.debug(`An asset called ${asset_name} already exists in release ${tag} so we'll overwrite it.`);
yield octokit.repos.deleteReleaseAsset(Object.assign(Object.assign({}, github.context.repo), { asset_id: duplicate_asset.id }));
yield octokit.repos.deleteReleaseAsset(Object.assign(Object.assign({}, repo()), { asset_id: duplicate_asset.id }));
}
else {
core.setFailed(`An asset called ${asset_name} already exists.`);
@@ -2257,13 +2319,35 @@ function upload_to_release(release, file, asset_name, tag, overwrite, octokit) {
return uploaded_asset.data.browser_download_url;
});
}
function repo() {
const repo_name = core.getInput('repo_name');
// If we're not targeting a foreign repository, we can just return immediately and don't have to do extra work.
if (!repo_name) {
return github.context.repo;
}
const owner = repo_name.substr(0, repo_name.indexOf('/'));
if (!owner) {
throw new Error(`Could not extract 'owner' from 'repo_name': ${repo_name}.`);
}
const repo = repo_name.substr(repo_name.indexOf('/') + 1);
if (!repo) {
throw new Error(`Could not extract 'repo' from 'repo_name': ${repo_name}.`);
}
return {
owner,
repo
};
}
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
const token = core.getInput('repo_token', { required: true });
const file = core.getInput('file', { required: true });
const tag = core.getInput('tag', { required: true }).replace('refs/tags/', '').replace('refs/heads/', '');
const tag = core
.getInput('tag', { required: true })
.replace('refs/tags/', '')
.replace('refs/heads/', '');
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;
@@ -6403,6 +6487,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
/**
* Commands
*
@@ -6456,28 +6541,14 @@ class Command {
return cmdStr;
}
}
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
function escapeData(s) {
return toCommandValue(s)
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
}
function escapeProperty(s) {
return toCommandValue(s)
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
@@ -7232,6 +7303,12 @@ function convertBody(buffer, headers) {
// html4
if (!res && str) {
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
if (!res) {
res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str);
if (res) {
res.pop(); // drop last quote
}
}
if (res) {
res = /charset=(.*)/i.exec(res.pop());
@@ -8239,7 +8316,7 @@ function fetch(url, opts) {
// HTTP fetch step 5.5
switch (request.redirect) {
case 'error':
reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));
finalize();
return;
case 'manual':
@@ -8278,7 +8355,8 @@ function fetch(url, opts) {
method: request.method,
body: request.body,
signal: request.signal,
timeout: request.timeout
timeout: request.timeout,
size: request.size
};
// HTTP-redirect fetch step 9
@@ -8593,6 +8671,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = __webpack_require__(431);
const file_command_1 = __webpack_require__(102);
const utils_1 = __webpack_require__(82);
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
/**
@@ -8619,10 +8699,18 @@ var ExitCode;
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) {
const convertedVal = command_1.toCommandValue(val);
const convertedVal = utils_1.toCommandValue(val);
process.env[name] = convertedVal;
const filePath = process.env['GITHUB_ENV'] || '';
if (filePath) {
const delimiter = '_GitHubActionsFileCommandDelimeter_';
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
file_command_1.issueCommand('ENV', commandValue);
}
else {
command_1.issueCommand('set-env', { name }, convertedVal);
}
}
exports.exportVariable = exportVariable;
/**
* Registers a secret which will get masked from logs
@@ -8637,7 +8725,13 @@ exports.setSecret = setSecret;
* @param inputPath
*/
function addPath(inputPath) {
const filePath = process.env['GITHUB_PATH'] || '';
if (filePath) {
file_command_1.issueCommand('PATH', inputPath);
}
else {
command_1.issueCommand('add-path', {}, inputPath);
}
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
}
exports.addPath = addPath;

2677
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "upload-release-action",
"version": "2.1.0",
"version": "2.3.0",
"private": true,
"description": "Upload files to a GitHub release",
"main": "lib/main.js",
@@ -27,24 +27,24 @@
"author": "Sven-Hendrik Haase",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@types/glob": "^7.1.2",
"glob": "^7.1.6"
},
"devDependencies": {
"@types/jest": "^24.9.1",
"@types/node": "^12.12.47",
"@types/node": "^12.12.64",
"@typescript-eslint/parser": "^3.5.0",
"@zeit/ncc": "^0.22.3",
"eslint": "^7.3.1",
"eslint": "^7.10.0",
"eslint-plugin-github": "^4.0.1",
"eslint-plugin-jest": "^23.17.1",
"jest": "^26.1.0",
"jest-circus": "^26.1.0",
"jest": "^26.5.2",
"jest-circus": "^26.5.2",
"js-yaml": "^3.14.0",
"prettier": "^2.0.5",
"ts-jest": "^26.1.1",
"ts-jest": "^26.4.1",
"typescript": "^3.9.6"
}
}

View File

@@ -6,7 +6,7 @@ import * as github from '@actions/github'
import * as path from 'path'
import * as glob from 'glob'
type RepoAssetsResp = Endpoints['GET /repos/:owner/:repo/releases/:release_id/assets']['response']
type RepoAssetsResp = Endpoints['GET /repos/:owner/:repo/releases/:release_id/assets']['response']['data']
type ReleaseByTagResp = Endpoints['GET /repos/:owner/:repo/releases/tags/:tag']['response']
type CreateReleaseResp = Endpoints['POST /repos/:owner/:repo/releases']['response']
type UploadAssetResp = Endpoints['POST /repos/:owner/:repo/releases/:release_id/assets{?name,label}']['response']
@@ -21,7 +21,7 @@ async function get_release_by_tag(
try {
core.debug(`Getting release by tag ${tag}.`)
return await octokit.repos.getReleaseByTag({
...github.context.repo,
...repo(),
tag: tag
})
} catch (error) {
@@ -31,10 +31,10 @@ async function get_release_by_tag(
`Release for tag ${tag} doesn't exist yet so we'll create it now.`
)
return await octokit.repos.createRelease({
...github.context.repo,
...repo(),
tag_name: tag,
prerelease: prerelease,
release_name: release_name,
name: release_name,
body: body
})
} else {
@@ -60,18 +60,21 @@ async function upload_to_release(
const file_bytes = fs.readFileSync(file)
// Check for duplicates.
const assets: RepoAssetsResp = await octokit.repos.listReleaseAssets({
...github.context.repo,
const assets: RepoAssetsResp = await octokit.paginate(
octokit.repos.listReleaseAssets,
{
...repo(),
release_id: release.data.id
})
const duplicate_asset = assets.data.find(a => a.name === asset_name)
}
)
const duplicate_asset = assets.find(a => a.name === asset_name)
if (duplicate_asset !== undefined) {
if (overwrite) {
core.debug(
`An asset called ${asset_name} already exists in release ${tag} so we'll overwrite it.`
)
await octokit.repos.deleteReleaseAsset({
...github.context.repo,
...repo(),
asset_id: duplicate_asset.id
})
} else {
@@ -99,6 +102,26 @@ async function upload_to_release(
return uploaded_asset.data.browser_download_url
}
function repo(): {owner: string; repo: string} {
const repo_name = core.getInput('repo_name')
// If we're not targeting a foreign repository, we can just return immediately and don't have to do extra work.
if (!repo_name) {
return github.context.repo
}
const owner = repo_name.substr(0, repo_name.indexOf('/'))
if (!owner) {
throw new Error(`Could not extract 'owner' from 'repo_name': ${repo_name}.`)
}
const repo = repo_name.substr(repo_name.indexOf('/') + 1)
if (!repo) {
throw new Error(`Could not extract 'repo' from 'repo_name': ${repo_name}.`)
}
return {
owner,
repo
}
}
async function run(): Promise<void> {
try {
// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs