mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-06-28 06:16:01 +00:00
Make target_commitish configurable
This commit is contained in:
parent
affa18ef97
commit
d0cd6479c6
4 changed files with 46 additions and 17 deletions
23
README.md
23
README.md
|
@ -172,17 +172,18 @@ jobs:
|
||||||
|
|
||||||
The following are optional as `step.with` keys
|
The following are optional as `step.with` keys
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|---------------------------|---------|-----------------------------------------------------------------------|
|
|---------------------------|---------|-------------------------------------------------------------------------------------------------------------------|
|
||||||
| `body` | String | Text communicating notable changes in this release |
|
| `body` | String | Text communicating notable changes in this release |
|
||||||
| `body_path` | String | Path to load text communicating notable changes in this release |
|
| `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 |
|
| `draft` | Boolean | Indicator of whether or not this release is a draft |
|
||||||
| `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.ref` |
|
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
|
||||||
| `repository` | String | Name of a target repository in `<owner>/<repo>` format. defaults to the current repository
|
| `repository` | String | Name of a target repository in `<owner>/<repo>` format. defaults to the current repository |
|
||||||
| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing|
|
| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing |
|
||||||
|
| `target_commitish` | String | Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. |
|
||||||
|
|
||||||
💡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.
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ describe("util", () => {
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined
|
input_tag_name: undefined,
|
||||||
|
input_target_commitish: undefined
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -54,7 +55,8 @@ describe("util", () => {
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined
|
input_tag_name: undefined,
|
||||||
|
input_target_commitish: undefined
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -71,7 +73,8 @@ describe("util", () => {
|
||||||
input_prerelease: false,
|
input_prerelease: false,
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined
|
input_tag_name: undefined,
|
||||||
|
input_target_commitish: undefined
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -89,7 +92,26 @@ describe("util", () => {
|
||||||
input_files: [],
|
input_files: [],
|
||||||
input_name: undefined,
|
input_name: undefined,
|
||||||
input_tag_name: undefined,
|
input_tag_name: undefined,
|
||||||
input_fail_on_unmatched_files: false
|
input_fail_on_unmatched_files: false,
|
||||||
|
input_target_commitish: undefined
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("parseConfig", () => {
|
||||||
|
it("parses basic config with commitish", () => {
|
||||||
|
assert.deepStrictEqual(parseConfig({INPUT_TARGET_COMMITISH: "affa18ef97bc9db20076945705aba8c516139abd"}), {
|
||||||
|
github_ref: "",
|
||||||
|
github_repository: "",
|
||||||
|
github_token: "",
|
||||||
|
input_body: undefined,
|
||||||
|
input_body_path: undefined,
|
||||||
|
input_draft: false,
|
||||||
|
input_prerelease: false,
|
||||||
|
input_files: [],
|
||||||
|
input_name: undefined,
|
||||||
|
input_tag_name: undefined,
|
||||||
|
input_fail_on_unmatched_files: false,
|
||||||
|
input_target_commitish: "affa18ef97bc9db20076945705aba8c516139abd"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,6 +35,7 @@ export interface Releaser {
|
||||||
body: string | undefined;
|
body: string | undefined;
|
||||||
draft: boolean | undefined;
|
draft: boolean | undefined;
|
||||||
prerelease: boolean | undefined;
|
prerelease: boolean | undefined;
|
||||||
|
target_commitish: string | undefined;
|
||||||
}): Promise<{ data: Release }>;
|
}): Promise<{ data: Release }>;
|
||||||
|
|
||||||
updateRelease(params: {
|
updateRelease(params: {
|
||||||
|
@ -77,6 +78,7 @@ export class GitHubReleaser implements Releaser {
|
||||||
body: string | undefined;
|
body: string | undefined;
|
||||||
draft: boolean | undefined;
|
draft: boolean | undefined;
|
||||||
prerelease: boolean | undefined;
|
prerelease: boolean | undefined;
|
||||||
|
target_commitish: string | undefined;
|
||||||
}): Promise<{ data: Release }> {
|
}): Promise<{ data: Release }> {
|
||||||
return this.github.repos.createRelease(params);
|
return this.github.repos.createRelease(params);
|
||||||
}
|
}
|
||||||
|
@ -191,6 +193,7 @@ export const release = async (
|
||||||
const body = releaseBody(config);
|
const body = releaseBody(config);
|
||||||
const draft = config.input_draft;
|
const draft = config.input_draft;
|
||||||
const prerelease = config.input_prerelease;
|
const prerelease = config.input_prerelease;
|
||||||
|
const target_commitish = config.input_target_commitish;
|
||||||
console.log(`👩🏭 Creating new GitHub release for tag ${tag_name}...`);
|
console.log(`👩🏭 Creating new GitHub release for tag ${tag_name}...`);
|
||||||
try {
|
try {
|
||||||
let release = await releaser.createRelease({
|
let release = await releaser.createRelease({
|
||||||
|
@ -200,7 +203,8 @@ export const release = async (
|
||||||
name,
|
name,
|
||||||
body,
|
body,
|
||||||
draft,
|
draft,
|
||||||
prerelease
|
prerelease,
|
||||||
|
target_commitish
|
||||||
});
|
});
|
||||||
return release.data;
|
return release.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ export interface Config {
|
||||||
input_draft?: boolean;
|
input_draft?: boolean;
|
||||||
input_prerelease?: boolean;
|
input_prerelease?: boolean;
|
||||||
input_fail_on_unmatched_files?: boolean;
|
input_fail_on_unmatched_files?: boolean;
|
||||||
|
input_target_commitish?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const releaseBody = (config: Config): string | undefined => {
|
export const releaseBody = (config: Config): string | undefined => {
|
||||||
|
@ -50,7 +51,8 @@ export const parseConfig = (env: Env): Config => {
|
||||||
input_files: parseInputFiles(env.INPUT_FILES || ""),
|
input_files: parseInputFiles(env.INPUT_FILES || ""),
|
||||||
input_draft: env.INPUT_DRAFT === "true",
|
input_draft: env.INPUT_DRAFT === "true",
|
||||||
input_prerelease: env.INPUT_PRERELEASE == "true",
|
input_prerelease: env.INPUT_PRERELEASE == "true",
|
||||||
input_fail_on_unmatched_files: env.INPUT_FAIL_ON_UNMATCHED_FILES == "true"
|
input_fail_on_unmatched_files: env.INPUT_FAIL_ON_UNMATCHED_FILES == "true",
|
||||||
|
input_target_commitish: env.INPUT_TARGET_COMMITISH
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue