glpkg publish
Publish the package in the current directory to the package registry of the current GitLab project.
glpkg publish|pub [options] [type]
Arguments and options
| Option | Description |
|---|---|
[type] | latest (default), dev or beta. For npm this is also the dist-tag. |
--bump <type> | Bump the version first: patch, minor or major |
--dry-run | Do everything except upload and Git steps. package.json, pyproject.toml and *.csproj are restored afterwards. |
--token <token> | Use this token instead of the saved one |
--no-build | Skip the build step (PyPI: python -m build; NuGet: dotnet pack) |
--git-tag <bool> | Create the release commit and tag (default true) |
--push <bool> | Push to the remote after publishing (default true) |
--force | Publish even if the Git working tree is not clean |
--no-repository | Do not add a repository field to package.json from the Git origin |
--pypi / --go / --nuget / --generic | Publish another package type |
--manifest <file> | Manifest file for --generic (default glpkg.json) |
--git-tag and --push take the strings true or false. Their defaults can be changed
with glpkg config defaults.
Requirements
- A token (saved,
GITLAB_TOKEN, or--token). gitandglab. glpkg runsglab api projects/:idto find the GitLab project of the current repository and publishes to that project's registry. It does not create projects.- A clean working tree, unless
--forceor--dry-run.
Versions
| Command | package.json 1.2.3 becomes | npm dist-tag |
|---|---|---|
glpkg publish | 1.2.3 (unchanged) | latest |
glpkg publish --bump patch | 1.2.4 | latest |
glpkg publish --bump minor | 1.3.0 | latest |
glpkg publish beta --bump minor | 1.3.0-beta.0 | beta |
glpkg publish beta | 1.2.3 (unchanged) | beta |
glpkg publish dev | 1.2.3-dev.<timestamp> | dev |
--bump drops any pre-release suffix before incrementing (1.3.0-beta.0 + patch →
1.3.1). A dev publish always uses the current base version plus a timestamp.
Git steps
After a successful upload, for latest and beta:
git add <manifest> && git commit -m "chore: release v<version>"git tag v<version>git push, thengit push --tags
A dev publish creates no commit or tag; it writes the dev version into package.json
and leaves it uncommitted. With --push on, it still runs git push.
Turn the steps off with --git-tag false and/or --push false. A failed push prints a
warning; push manually afterwards.
repository field
If package.json has no repository field, glpkg adds one from the Git origin URL before
publishing, so the published package links to its source. It is committed with the release
commit. Use --no-repository to skip this.
Other package types
| Type | Reads | What happens |
|---|---|---|
--pypi | pyproject.toml | python -m build, then twine upload to the project PyPI registry. Needs build and twine. |
--nuget | *.csproj | dotnet pack -c Release, then dotnet nuget push to the project NuGet registry (duplicates skipped). |
--go | go.mod | No upload: runs go mod tidy, creates the next version tag (latest tag + --bump, or + patch) and pushes it. GitLab serves the module from the tag. [type] and --git-tag are not used; --push false skips the push. |
--generic | glpkg.json or --manifest | Creates a tarball and uploads it to the project generic registry. [type] and --bump are not used. |
See Python, Go, NuGet and generic packages.
Examples
glpkg publish --dry-run
glpkg publish --bump patch
glpkg publish beta --bump minor
glpkg publish --bump patch --git-tag false --push false # CI without git writes
glpkg publish --pypi --bump patch
glpkg publish --go --bump minor