@wtf/release-github
v1.3.0
Published
GitHub as the forge of a release, a Forge of @wtf/release/forge, of no release tool, by the platform and the token its caller gives it: the platform and the token it takes (.), the run of a workflow of GitHub Actions, of its variables, and the headers of
Maintainers
Readme
@wtf/release-github
GitHub as the forge of a release: where a repo lives, its registries, and the releases of its tags.
An ecosystem says what a release published, a Released of
@wtf/release/forge; this forge says where a package on GitHub Packages
lives, and keeps a file of a package of no page as an asset of the release, so the GitHub release
of the tag names each package it published. It is a library of no release tool: it asks GitHub by
the fetch of the platform its caller gives it, and by the token its caller gives it, and reads no
token of the environment. @wtf/semantic-release/github gives it
the token and the options of a run of semantic-release.
The forge
githubForge of ./forge is a Forge of @wtf/release/forge:
runOfis the run of a workflow of GitHub Actions, of its variables: the page of the repository,GITHUB_SERVER_URLandGITHUB_REPOSITORY, and the API,GITHUB_API_URL. None outside a workflow.pageOfgives the page of a package on GitHub, of the registry it was published to:| A package published to | Its page | | ------------------------------------------------ | -------------------------------------------------- | | npm of GitHub Packages,
npm.pkg.github.com| the page of its version, of its scope as its owner | | Maven of GitHub Packages,maven.pkg.github.com| the page of its version, of its coordinates | | the container registry,ghcr.io(container) | the page of the version its tags hold | | nowhere, of a folder and a tag, as a Go module | its folder at its tag |GitHub lists a version a moment after it took it, so a package GitHub does not list at the version yet is asked again, about a minute in all. The registries of GitHub Enterprise Server are read too, of their hosts (
npm.<host>,containers.<host>) and of their paths (<host>/_registry/npm).uploadkeeps a file of a package of no page as an asset of the release of its tag, which is made already: of a release that has the asset already, as of a release run again, that one.
The token goes to the API of GitHub alone, as Authorization: Bearer. The packages of GitHub
Packages are read by a token of read:packages, which the GITHUB_TOKEN of a workflow is of
permissions: packages: read; the releases are written by one of contents: write.
The notes
A GitHub release has no links of its own, as a GitLab release has: its notes name each package in a
section of their own, ### Packages, a link of each, after the notes of the release.
notesWithPackages of ./notes gives the notes of a release with that section, and
addPackagesToRelease changes the notes of a release made already.
import type { GitHubPlatform } from '@wtf/release-github'
import { releaseLinks } from '@wtf/release-github/links'
import { addPackagesToRelease } from '@wtf/release-github/notes'
import { headersOf } from '@wtf/release-github/run'
declare const platform: GitHubPlatform
declare const env: Record<string, string | undefined>
const run = {
url: 'https://github.com/acme/core',
api: 'https://api.github.com',
project: 'acme/core'
}
const auth = { token: env['GITHUB_TOKEN'] }
const links = await releaseLinks(
[
{
ecosystem: 'npm',
name: '@acme/core',
version: '1.2.0',
registry: { url: 'https://npm.pkg.github.com', type: 'npm', name: '@acme/core' }
}
],
{ run, tag: 'core-v1.2.0', platform, auth }
)
await addPackagesToRelease({
fetch: platform.fetch,
run,
tag: 'core-v1.2.0',
headers: headersOf(auth),
links
})The runs and the release of a tag
A tag can have no workflow run: GitHub starts no workflow of a tag pushed by the GITHUB_TOKEN of a
workflow, and makes no push event of tags when more than three are pushed at once. ./runs finds the runs of a tag (findRuns), dispatches a run of a workflow of a tag
that has none (dispatchRun, by POST /repos/:owner/:repo/actions/workflows/:file/dispatches of
the tag as its ref), ensures one, after a second look at a tag that has none, as GitHub makes the
run of a push some seconds after it (ensureRun), and waits for one until it completes
(waitForRun). GitHub runs the
workflow as it is at the tag, and refuses the dispatch, with 422, of a workflow of no
on: workflow_dispatch there. ./releases reads the GitHub release of a tag (findRelease), its
notes and its assets. The bin release-github runs them.
| Export | What it is |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| @wtf/release-github | The types: GitHubPlatform, the platform GitHub is asked by, of its fetch (HttpFetch), and GitHubAuth, the token of a run |
| @wtf/release-github/run | githubRunOf, the run of a workflow; githubReleasePageOf, githubCommitPageOf, the pages of a release and a commit; apiOf, the API of a server; headersOf, of a token |
| @wtf/release-github/trust | githubPublisherOf, the workflow npm trusts to publish, of GITHUB_REPOSITORY or the remote of github.com and its workflow file; githubRepositoryOf, githubRepositoryOfRemote, githubWorkflowOf |
| @wtf/release-github/packages | githubPackageOf, the package of GitHub Packages of a registry, and findPackageVersion, the page of its version |
| @wtf/release-github/assets | releaseOfTag, the release of a tag; uploadAsset, a file uploaded as its asset; assetUrlOf, where GitHub serves one |
| @wtf/release-github/notes | packagesSection and notesWithPackages, the notes of a release with its packages; addPackagesToRelease, of one made |
| @wtf/release-github/forge | githubForge, GitHub as a Forge of @wtf/release/forge |
| @wtf/release-github/runs | findRuns, the workflow runs of a tag; dispatchRun, a run of a workflow dispatched of a tag; ensureRun, one dispatched of a tag that has none, after a second look; waitForRun, one waited for until it completes |
| @wtf/release-github/releases | findRelease, the GitHub release of a tag, its notes and its assets |
| @wtf/release-github/links | releaseLinks, the link of each package from the GitHub release of the tag |
| @wtf/release-github/errors | GitHubError and GITHUB_ERRORS: EGITHUB, EGITHUBPACKAGE, EGITHUBRELEASE, EGITHUBDISPATCH, a run GitHub dispatches not, and EGITHUBTIMEOUT, a run that has not completed in the time waited |
License
MIT
