-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add Package Registry #16510
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
Changes from 21 commits
51bc02e
48c2faf
3e801f9
3c86d2b
8d922ff
2b9d96a
99298b7
c7fb932
8aaf412
06790f9
338dee3
0544b22
5a3c561
ea36a75
8c6715b
ec05929
4a57e22
b8ac3e3
1386b27
9e5b2c0
8ba72d7
cab94bb
f16296c
9edf241
814a942
9417754
02708f8
cb360c0
7264b7e
7625900
2351df1
53a47de
e6075ab
068b1b1
c515aa6
55c6b2b
b856141
6fadfe9
c5a85b1
e60969b
4ced953
291cbf5
c060e4a
cd1bc10
12ca06f
2c9fa64
41efc7c
1b666dc
baf7074
3e462af
39a4115
fb4f039
08e6f82
fe02ca2
1cf894b
03b7122
faf5518
f30b09f
33045a1
4f1ffa6
b1c8554
3c5c54f
c0e542c
2b9574e
42aa098
b9e6fb1
d186342
2c04814
cb16fe8
af0ea8c
b24c033
7756689
483d8e5
dacf577
88aa66f
fa518b6
3f89e67
c444d4b
f3b0d77
1cef19a
a91f780
4162676
86af611
df1ceb5
5dc9a9a
77485e3
e01b8a7
82147e6
4d883cb
6335e68
d16c894
9e1c5c1
bd9a516
b7ebbaa
a54cf5c
28b1658
e12f3fc
1bf7106
1addc8e
9c13368
f7d2484
3cb36d5
2892782
7d41635
e84812c
87ac836
8934214
c910dd8
a86fd67
e0f9085
abf508f
b01d240
1239f82
ea24bfd
14179c5
16edc81
2b3dd59
842308c
da48b2e
df81183
ec9f89e
b4bf28e
ac23797
80a69aa
ba7f050
b10ef75
168e32a
83148f2
c6eca22
417308d
6e12833
bfae746
c6a45ff
1b4854c
c209e68
04b3aae
ff51ca9
fa0c89c
f596b58
6bdf396
e70ec8e
0aa6069
a5216a0
779c5d9
7ba602c
0293e77
9af3259
35c04f0
118770f
abf3a1e
5a4128a
3b8b071
f41cbf0
17b949e
dd953f2
6804517
15246c2
250443d
00dbfe2
5f8e6b2
d8b1c69
cb59cbd
d87c42b
6e24f6f
70c3825
af95307
8af95ef
1bf5b5f
c05f9fa
4aab760
431ba7c
be74e4d
3cb84ef
20facab
64d02e3
3a51b83
10c5f03
5d08e80
dbbbfa4
7efd245
f55dcbf
1d4ce1a
84ff7b0
16f8940
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ draft: false | |
menu: | ||
sidebar: | ||
name: "Developers" | ||
weight: 50 | ||
weight: 55 | ||
identifier: "developers" | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ draft: false | |
menu: | ||
sidebar: | ||
name: "開發人員" | ||
weight: 50 | ||
weight: 55 | ||
identifier: "developers" | ||
--- |
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" | ||
--- |
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" | ||
``` |
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 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maven's definition of
Suggested change
or even only
Suggested change
as that is even earlier in the lifecycle and Maven has no concept of a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how the Maven package manager works but both GitHub and GitLab use that in their documentation. https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#installing-a-package There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 An |
||||||||||
``` |
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 | ||
``` |
Uh oh!
There was an error while loading. Please reload this page.