Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for prereleases #19

Merged
merged 2 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ GitHub actions inputs don't inherently support lists of things and one might lik
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

* Add support for prerelease annotated GitHub releases with the new input field `with.prerelease: true`

---

## 0.1.1
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ The following are optional as `step.with` keys
| `body` | String | 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 |
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
| `prerelease`| Boolean | Indicator of whether or not is a prerelease |
| `files` | String | Newline-delimited globs of paths to assets to upload for release|
| `name` | String | Name of the release. defaults to tag name |

💡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.
Expand Down
1 change: 1 addition & 0 deletions __tests__/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe("util", () => {
input_body: undefined,
input_body_path: undefined,
input_draft: false,
input_prerelease: false,
input_files: [],
input_name: undefined
});
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ inputs:
description: 'Gives the release a custom name. Defaults to tag name'
required: false
draft:
description: 'Creates a draft release'
description: 'Creates a draft release. Defaults to false'
required: false
prerelease:
description: 'Identify the release as a prerelease. Defaults to false'
required: false
files:
description: 'Newline-delimited list of path globs for asset files to upload'
Expand Down
4 changes: 3 additions & 1 deletion lib/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ exports.release = (config, releaser) => __awaiter(void 0, void 0, void 0, functi
const name = config.input_name || tag;
const body = config.input_body;
const draft = config.input_draft;
const prerelease = config.input_prerelease;
console.log(`👩‍🏭 Creating new GitHub release for tag ${tag_name}...`);
let release = yield releaser.createRelease({
owner,
repo,
tag_name,
name,
body,
draft
draft,
prerelease
});
return release.data;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ exports.parseConfig = (env) => {
input_body: env.INPUT_BODY,
input_body_path: env.INPUT_BODY_PATH,
input_files: exports.parseInputFiles(env.INPUT_FILES || ""),
input_draft: env.INPUT_DRAFT === "true"
input_draft: env.INPUT_DRAFT === "true",
input_prerelease: env.INPUT_PRERELEASE == "true"
};
};
exports.paths = (patterns) => {
Expand Down
6 changes: 5 additions & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface Releaser {
name: string;
body: string | undefined;
draft: boolean | undefined;
prerelease: boolean | undefined;
}): Promise<{ data: Release }>;

allReleases(params: {
Expand Down Expand Up @@ -60,6 +61,7 @@ export class GitHubReleaser implements Releaser {
name: string;
body: string | undefined;
draft: boolean | undefined;
prerelease: boolean | undefined;
}): Promise<{ data: Release }> {
return this.github.repos.createRelease(params);
}
Expand Down Expand Up @@ -138,14 +140,16 @@ export const release = async (
const name = config.input_name || tag;
const body = config.input_body;
const draft = config.input_draft;
const prerelease = config.input_prerelease;
console.log(`👩‍🏭 Creating new GitHub release for tag ${tag_name}...`);
let release = await releaser.createRelease({
owner,
repo,
tag_name,
name,
body,
draft
draft,
prerelease
});
return release.data;
} catch (error) {
Expand Down
4 changes: 3 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Config {
input_body_path?: string;
input_files?: string[];
input_draft?: boolean;
input_prerelease?: boolean;
}

type Env = { [key: string]: string | undefined };
Expand All @@ -35,7 +36,8 @@ export const parseConfig = (env: Env): Config => {
input_body: env.INPUT_BODY,
input_body_path: env.INPUT_BODY_PATH,
input_files: parseInputFiles(env.INPUT_FILES || ""),
input_draft: env.INPUT_DRAFT === "true"
input_draft: env.INPUT_DRAFT === "true",
input_prerelease: env.INPUT_PRERELEASE == "true"
};
};

Expand Down