|
| 1 | +# @simple-release/github-action |
| 2 | + |
| 3 | +[![ESM-only package][package]][package-url] |
| 4 | +[![NPM version][npm]][npm-url] |
| 5 | +[![Node version][node]][node-url] |
| 6 | +[![Dependencies status][deps]][deps-url] |
| 7 | +[![Install size][size]][size-url] |
| 8 | +[![Build status][build]][build-url] |
| 9 | +[![Coverage status][coverage]][coverage-url] |
| 10 | + |
| 11 | +[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg |
| 12 | +[package-url]: https://nodejs.org/api/esm.html |
| 13 | + |
| 14 | +[npm]: https://img.shields.io/npm/v/@simple-release/github-action.svg |
| 15 | +[npm-url]: https://www.npmjs.com/package/@simple-release/github-action |
| 16 | + |
| 17 | +[node]: https://img.shields.io/node/v/@simple-release/github-action.svg |
| 18 | +[node-url]: https://nodejs.org |
| 19 | + |
| 20 | +[deps]: https://img.shields.io/librariesio/release/npm/@simple-release/github-action |
| 21 | +[deps-url]: https://libraries.io/npm/@simple-release%2Fgithub-actions/tree |
| 22 | + |
| 23 | +[size]: https://packagephobia.com/badge?p=@simple-release/github-action |
| 24 | +[size-url]: https://packagephobia.com/result?p=@simple-release/github-action |
| 25 | + |
| 26 | +[build]: https://img.shields.io/github/actions/workflow/status/TrigenSoftware/simple-release/tests.yml?branch=main |
| 27 | +[build-url]: https://github.com/TrigenSoftware/simple-release/actions |
| 28 | + |
| 29 | +[coverage]: https://coveralls.io/repos/github/TrigenSoftware/simple-release/badge.svg?branch=main |
| 30 | +[coverage-url]: https://coveralls.io/github/TrigenSoftware/simple-release?branch=main |
| 31 | + |
| 32 | +A simple-release api for github action. |
| 33 | + |
| 34 | +## Install |
| 35 | + |
| 36 | +```bash |
| 37 | +# pnpm |
| 38 | +pnpm add @simple-release/github-action |
| 39 | +# yarn |
| 40 | +yarn add @simple-release/github-action |
| 41 | +# npm |
| 42 | +npm i @simple-release/github-action |
| 43 | +``` |
| 44 | + |
| 45 | +## Usage |
| 46 | + |
| 47 | +```js |
| 48 | +import { getOctokit } from '@actions/github' |
| 49 | +import { load } from '@simple-release/config' |
| 50 | +import { ReleaserGithubAction, ifReleaseCommit } from '@simple-release/github-action' |
| 51 | + |
| 52 | +const { |
| 53 | + project, |
| 54 | + releaser, |
| 55 | + ...options |
| 56 | +} = await load({ |
| 57 | + config: true, |
| 58 | + project: true |
| 59 | +}) |
| 60 | +const action = await new ReleaserGithubAction({ |
| 61 | + project, |
| 62 | + octokit: getOctokit(token), |
| 63 | + ...releaser |
| 64 | +}) |
| 65 | + |
| 66 | +// Create pull request with version bump |
| 67 | +action |
| 68 | + .setOptions(options) |
| 69 | + .checkout() |
| 70 | + .fetchOptions() |
| 71 | + .bump() |
| 72 | + .commit() |
| 73 | + .push() |
| 74 | + .pullRequest() |
| 75 | + .run() |
| 76 | + |
| 77 | +// Publish release and project |
| 78 | +action |
| 79 | + .setOptions(options) |
| 80 | + .tag() |
| 81 | + .push() |
| 82 | + .release() |
| 83 | + .publish() |
| 84 | + .run(ifReleaseCommit) |
| 85 | + |
| 86 | +// Run all steps to create a pull request with version bump |
| 87 | +action |
| 88 | + .setOptions(options) |
| 89 | + .runPullRequestAction() |
| 90 | + |
| 91 | +// Run all steps to release project |
| 92 | +action |
| 93 | + .setOptions(options) |
| 94 | + .runReleaseAction() |
| 95 | + |
| 96 | +// Detect action by commit type and run appropriate steps |
| 97 | +action |
| 98 | + .setOptions(options) |
| 99 | + .runAction() |
| 100 | +``` |
| 101 | + |
| 102 | +### fethchOptions |
| 103 | + |
| 104 | +You can pass additional options to releaser via comment in your pull request. Your comment should start with `!simple-release/set-options` and contain JSON object with options. For example: |
| 105 | + |
| 106 | +```` |
| 107 | +!simple-release/set-options |
| 108 | +
|
| 109 | +```json |
| 110 | +{ |
| 111 | + "bump": { |
| 112 | + "prerelease": "alpha" |
| 113 | + } |
| 114 | +} |
| 115 | +``` |
| 116 | +```` |
| 117 | + |
| 118 | +To fetch and parse comments you should use `fetchOptions` step after `checkout` step. |
0 commit comments