Skip to content

Commit 85a32f5

Browse files
authored
Merge branch 'main' into bugfix/issue-22934
2 parents 75ab86d + 5eea61d commit 85a32f5

File tree

26 files changed

+1425
-25
lines changed

26 files changed

+1425
-25
lines changed

custom/conf/app.example.ini

+2
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,8 @@ ROUTER = console
25162516
;LIMIT_SIZE_PYPI = -1
25172517
;; Maximum size of a RubyGems upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
25182518
;LIMIT_SIZE_RUBYGEMS = -1
2519+
;; Maximum size of a Swift upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2520+
;LIMIT_SIZE_SWIFT = -1
25192521
;; Maximum size of a Vagrant upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
25202522
;LIMIT_SIZE_VAGRANT = -1
25212523

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
12541254
- `LIMIT_SIZE_PUB`: **-1**: Maximum size of a Pub upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12551255
- `LIMIT_SIZE_PYPI`: **-1**: Maximum size of a PyPI upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12561256
- `LIMIT_SIZE_RUBYGEMS`: **-1**: Maximum size of a RubyGems upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1257+
- `LIMIT_SIZE_SWIFT`: **-1**: Maximum size of a Swift upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12571258
- `LIMIT_SIZE_VAGRANT`: **-1**: Maximum size of a Vagrant upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12581259

12591260
## Mirror (`mirror`)

docs/content/doc/packages/overview.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The following package managers are currently supported:
4040
| [Pub]({{< relref "doc/packages/pub.en-us.md" >}}) | Dart | `dart`, `flutter` |
4141
| [PyPI]({{< relref "doc/packages/pypi.en-us.md" >}}) | Python | `pip`, `twine` |
4242
| [RubyGems]({{< relref "doc/packages/rubygems.en-us.md" >}}) | Ruby | `gem`, `Bundler` |
43+
| [Swift]({{< relref "doc/packages/rubygems.en-us.md" >}}) | Swift | `swift` |
4344
| [Vagrant]({{< relref "doc/packages/vagrant.en-us.md" >}}) | - | `vagrant` |
4445

4546
**The following paragraphs only apply if Packages are not globally disabled!**
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
date: "2023-01-10T00:00:00+00:00"
3+
title: "Swift Packages Repository"
4+
slug: "packages/swift"
5+
draft: false
6+
toc: false
7+
menu:
8+
sidebar:
9+
parent: "packages"
10+
name: "Swift"
11+
weight: 95
12+
identifier: "swift"
13+
---
14+
15+
# Swift Packages Repository
16+
17+
Publish [Swift](hhttps://www.swift.org/) packages for your user or organization.
18+
19+
**Table of Contents**
20+
21+
{{< toc >}}
22+
23+
## Requirements
24+
25+
To work with the Swift package registry, you need to use [swift](https://www.swift.org/getting-started/) to consume and a HTTP client (like `curl`) to publish packages.
26+
27+
## Configuring the package registry
28+
29+
To register the package registry and provide credentials, execute:
30+
31+
```shell
32+
swift package-registry set https://gitea.example.com/api/packages/{owner}/swift -login {username} -password {password}
33+
```
34+
35+
| Placeholder | Description |
36+
| ------------ | ----------- |
37+
| `owner` | The owner of the package. |
38+
| `username` | Your Gitea username. |
39+
| `password` | Your Gitea password. If you are using 2FA or OAuth use a [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}) instead of the password. |
40+
41+
The login is optional and only needed if the package registry is private.
42+
43+
## Publish a package
44+
45+
First you have to pack the contents of your package:
46+
47+
```shell
48+
swift package archive-source
49+
```
50+
51+
To publish the package perform a HTTP PUT request with the package content in the request body.
52+
53+
```shell --user your_username:your_password_or_token \
54+
curl -X PUT --user {username}:{password} \
55+
-H "Accept: application/vnd.swift.registry.v1+json" \
56+
-F source-archive=@/path/to/package.zip \
57+
-F metadata={metadata} \
58+
https://gitea.example.com/api/packages/{owner}/swift/{scope}/{name}/{version}
59+
```
60+
61+
| Placeholder | Description |
62+
| ----------- | ----------- |
63+
| `username` | Your Gitea username. |
64+
| `password` | Your Gitea password. If you are using 2FA or OAuth use a [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}) instead of the password. |
65+
| `owner` | The owner of the package. |
66+
| `scope` | The package scope. |
67+
| `name` | The package name. |
68+
| `version` | The package version. |
69+
| `metadata` | (Optional) The metadata of the package. JSON encoded subset of https://schema.org/SoftwareSourceCode |
70+
71+
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
72+
73+
## Install a package
74+
75+
To install a Swift package from the package registry, add it in the `Package.swift` file dependencies list:
76+
77+
```
78+
dependencies: [
79+
.package(id: "{scope}.{name}", from:"{version}")
80+
]
81+
```
82+
83+
| Parameter | Description |
84+
| ----------- | ----------- |
85+
| `scope` | The package scope. |
86+
| `name` | The package name. |
87+
| `version` | The package version. |
88+
89+
Afterwards execute the following command to install it:
90+
91+
```shell
92+
swift package resolve
93+
```

