Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Package Registry #16510

Merged
merged 184 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
51bc02e
Added package store settings.
KN4CK3R Jul 11, 2021
48c2faf
Added models.
KN4CK3R Jul 11, 2021
3e801f9
Added generic package registry.
KN4CK3R Jul 11, 2021
3c86d2b
Added tests.
KN4CK3R Jul 11, 2021
8d922ff
Added NuGet package registry.
KN4CK3R Jul 13, 2021
2b9d96a
Moved service index to api file.
KN4CK3R Jul 13, 2021
99298b7
Added NPM package registry.
KN4CK3R Jul 14, 2021
c7fb932
Added Maven package registry.
KN4CK3R Jul 17, 2021
8aaf412
Added PyPI package registry.
KN4CK3R Jul 18, 2021
06790f9
Summary is deprecated.
KN4CK3R Jul 19, 2021
338dee3
Changed npm name.
KN4CK3R Jul 20, 2021
0544b22
Sanitize project url.
KN4CK3R Jul 20, 2021
5a3c561
Allow only scoped packages.
KN4CK3R Jul 20, 2021
ea36a75
Added user interface.
KN4CK3R Jul 20, 2021
8c6715b
Changed method name.
KN4CK3R Jul 20, 2021
ec05929
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Jul 20, 2021
4a57e22
Added missing migration file.
KN4CK3R Jul 20, 2021
b8ac3e3
Set page info.
KN4CK3R Jul 21, 2021
1386b27
Added documentation.
KN4CK3R Jul 21, 2021
9e5b2c0
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Jul 21, 2021
8ba72d7
Added documentation links.
KN4CK3R Jul 21, 2021
cab94bb
Fixed wrong error message.
KN4CK3R Jul 22, 2021
f16296c
Lint template files.
KN4CK3R Jul 22, 2021
9edf241
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Aug 7, 2021
814a942
Fixed merge errors.
KN4CK3R Aug 7, 2021
9417754
Fixed unit test storage path.
KN4CK3R Aug 7, 2021
02708f8
Switch to json module.
KN4CK3R Aug 8, 2021
cb360c0
Added suggestions.
KN4CK3R Aug 9, 2021
7264b7e
Added package webhook.
KN4CK3R Aug 10, 2021
7625900
Add package api.
KN4CK3R Aug 11, 2021
2351df1
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Aug 11, 2021
53a47de
Fixed swagger file.
KN4CK3R Aug 11, 2021
e6075ab
Fixed enum and comments.
KN4CK3R Aug 11, 2021
068b1b1
Fixed NuGet pagination.
KN4CK3R Aug 11, 2021
c515aa6
Print test names.
KN4CK3R Aug 11, 2021
55c6b2b
Added api tests.
KN4CK3R Aug 11, 2021
b856141
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Aug 12, 2021
6fadfe9
Fixed access level.
KN4CK3R Aug 15, 2021
c5a85b1
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Aug 15, 2021
e60969b
Fix User unmarshal.
KN4CK3R Aug 15, 2021
4ced953
Added RubyGems package registry.
KN4CK3R Aug 23, 2021
291cbf5
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Aug 23, 2021
c060e4a
Fix lint.
KN4CK3R Aug 23, 2021
cd1bc10
Implemented io.Writer.
KN4CK3R Aug 26, 2021
12ca06f
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Aug 27, 2021
2c9fa64
Added support for sha256/sha512 checksum files.
KN4CK3R Sep 1, 2021
41efc7c
Improved maven-metadata.xml support.
KN4CK3R Sep 2, 2021
1b666dc
Added support for symbol package uploads.
KN4CK3R Sep 6, 2021
baf7074
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 6, 2021
3e462af
Added tests.
KN4CK3R Sep 6, 2021
39a4115
Added overview docs.
KN4CK3R Sep 6, 2021
fb4f039
Added npm dependencies and keywords.
KN4CK3R Sep 7, 2021
08e6f82
Added no-packages information.
KN4CK3R Sep 7, 2021
fe02ca2
Display file size.
KN4CK3R Sep 7, 2021
1cf894b
Display asset count.
KN4CK3R Sep 7, 2021
03b7122
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 7, 2021
faf5518
Fixed filter alignment.
KN4CK3R Sep 7, 2021
f30b09f
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 8, 2021
33045a1
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 9, 2021
4f1ffa6
Added package icons.
KN4CK3R Sep 9, 2021
b1c8554
Formatted instructions.
KN4CK3R Sep 9, 2021
3c5c54f
Allow anonymous package downloads.
KN4CK3R Sep 9, 2021
c0e542c
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 9, 2021
2b9574e
Fixed comments.
KN4CK3R Sep 13, 2021
42aa098
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 13, 2021
b9e6fb1
Fixed postgres test.
KN4CK3R Sep 13, 2021
d186342
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 14, 2021
2c04814
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 26, 2021
cb16fe8
Moved file.
KN4CK3R Sep 28, 2021
af0ea8c
Moved models to models/packages.
KN4CK3R Sep 28, 2021
b24c033
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 28, 2021
7756689
Use correct error response format per client.
KN4CK3R Sep 30, 2021
483d8e5
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Sep 30, 2021
dacf577
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Oct 2, 2021
88aa66f
Use simpler search form.
KN4CK3R Oct 2, 2021
fa518b6
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Oct 10, 2021
3f89e67
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Oct 29, 2021
c444d4b
Fixed IsProd.
KN4CK3R Oct 30, 2021
f3b0d77
Restructured data model.
KN4CK3R Nov 7, 2021
1cef19a
Prevent empty filename.
KN4CK3R Nov 7, 2021
a91f780
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 9, 2021
4162676
Fix swagger.
KN4CK3R Nov 9, 2021
86af611
Implemented user/org registry.
KN4CK3R Nov 9, 2021
df1ceb5
Implemented UI.
KN4CK3R Nov 12, 2021
5dc9a9a
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 13, 2021
77485e3
Use GetUserByIDCtx.
KN4CK3R Nov 13, 2021
e01b8a7
Use table for dependencies.
KN4CK3R Nov 13, 2021
82147e6
make svg
KN4CK3R Nov 13, 2021
4d883cb
Added support for unscoped npm packages.
KN4CK3R Nov 14, 2021
6335e68
Add support for npm dist tags.
KN4CK3R Nov 15, 2021
d16c894
Added tests for npm tags.
KN4CK3R Nov 15, 2021
9e1c5c1
Unlink packages if repository gets deleted.
KN4CK3R Nov 16, 2021
bd9a516
Prevent user/org delete if a packages exist.
KN4CK3R Nov 16, 2021
b7ebbaa
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 16, 2021
a54cf5c
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 18, 2021
28b1658
Use package unlink in repository service.
KN4CK3R Nov 19, 2021
e12f3fc
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 20, 2021
1bf7106
Added support for composer packages.
KN4CK3R Nov 22, 2021
1addc8e
Restructured package docs.
KN4CK3R Nov 22, 2021
9c13368
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 22, 2021
f7d2484
Added missing tests.
KN4CK3R Nov 22, 2021
3cb36d5
Fixed generic content page.
KN4CK3R Nov 22, 2021
2892782
Fixed docs.
KN4CK3R Nov 22, 2021
7d41635
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 23, 2021
e84812c
Fixed swagger.
KN4CK3R Nov 23, 2021
87ac836
Added missing type.
KN4CK3R Nov 23, 2021
8934214
Fixed ambiguous column.
KN4CK3R Nov 23, 2021
c910dd8
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 23, 2021
a86fd67
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 24, 2021
e0f9085
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 24, 2021
abf508f
Organize content store by sha256 hash.
KN4CK3R Nov 27, 2021
b01d240
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Nov 27, 2021
1239f82
Added admin package management.
KN4CK3R Nov 30, 2021
ea24bfd
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Dec 1, 2021
14179c5
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Dec 2, 2021
16edc81
Added support for sorting.
KN4CK3R Dec 8, 2021
2b3dd59
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Jan 10, 2022
842308c
Add support for multiple identical versions/files.
KN4CK3R Jan 13, 2022
da48b2e
Added missing repository unlink.
KN4CK3R Jan 13, 2022
df81183
Added file properties.
KN4CK3R Jan 21, 2022
ec9f89e
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Feb 10, 2022
b4bf28e
make fmt
KN4CK3R Feb 10, 2022
ac23797
lint
KN4CK3R Feb 10, 2022
80a69aa
Added Conan package registry.
KN4CK3R Feb 14, 2022
ba7f050
Updated docs.
KN4CK3R Feb 14, 2022
b10ef75
Unify package names.
KN4CK3R Feb 14, 2022
168e32a
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Feb 14, 2022
83148f2
Added swagger enum.
KN4CK3R Feb 14, 2022
c6eca22
Use longer TEXT column type.
KN4CK3R Feb 14, 2022
417308d
Removed version composite key.
KN4CK3R Feb 14, 2022
6e12833
Merged package and container registry.
KN4CK3R Feb 15, 2022
bfae746
Removed index.
KN4CK3R Feb 15, 2022
c6a45ff
Use dedicated package router.
KN4CK3R Feb 15, 2022
1b4854c
Moved files to new location.
KN4CK3R Feb 15, 2022
c209e68
Updated docs.
KN4CK3R Feb 15, 2022
04b3aae
Fixed JOIN order.
KN4CK3R Feb 15, 2022
ff51ca9
Fixed GROUP BY statement.
KN4CK3R Feb 16, 2022
fa0c89c
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Feb 17, 2022
f596b58
Fixed GROUP BY #2.
KN4CK3R Feb 17, 2022
6bdf396
Added symbol server support.
KN4CK3R Feb 20, 2022
e70ec8e
Added more tests.
KN4CK3R Feb 20, 2022
0aa6069
Set NOT NULL.
KN4CK3R Feb 24, 2022
a5216a0
Added setting to disable package registries.
KN4CK3R Mar 3, 2022
779c5d9
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 12, 2022
7ba602c
Moved auth into service.
KN4CK3R Mar 13, 2022
0293e77
refactor
KN4CK3R Mar 13, 2022
9af3259
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 14, 2022
35c04f0
Use ctx everywhere.
KN4CK3R Mar 15, 2022
118770f
Added package cleanup task.
KN4CK3R Mar 17, 2022
abf3a1e
Changed packages path.
KN4CK3R Mar 18, 2022
5a4128a
Added container registry.
KN4CK3R Mar 20, 2022
3b8b071
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 20, 2022
f41cbf0
Refactoring
KN4CK3R Mar 20, 2022
17b949e
Updated comparison.
KN4CK3R Mar 20, 2022
dd953f2
Fix swagger.
KN4CK3R Mar 20, 2022
6804517
Fixed table order.
KN4CK3R Mar 20, 2022
15246c2
Use token auth for npm routes.
KN4CK3R Mar 22, 2022
250443d
Enabled ReverseProxy auth.
KN4CK3R Mar 22, 2022
00dbfe2
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 22, 2022
5f8e6b2
Added packages link for orgs.
KN4CK3R Mar 23, 2022
d8b1c69
Fixed anonymous org access.
KN4CK3R Mar 25, 2022
cb59cbd
Enable copy button for setup instructions.
KN4CK3R Mar 25, 2022
d87c42b
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 25, 2022
6e24f6f
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 26, 2022
70c3825
Merge error
KN4CK3R Mar 27, 2022
af95307
Added suggestions.
KN4CK3R Mar 27, 2022
8af95ef
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 27, 2022
1bf5b5f
Fixed merge.
KN4CK3R Mar 27, 2022
c05f9fa
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 27, 2022
4aab760
Merge branch 'main' into feature-packages
wxiaoguang Mar 28, 2022
431ba7c
Merge branch 'main' into feature-packages
wxiaoguang Mar 28, 2022
be74e4d
Handle "generic".
KN4CK3R Mar 28, 2022
3cb84ef
Added link for TODO.
KN4CK3R Mar 28, 2022
20facab
Added suggestions.
KN4CK3R Mar 28, 2022
64d02e3
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 28, 2022
3a51b83
Merge branch 'feature-packages' of https://github.com/KN4CK3R/gitea i…
KN4CK3R Mar 28, 2022
10c5f03
Changed temporary buffer filename.
KN4CK3R Mar 28, 2022
5d08e80
Merge branch 'main' into feature-packages
wxiaoguang Mar 28, 2022
dbbbfa4
Added suggestions.
KN4CK3R Mar 29, 2022
7efd245
Merge branch 'main' of https://github.com/go-gitea/gitea into feature…
KN4CK3R Mar 29, 2022
f55dcbf
Merge branch 'main' into feature-packages
wxiaoguang Mar 29, 2022
1d4ce1a
Apply suggestions from code review
wxiaoguang Mar 30, 2022
84ff7b0
Update docs/content/doc/packages/nuget.en-us.md
wxiaoguang Mar 30, 2022
16f8940
Merge branch 'main' into feature-packages
wxiaoguang Mar 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,16 @@ PATH =
;[lfs]
;STORAGE_TYPE = local

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; settings for packages, will override storage setting
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[storage.packages]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; storage type
;STORAGE_TYPE = local

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; customize storage
Expand Down
2 changes: 1 addition & 1 deletion docs/content/doc/developers.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ draft: false
menu:
sidebar:
name: "Developers"
weight: 50
weight: 55
identifier: "developers"
---
2 changes: 1 addition & 1 deletion docs/content/doc/developers.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ draft: false
menu:
sidebar:
name: "開發人員"
weight: 50
weight: 55
identifier: "developers"
---
3 changes: 2 additions & 1 deletion docs/content/doc/features/comparison.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ _Symbols used in table:_
| Integrated Git-powered wiki | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ (cloud only) | ✘ |
| Deploy Tokens | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Repository Tokens with write rights | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Built-in Container Registry | [✘](https://github.com/go-gitea/gitea/issues/2316) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ |
| Built-in Container Registry | [✘](https://github.com/go-gitea/gitea/issues/2316) | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ |
| Built-in Package Registry | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ |
KN4CK3R marked this conversation as resolved.
Show resolved Hide resolved
| External git mirroring | ✓ | ✓ | ✘ | ✘ | ✓ | ✓ | ✓ |
| FIDO U2F (2FA) | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ |
| Built-in CI/CD | ✘ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ |
Expand Down
12 changes: 12 additions & 0 deletions docs/content/doc/packages.en-us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
date: "2021-07-20T00:00:00+00:00"
title: "Package Registry"
slug: "packages"
toc: false
draft: false
menu:
sidebar:
name: "Package Registry"
weight: 45
identifier: "packages"
---
82 changes: 82 additions & 0 deletions docs/content/doc/packages/generic.en-us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
date: "2021-07-20T00:00:00+00:00"
title: "Generic Packages Repository"
slug: "generic"
draft: false
toc: false
menu:
sidebar:
parent: "packages"
name: "Generic"
weight: 10
identifier: "generic"
---

# Generic Packages Repository

Publish generic files, like release binaries or other output, in your project’s Package Registry.

**Table of Contents**

{{< toc >}}

## Authenticate to the package registry

To authenticate to the Package Registry, you need to provide [custom HTTP headers or use HTTP Basic authentication]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}).

