@wtf/release-gitlab
v1.3.0
Published
GitLab 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 pipeline of GitLab, of its CI variables, and the headers of a tok
Maintainers
Readme
@wtf/release-gitlab
GitLab 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 the registries of
GitLab lives, and keeps a file of a package of no page, so the GitLab release of the tag links each
package it published. It is a library of no release tool: it asks GitLab 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/gitlab gives it the token and
the options of a run of semantic-release.
The forge
gitlabForge of ./forge is a Forge of @wtf/release/forge:
runOfis the run of a pipeline of GitLab, of its CI variables: the page of the project,CI_SERVER_URLandCI_PROJECT_PATH, and the API,CI_API_V4_URL. None outside a pipeline.pageOfgives the page of a package on GitLab, of the registry it was published to:| A package published to | Its page | | ----------------------------------------------------- | --------------------------------------------------------- | | a package registry of GitLab, of a project or a group | its page there, as the Packages API lists it, waited for | | the container registry of the project (
container) | its repository there, as the Container Registry API lists | | nowhere, of a folder and a tag, as a Go module | its folder at its tag |GitLab lists a package a moment after it took it, so a registry that lists none yet is asked again, about a minute in all. A package of Maven is named by its coordinates, as
org.acme:core, which GitLab knows asorg/acme/core.uploadkeeps a file of a package of no page in the generic package registry of the project, as the generic package ofgenericPackage(the train's, of a release of trains; the name of the project by default) at the version of the package.
The token goes to the GitLab of the run alone, never to a registry of another host: a token, as
PRIVATE-TOKEN, else the job token of a pipeline, as JOB-TOKEN. The Container Registry API of
GitLab refuses the job token, so it is asked of a token alone, and a release that links images of a
project that is not public takes a token of the read_api scope;
checkContainerRegistry of ./container asks once, before anything is released, whether it may.
import type { GitLabPlatform } from '@wtf/release-gitlab'
import { gitlabForge } from '@wtf/release-gitlab/forge'
import { linksOf } from '@wtf/release/forge'
declare const platform: GitLabPlatform
declare const env: Record<string, string | undefined>
const forge = gitlabForge({
platform,
auth: { token: env['GITLAB_TOKEN'] },
genericPackage: 'core'
})
const run = forge.runOf(env)
if (run !== undefined) {
const links = await linksOf(
run,
forge,
[
{
ecosystem: 'npm',
name: '@acme/core',
version: '1.2.0',
registry: {
url: 'https://gitlab.com/api/v4/projects/7/packages/npm/',
type: 'npm',
name: '@acme/core'
}
}
],
{ tag: 'core-v1.2.0' }
)
console.log(links) // [{ label: '@acme/core', url: 'https://gitlab.com/acme/core/-/packages/42', type: 'package' }]
}The pipelines and the release of a tag
A tag can have no pipeline: GitLab runs none of a tag pushed with the push option ci.skip, or of
a commit whose message says [skip ci], of which it shows an empty pipeline, skipped; and the
rules of workflow of a pipeline file can let none run. ./pipelines finds the pipelines of a tag
(findPipelines), starts one (createPipeline, by POST /projects/:id/pipeline of the tag as its
ref, of a token of the api scope: the pipelines API takes no job token), ensures one, counting
a skipped one as none, and looking again after a wait at a tag that has none, as GitLab makes the
pipeline of a push a moment after it (ensurePipeline), and waits for one until it settles
(waitForPipeline).
./releases reads the GitLab release of a tag (findRelease), its notes and its links. The bin
release-gitlab runs them.
releaseLinks of ./links makes the forge and the links of a release in one call, each a link of
the type package, as a GitLab release takes its links.
| Export | What it is |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| @wtf/release-gitlab | The types: GitLabPlatform, the platform GitLab is asked by, of its fetch (HttpFetch), and GitLabAuth, the token of a run |
| @wtf/release-gitlab/run | gitlabRunOf, the run of a pipeline; gitlabReleasePageOf, gitlabCommitPageOf, the pages of a release and a commit; serverOf, projectIdOf, the server and the project of a run; headersOf, of a token |
| @wtf/release-gitlab/trust | gitlabPublisherOf, the pipeline npm trusts to publish, of CI_PROJECT_PATH or the remote of gitlab.com and .gitlab-ci.yml; gitlabProjectOf, gitlabProjectOfRemote, the project |
| @wtf/release-gitlab/packages | gitlabRegistryOf, packageNameOf, findPackage, the page of a package of a package registry, and uploadGeneric |
| @wtf/release-gitlab/container | containerPageOf, the page of an image of the container registry, and checkContainerRegistry |
| @wtf/release-gitlab/forge | gitlabForge, GitLab as a Forge of @wtf/release/forge |
| @wtf/release-gitlab/pipelines | findPipelines, jobsOf, the pipelines of a tag and their jobs; createPipeline, one started of a tag; ensurePipeline, one started of a tag that has none or a skipped one, after a second look; waitForPipeline, isSettled, one waited for until it settles |
| @wtf/release-gitlab/releases | findRelease, the GitLab release of a tag, its notes and its links |
| @wtf/release-gitlab/settings | jobTokenPushOf: whether a project lets the CI/CD job token push to its repository |
| @wtf/release-gitlab/links | releaseLinks, the link of each package from the GitLab release of the tag |
| @wtf/release-gitlab/errors | GitLabError and GITLAB_ERRORS: EGITLAB, a request GitLab refused, and EGITLABPACKAGE, a package GitLab does not list; EGITLABPIPELINE, a tag GitLab starts no pipeline of; EGITLABTIMEOUT, a pipeline that has not settled in the time waited; EGITLABJOBTOKENPUSH, a project whose job token can push |
License
MIT
