Create GitHub releases
This guide shows how to create a GitHub release for each published version.
Register the plugin
Section titled “Register the plugin”npm i -D @unirelman/plugin-githubpnpm add -D @unirelman/plugin-githubyarn add -D @unirelman/plugin-githubbun add -d @unirelman/plugin-githubimport { 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.
Provide the repository and the token
Section titled “Provide the repository and the token”The plugin needs the repository and a token with the contents: write permission.
With the GitHub Action
Section titled “With the GitHub Action”The GitHub Action provides the repository, and its github-token input as the token.
With environment variables
Section titled “With environment variables”Set the GITHUB_REPOSITORY and GITHUB_TOKEN environment variables:
export GITHUB_REPOSITORY=owner/nameexport 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:
- name: Publish run: npx unirelman publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}With options
Section titled “With options”Set the repository and token options:
createGitHubPlugin({ repository: "owner/name", token: process.env.MY_TOKEN,});Create drafts
Section titled “Create drafts”createGitHubPlugin({ draft: true });Keep the latest release on one scope
Section titled “Keep the latest release on one scope”createGitHubPlugin({ makeLatest: "@example/core" });Use GitHub Enterprise Server
Section titled “Use GitHub Enterprise Server”Set the GITHUB_API_URL environment variable, which GitHub Actions sets on Enterprise Server, or pass the apiUrl option:
createGitHubPlugin({ apiUrl: "https://github.example.com/api/v3" });Use the created releases
Section titled “Use the created releases”The publish JSON document gives each GitHub release with its id, url and uploadUrl, for example to upload assets in a later workflow step.