## Publish a package

To publish a generic package perform a HTTP PUT operation with the package content in the request body.
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.

```
PUT https://gitea.example.com/api/v1/repos/{owner}/{repository}/packages/generic/{package_name}/{package_version}/{file_name}
```

| Parameter | Description |
| ----------------- | ----------- |
| `owner` | The owner of the repository. |
| `repository` | The name of the repository. |
| `package_name` | The package name. It can contain only lowercase letters (`a-z`), uppercase letter (`A-Z`), numbers (`0-9`), dots (`.`), hyphens (`-`), or underscores (`_`). |
| `package_version` | The package version as described in the [SemVer](https://semver.org/) spec. |
| `file_name` | The filename. It can contain only lowercase letters (`a-z`), uppercase letter (`A-Z`), numbers (`0-9`), dots (`.`), hyphens (`-`), or underscores (`_`). |

Example request using HTTP Basic authentication:

```shell
curl --user your_username:your_password_or_token \
--upload-file path/to/file.bin \
"https://gitea.example.com/api/v1/repos/testuser/test-repository/packages/generic/test_package/1.0.0/file.bin"
```

The server reponds with the following HTTP Status codes.

| HTTP Status Code | Meaning |
| ----------------- | ------- |
| `201 Created` | The package has been published. |
| `400 Bad Request` | The package name and/or version are invalid or a package with the same name and version already exist. |
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved

## Download a package

To download a generic package perform a HTTP GET operation.

```
GET https://gitea.example.com/api/v1/repos/{owner}/{repository}/packages/generic/{package_name}/{package_version}/{file_name}
```

| Parameter | Description |
| ----------------- | ----------- |
| `owner` | The owner of the repository. |
| `repository` | The name of the repository. |
| `package_name` | The package name. |
| `package_version` | The package version. |
| `file_name` | The filename. |

The file content is served in the response body. The response content type is `application/octet-stream`.

Example request using HTTP Basic authentication:

```shell
curl --user your_username:your_token_or_password \
"https://gitea.example.com/api/v1/repos/testuser/test-repository/packages/generic/test_package/1.0.0/file.bin"
```
103 changes: 103 additions & 0 deletions docs/content/doc/packages/maven.en-us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
date: "2021-07-20T00:00:00+00:00"
title: "Maven Packages Repository"
slug: "maven"
draft: false
toc: false
menu:
sidebar:
parent: "packages"
name: "Maven"
weight: 40
identifier: "maven"
---

# Maven Packages Repository

Publish [Maven](https://maven.apache.org) packages in your project’s Package Registry.

**Table of Contents**

{{< toc >}}

## Requirements

To work with the Maven package registry, you can use [Maven](https://maven.apache.org/install.html) or [Gradle](https://gradle.org/install/).
The following examples use `Maven`.

## Configuring the package registry

To register the project’s package registry you first need to add your access token to the [`settings.xml`](https://maven.apache.org/settings.html) file:

```xml
<settings>
<servers>
<server>
<id>gitea</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<value>token {access_token}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
```

Afterwards add the following sections to your project `pom.xml` file:

```xml
<repositories>
<repository>
<id>gitea</id>
<url>https://gitea.example.com/api/v1/repos/{owner}/{repository}/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://gitea.example.com/api/v1/repos/{owner}/{repository}/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitea</id>
<url>https://gitea.example.com/api/v1/repos/{owner}/{repository}/packages/maven</url>
</snapshotRepository>
</distributionManagement>
```

| Parameter | Description |
| -------------- | ----------- |
| `access_token` | Your [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}). |
| `owner` | The owner of the repository. |
| `repository` | The name of the repository. |

## Publish a package

To publish a package simply run:

```shell
mvn deploy
```

You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.

## Install a package

To install a Maven package from the package registry, add a new dependency to your project `pom.xml` file:

```xml
<dependency>
<groupId>com.test.package</groupId>
<artifactId>test_project</artifactId>
<version>1.0.0</version>
</dependency>
```

Afterwards run:

```shell
mvn install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maven's definition of install is a bit different than what you would expect: install makes the current project available to be used as dependency for other local projects, so it installs the project locally.
I think you want

Suggested change
mvn install
mvn package

or even only

Suggested change
mvn install
mvn compile

as that is even earlier in the lifecycle and Maven has no concept of a download dependencies command.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downloading of dependencies is done automatically without supplemental command. If you start a build via mvn package everything will be downloaded what is needed.

An mvn install means to install the created artifact within your local cache $HOME/.m2/repository which means some other project on the same machine can consume those artifacts.
If you like to distribute artifacts to a wider audience it is needed to deploy them via mvn deploy which is defined by <distributionManagement>..</distributionManagement>...this contains usually a definition of a repository manager...

```
81 changes: 81 additions & 0 deletions docs/content/doc/packages/npm.en-us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
date: "2021-07-20T00:00:00+00:00"
title: "npm Packages Repository"
slug: "npm"
draft: false
toc: false
menu:
sidebar:
parent: "packages"
name: "npm"
weight: 30
identifier: "npm"
---

# npm Packages Repository

Publish [npm](https://www.npmjs.com/) packages in your project’s Package Registry.

**Table of Contents**

{{< toc >}}

## Requirements

To work with the npm package registry, you need [Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm/) or an other tool like [Yarn](https://classic.yarnpkg.com/en/docs/install).
KN4CK3R marked this conversation as resolved.
Show resolved Hide resolved

Only [scoped](https://docs.npmjs.com/misc/scope/) packages are supported.

The following examples use the `npm` tool with the scope `@test`.

## Configuring the package registry

To register the project’s package registry you need to configure a new package source.

```shell
npm config set {scope}:registry https://gitea.example.com/api/v1/repos/{owner}/{repository}/packages/npm
npm config set -- '//gitea.example.com/api/v1/repos/{owner}/{repository}/packages/npm/:_authToken' "{token}"
```

| Parameter | Description |
| ------------ | ----------- |
| `scope` | The scope of the packages. |
| `owner` | The owner of the repository. |
| `repository` | The name of the repository. |
| `token` | Your [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}). |

For example:

```shell
npm config set @test:registry https://gitea.example.com/api/v1/repos/testuser/test-repository/packages/npm
npm config set -- '//gitea.example.com/api/v1/repos/testuser/test-repository/packages/npm/:_authToken' "personal_access_token"
```

## Publish a package

Publish a package by running the following command in your project:

```shell
npm publish
```

You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.

## Install a package

To install a package from the package registry, execute the following command:

```shell
npm install {scope}/{package_name}
```

| Parameter | Description |
| -------------- | ----------- |
| `scope` | The scope of the packages. |
| `package_name` | The package name. |

For example:

```shell
npm install @test/test_package
```
Loading