Skip to content

Create GitHub releases

This guide shows how to create a GitHub release for each published version.

Terminal window
npm i -D @unirelman/plugin-github
unirelman.config.ts
import { createGitHubPlugin } from "@unirelman/plugin-github";
// ...
plugins: [
// ...
createGitHubPlugin(),
],

On publish, the plugin creates a GitHub release for each current version, named after its tag. With the Changelog plugin registered, the release notes of the version are the body of the release.

The plugin needs the repository and a token with the contents: write permission.

The GitHub Action provides the repository, and its github-token input as the token.

Set the GITHUB_REPOSITORY and GITHUB_TOKEN environment variables:

Terminal window
export GITHUB_REPOSITORY=owner/name
export GITHUB_TOKEN=ghp_...

In a GitHub Actions run step, GitHub Actions sets the GITHUB_REPOSITORY environment variable. Set the GITHUB_TOKEN environment variable in the step’s env:

.github/workflows/release.yml
- name: Publish
run: npx unirelman publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Set the repository and token options:

unirelman.config.ts
createGitHubPlugin({
repository: "owner/name",
token: process.env.MY_TOKEN,
});
unirelman.config.ts
createGitHubPlugin({ draft: true });
unirelman.config.ts
createGitHubPlugin({ makeLatest: "@example/core" });

Set the GITHUB_API_URL environment variable, which GitHub Actions sets on Enterprise Server, or pass the apiUrl option:

unirelman.config.ts
createGitHubPlugin({ apiUrl: "https://github.example.com/api/v3" });

The publish JSON document gives each GitHub release with its id, url and uploadUrl, for example to upload assets in a later workflow step.