This commit is contained in:
umarcor
2023-02-26 17:46:26 +01:00
2 changed files with 16 additions and 12 deletions

View File

@@ -52,7 +52,7 @@ def GetListOfArtifacts(argv, files):
if len(argv) > 1: if len(argv) > 1:
args += argv[1:] args += argv[1:]
if len(args) == 1 and args[0].lower() == "none": if len(args) == 1 and args[0].lower() == "none":
print("! Skipping 'files' because it's set to 'none") print("! Skipping 'files' because it's set to 'none'.")
return [] return []
elif len(args) == 0: elif len(args) == 0:
stdout.flush() stdout.flush()
@@ -63,7 +63,7 @@ def GetListOfArtifacts(argv, files):
print(f" glob({item!s}):") print(f" glob({item!s}):")
for fname in [fname for fname in glob(item, recursive=True) if not Path(fname).is_dir()]: for fname in [fname for fname in glob(item, recursive=True) if not Path(fname).is_dir()]:
if Path(fname).stat().st_size == 0: if Path(fname).stat().st_size == 0:
print(f" - ! Skipping empty file {fname!s}") print(f" - ! Skipping empty file {fname!s}.")
continue continue
print(f" - {fname!s}") print(f" - {fname!s}")
flist.append(fname) flist.append(fname)
@@ -101,7 +101,7 @@ def CheckRefSemVer(gh_ref, tag, snapshots):
return (tag, env_tag, False) return (tag, env_tag, False)
elif snapshots: elif snapshots:
# is semver compilant prerelease tag, thus a snapshot (we skip it) # is semver compilant prerelease tag, thus a snapshot (we skip it)
print("! Skipping snapshot prerelease") print("! Skipping snapshot prerelease.")
sys_exit() sys_exit()
return (tag, env_tag, True) return (tag, env_tag, True)
@@ -179,12 +179,15 @@ if paramRM:
asset.delete_asset() asset.delete_asset()
stdout.flush() stdout.flush()
print("· Cleanup and/or upload artifacts") if len(files) > 0:
env = environ.copy() print("· Upload assets")
env["GITHUB_TOKEN"] = paramToken env = environ.copy()
cmd = ["gh", "release", "upload", "--repo", paramRepo, "--clobber", tag] + files env["GITHUB_TOKEN"] = paramToken
print(f" > {' '.join(cmd)}") cmd = ["gh", "release", "upload", "--repo", paramRepo, "--clobber", tag] + files
check_call(cmd, env=env) print(f" > {' '.join(cmd)}")
stdout.flush() check_call(cmd, env=env)
stdout.flush()
else:
print("! Skipping uploading assets because the file list is empty.")
UpdateReference(gh_release, tag, paramSHA if env_tag is None else None, is_prerelease, is_draft) UpdateReference(gh_release, tag, paramSHA if env_tag is None else None, is_prerelease, is_draft)

View File

@@ -26,7 +26,8 @@
* * https://github.com/actions/runner/issues/1478 * * * https://github.com/actions/runner/issues/1478 *
* ================================================================================================================== */ * ================================================================================================================== */
const { spawn } = require("child_process"); const { spawn } = require("child_process");
const fs = require('fs'); const { appendFileSync } = require("fs");
const { EOL } = require("os");
function run(cmd) { function run(cmd) {
const subprocess = spawn(cmd, { stdio: "inherit", shell: true }); const subprocess = spawn(cmd, { stdio: "inherit", shell: true });
@@ -40,6 +41,6 @@ const key = process.env.INPUT_KEY.toUpperCase();
if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step? if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step?
run(process.env.INPUT_POST); run(process.env.INPUT_POST);
} else { // Otherwise, this is the main step } else { // Otherwise, this is the main step
fs.appendFileSync(process.env.GITHUB_STATE, `${key}=true`); appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`);
run(process.env.INPUT_MAIN); run(process.env.INPUT_MAIN);
} }