This commit is contained in:
Brendan D 2024-02-23 22:57:53 +00:00 committed by GitHub
commit 9c939c4eb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 35 additions and 15 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ __tests__/runner/*
# actions requires a node_modules dir https://github.com/actions/toolkit/blob/master/docs/javascript-action.md#publish-a-releasesv1-action
# but its recommended not to check these in https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations
node_modules
lib/*

View file

@ -173,7 +173,7 @@ The following are optional as `step.with` keys
| `body_path` | String | Path to load text communicating notable changes in this release |
| `draft` | Boolean | Indicator of whether or not this release is a draft |
| `prerelease` | Boolean | Indicator of whether or not is a prerelease |
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
| `files` | String | Newline-delimited globs of paths to assets to upload for release. Files can be renamed using oldName:newName. |
| `name` | String | Name of the release. defaults to tag name |
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing |

4
dist/index.js vendored

File diff suppressed because one or more lines are too long

14
package-lock.json generated
View file

@ -12,7 +12,7 @@
"@actions/github": "^5.1.1",
"@octokit/plugin-retry": "^4.0.3",
"@octokit/plugin-throttling": "^4.3.2",
"glob": "^8.0.3",
"glob": "^8.1.0",
"mime": "^3.0.0",
"node-fetch": "^2.6.7"
},
@ -2212,9 +2212,9 @@
}
},
"node_modules/glob": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
"integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",
"integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==",
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -6024,9 +6024,9 @@
"dev": true
},
"glob": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
"integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",
"integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",

View file

@ -23,7 +23,7 @@
"@actions/github": "^5.1.1",
"@octokit/plugin-retry": "^4.0.3",
"@octokit/plugin-throttling": "^4.3.2",
"glob": "^8.0.3",
"glob": "^8.1.0",
"mime": "^3.0.0",
"node-fetch": "^2.6.7"
},

View file

@ -9,6 +9,7 @@ import { release, upload, GitHubReleaser } from "./github";
import { getOctokit } from "@actions/github";
import { setFailed, setOutput } from "@actions/core";
import { GitHub, getOctokitOptions } from "@actions/github/lib/utils";
import * as fs from 'fs';
import { env } from "process";
@ -24,9 +25,21 @@ async function run() {
}
if (config.input_files) {
const patterns = unmatchedPatterns(config.input_files);
patterns.forEach((pattern) =>
console.warn(`🤔 Pattern '${pattern}' does not match any files.`)
);
patterns.forEach((pattern) => {
console.warn(pattern);
// Rename file using oldName:newName notation
if (pattern.includes(":")) {
let names = pattern.split(':');
let oldName = names[0];
let newName = names[1];
fs.rename(oldName, newName, () => {
console.warn(`🤔Renamed file from '${oldName}' to '${newName}!`);
});
}
else {
console.warn(`🤔 Pattern '${pattern}' does not match any files.`)
}
});
if (patterns.length > 0 && config.input_fail_on_unmatched_files) {
throw new Error(`⚠️ There were unmatched files`);
}
@ -62,8 +75,14 @@ async function run() {
const rel = await release(config, new GitHubReleaser(gh));
if (config.input_files) {
const files = paths(config.input_files);
config.input_files.forEach((file) => {
if (file.includes(":")) {
// Use the new name instead to upload
files.push(file.split(":")[1]);
}
})
if (files.length == 0) {
console.warn(`🤔 ${config.input_files} not include valid file.`);
console.warn(`🤔 ${config.input_files} did not include valid files.`);
}
const currentAssets = rel.assets;
const assets = await Promise.all(