Add tag_name option (#39)
Allow setting tag name like actions/create-release.
This commit is contained in:
parent
b7e450da2a
commit
9f4852ebe6
@ -180,6 +180,7 @@ The following are optional as `step.with` keys
|
|||||||
| `prerelease`| Boolean | Indicator of whether or not is a prerelease |
|
| `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|
|
||||||
| `name` | String | Name of the release. defaults to tag name |
|
| `name` | String | Name of the release. defaults to tag name |
|
||||||
|
| `tag_name` | String | Name of a tag. defaults to github.GITHUB_REF |
|
||||||
|
|
||||||
💡When providing a `body` and `body_path` at the same time, `body_path` will be attempted first, then falling back on `body` if the path can not be read from.
|
💡When providing a `body` and `body_path` at the same time, `body_path` will be attempted first, then falling back on `body` if the path can not be read from.
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@ describe("util", () => {
|
|||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined
|
input_name: undefined,
|
||||||
|
input_tag_name: undefined
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -51,7 +52,8 @@ describe("util", () => {
|
|||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined
|
input_name: undefined,
|
||||||
|
input_tag_name: undefined
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -67,7 +69,8 @@ describe("util", () => {
|
|||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined
|
input_name: undefined,
|
||||||
|
input_tag_name: undefined
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -83,7 +86,8 @@ describe("util", () => {
|
|||||||
input_draft: false,
|
input_draft: false,
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined
|
input_name: undefined,
|
||||||
|
input_tag_name: undefined
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,9 @@ inputs:
|
|||||||
name:
|
name:
|
||||||
description: 'Gives the release a custom name. Defaults to tag name'
|
description: 'Gives the release a custom name. Defaults to tag name'
|
||||||
required: false
|
required: false
|
||||||
|
tag_name:
|
||||||
|
description: 'Gives a tag name. Defaults to github.GITHUB_REF'
|
||||||
|
required: false
|
||||||
draft:
|
draft:
|
||||||
description: 'Creates a draft release. Defaults to false'
|
description: 'Creates a draft release. Defaults to false'
|
||||||
required: false
|
required: false
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -142,7 +142,8 @@ export const release = async (
|
|||||||
releaser: Releaser
|
releaser: Releaser
|
||||||
): Promise<Release> => {
|
): Promise<Release> => {
|
||||||
const [owner, repo] = config.github_repository.split("/");
|
const [owner, repo] = config.github_repository.split("/");
|
||||||
const tag = config.github_ref.replace("refs/tags/", "");
|
const tag =
|
||||||
|
config.input_tag_name || config.github_ref.replace("refs/tags/", "");
|
||||||
try {
|
try {
|
||||||
// you can't get a an existing draft by tag
|
// you can't get a an existing draft by tag
|
||||||
// so we must find one in the list of all releases
|
// so we must find one in the list of all releases
|
||||||
|
@ -7,7 +7,7 @@ import { env } from "process";
|
|||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const config = parseConfig(env);
|
const config = parseConfig(env);
|
||||||
if (!isTag(config.github_ref)) {
|
if (!config.input_tag_name && !isTag(config.github_ref)) {
|
||||||
throw new Error(`⚠️ GitHub Releases requires a tag`);
|
throw new Error(`⚠️ GitHub Releases requires a tag`);
|
||||||
}
|
}
|
||||||
GitHub.plugin(require("@octokit/plugin-throttling"));
|
GitHub.plugin(require("@octokit/plugin-throttling"));
|
||||||
|
@ -7,6 +7,7 @@ export interface Config {
|
|||||||
github_repository: string;
|
github_repository: string;
|
||||||
// user provided
|
// user provided
|
||||||
input_name?: string;
|
input_name?: string;
|
||||||
|
input_tag_name?: string;
|
||||||
input_body?: string;
|
input_body?: string;
|
||||||
input_body_path?: string;
|
input_body_path?: string;
|
||||||
input_files?: string[];
|
input_files?: string[];
|
||||||
@ -41,6 +42,7 @@ export const parseConfig = (env: Env): Config => {
|
|||||||
github_ref: env.GITHUB_REF || "",
|
github_ref: env.GITHUB_REF || "",
|
||||||
github_repository: env.GITHUB_REPOSITORY || "",
|
github_repository: env.GITHUB_REPOSITORY || "",
|
||||||
input_name: env.INPUT_NAME,
|
input_name: env.INPUT_NAME,
|
||||||
|
input_tag_name: env.INPUT_TAG_NAME,
|
||||||
input_body: env.INPUT_BODY,
|
input_body: env.INPUT_BODY,
|
||||||
input_body_path: env.INPUT_BODY_PATH,
|
input_body_path: env.INPUT_BODY_PATH,
|
||||||
input_files: parseInputFiles(env.INPUT_FILES || ""),
|
input_files: parseInputFiles(env.INPUT_FILES || ""),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user