models/actions/run.go

+11
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) {
128128
return nil, fmt.Errorf("event %s is not a push event", run.Event)
129129
}
130130

131+
func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, error) {
132+
if run.Event == webhook_module.HookEventPullRequest {
133+
var payload api.PullRequestPayload
134+
if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil {
135+
return nil, err
136+
}
137+
return &payload, nil
138+
}
139+
return nil, fmt.Errorf("event %s is not a pull request event", run.Event)
140+
}
141+
131142
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
132143
_, err := db.GetEngine(ctx).ID(repo.ID).
133144
SetExpr("num_action_runs",

models/packages/descriptor.go

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"code.gitea.io/gitea/modules/packages/pub"
2525
"code.gitea.io/gitea/modules/packages/pypi"
2626
"code.gitea.io/gitea/modules/packages/rubygems"
27+
"code.gitea.io/gitea/modules/packages/swift"
2728
"code.gitea.io/gitea/modules/packages/vagrant"
2829

2930
"github.com/hashicorp/go-version"
@@ -159,6 +160,8 @@ func GetPackageDescriptor(ctx context.Context, pv *PackageVersion) (*PackageDesc
159160
metadata = &pypi.Metadata{}
160161
case TypeRubyGems:
161162
metadata = &rubygems.Metadata{}
163+
case TypeSwift:
164+
metadata = &swift.Metadata{}
162165
case TypeVagrant:
163166
metadata = &vagrant.Metadata{}
164167
default:

models/packages/package.go

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const (
4444
TypePub Type = "pub"
4545
TypePyPI Type = "pypi"
4646
TypeRubyGems Type = "rubygems"
47+
TypeSwift Type = "swift"
4748
TypeVagrant Type = "vagrant"
4849
)
4950

@@ -62,6 +63,7 @@ var TypeList = []Type{
6263
TypePub,
6364
TypePyPI,
6465
TypeRubyGems,
66+
TypeSwift,
6567
TypeVagrant,
6668
}
6769

@@ -96,6 +98,8 @@ func (pt Type) Name() string {
9698
return "PyPI"
9799
case TypeRubyGems:
98100
return "RubyGems"
101+
case TypeSwift:
102+
return "Swift"
99103
case TypeVagrant:
100104
return "Vagrant"
101105
}
@@ -133,6 +137,8 @@ func (pt Type) SVGName() string {
133137
return "gitea-python"
134138
case TypeRubyGems:
135139
return "gitea-rubygems"
140+
case TypeSwift:
141+
return "gitea-swift"
136142
case TypeVagrant:
137143
return "gitea-vagrant"
138144
}

0 commit comments

Comments
 (0)