Skip to content

GitHub Action

@simple-release/github-action is the API that simple-release-action is built from. Use it to assemble a custom action or a script with the same flows.

An extension of the Releaser preconfigured for the GitHub Actions environment: the hosting is created from an Octokit instance, setUser defaults to the github-actions[bot] identity, checkout fetches and force-recreates the release branch, tag fetches fresh tags, and push force-pushes.

import { getOctokit } from '@actions/github'
import { load } from '@simple-release/config'
import { ReleaserGithubAction } from '@simple-release/github-action'
const {
project,
releaser,
...options
} = await load({
config: true,
project: true
})
const action = new ReleaserGithubAction({
project,
octokit: getOctokit(process.env.GITHUB_TOKEN),
...releaser
})
.setOptions(options)
MethodDescription
runPullRequestAction()The main flow pull request side: checkout, fetch options from comments, bump, commit, push, pull request.
runReleaseAction(check)The release side: maintenance branches, tags, push, publish, release — guarded by ifReleaseCommit unless check is false.
runSnapshotAction(tag)The snapshot flow: fetch refs, bump with the timestamped snapshot identifier, publish under the tag, revert.
runAction()Detect the current event context and run the pull request or release flow.

On top of the Releaser steps:

StepDescription
fetch()Fetch all commits and tags from the remote — unshallows the default actions/checkout state.
fetchOptions()Read extra releaser options from the pull request comments.
HelperDescription
ifReleaseCommit(releaser)Whether the current branch head is an unreleased chore(release): ... commit — the guard for the release flow.
ifSetOptionsComment()Whether the current event is a !simple-release/set-options comment on a release pull request. Returns the target branch, or false to stop.
getInputOptions()Read the action inputs and map them to releaser step options.

getInputOptions maps the action inputs as follows:

InputTarget option
branchcheckout.branch
bump-versionbump.version
bump-asbump.as
bump-prereleasebump.prerelease
bump-snapshotbump.snapshot
bump-first-releasebump.firstRelease
bump-skipbump.skip
bump-by-projectbump.byProject
maintenance-branchmaintenanceBranch.enabled
publish-skippublish.skip
publish-accesspublish.access
publish-tagpublish.tag