You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/docs/adding-upm-package.md
+40-84
Original file line number
Diff line number
Diff line change
@@ -3,19 +3,39 @@ sidebar: true
3
3
sidebarDepth: 2
4
4
showFooter: false
5
5
---
6
-
# Adding Upm Package
6
+
# Adding UPM Package
7
7
8
-
## Upm Package Criteria
8
+
## UPM Package Criteria
9
9
10
10
OpenUPM requires the package repository fulfils below criteria
11
-
- Containing the required `package.json` of upm package. The `package.json` can be placed at any folder.
12
-
- Open source license. It is recommended to choose one from [spdx license list](https://spdx.org/licenses/), especially the one with OSI approved flag. For custom license (or dual licenses), it should be clear whether the package is commercial available.
13
-
- Hosting on Github. For now only GitHub repository are supported, but generic git support is under consideration.
14
-
- Git tags that conforms valid semver format, with or without the `v` prefix. i.e. `v1.1.0`, `1.1.0`, `1.1.1-preview`, `v2.0.0-preview.1`. Valid tags will be built as package releases. You can create git tags (though GitHub release feature) after adding a repository to the system.
11
+
- The valid UPM structure. At least contains a `package.json` file, can be placed at a sub-folder.
12
+
- An open source license. It is recommended to choose one from the [spdx license list](https://spdx.org/licenses/).
13
+
- Hosting on Github. For now only GitHub repositories are supported, but the generic git support is under consideration.
14
+
- Git tags that are valid semver, with/without the `v` prefix. i.e. `v1.1.0`, `1.1.0`, `1.1.1-preview`, `v2.0.0-preview.1`. Only valid tags are built. It is recommended to either using the GitHub release feature, or CI tools to create git tags.
15
+
16
+
## Understanding Different Folder Structures of UPM Repositories
17
+
18
+
There're three typical folder structures of UPM repositories. OpenUPM build pipelines can handle all of them.
19
+
20
+
- UPM package at the root path
21
+
- UPM package at a sub-folder
22
+
- UPM package at a sub-folder with UPM branch
23
+
24
+
### UPM Package at the Root Path
25
+
26
+
The `package.json` file is located at the root path of the master branch. It is the simplest case.
27
+
28
+
### UPM Package at a Sub-folder
29
+
30
+
The master branch is usually an Unity project (with Assets folder). The `package.json` file is located at a sub-folder, for example `Assets/package-name` or `Packages/com.namespace.package-name`. Git tags are based on the master branch. Build pipelines will detect the location of the `package.json` file, and handle it correctly.
31
+
32
+
### UPM Package at a Sub-folder with UPM Branch
33
+
34
+
The master branch is usually an Unity project (with Assets folder). The `package.json` file is located at a sub-folder, for example `Assets/package-name` or `Packages/com.namespace.package-name`. An `upm` branch is created from the package folder using the `git subtree split/push` command to make the `package.json` file placed at the root path. So the package can be installed by Unity Package Manager via git url. Git tags are based on the upm branch.
15
35
16
36
## Package YAML File
17
37
18
-
OpenUPM uses a yaml file to describe the package information. Here's an example.
38
+
OpenUPM uses a yaml file to store the package information. Here's an example.
19
39
20
40
```yaml
21
41
# package name
@@ -28,8 +48,6 @@ description: An unity package example
Package hunter can use the [package add form](/packages/add/), to add package yaml file to the system easily. The form will guide you to fill necessary information, generate the yaml file, add to GitHub via web page and start a pull request.
68
+
Package hunters can use the [package add form](/packages/add/), to submit the package yaml file. The form will guide you to fill required information, generate the yaml file, then submit to GitHub as pull request in the browser.
Once the pull request get merged, within a few minutes (for the CI to do the jobs):
55
-
- You can visit the package at url `/packages/com.namespace.package-name`.
56
-
- The package will be added to build pipelines, and results can be viewed from the **version history** and **build issues** sections on the package detail page.
72
+
The pull request of adding new package will be merged automatically. The CI will do jobs to update the website and build pipelines. Within a few minutes you can view the package detail page at url `/packages/com.namespace.package-name`, and check the build result from the **version history** and **build issues** sections.
57
73
58
74
@flowstart
59
-
form=>operation: Fill package form
60
-
yaml=>operation: Start pull request with generated YAML
61
-
merge=>operation: Wait pull request get merged
62
-
build=>end: Add to website and build pipeline
63
-
64
-
form->yaml
65
-
yaml->merge
66
-
merge->build
75
+
form=>operation: Fill the package form
76
+
pr=>operation: Start a pull request
77
+
ci=>operation: Wait the CI
78
+
79
+
form->pr
80
+
pr->ci
67
81
@flowend
68
82
69
83
## Troubleshooting
70
84
71
-
### Handling Different Folder Structures
72
-
73
-
There're three typical folder structures of repository.
74
-
75
-
- Pure upm package
76
-
- Upm package at a sub-folder
77
-
- Upm package at a sub-folder with upm branch
78
-
79
-
#### Pure Upm Package
80
-
81
-
The `package.json` is located at the root path of the master branch, and same for other git tags. This is the simplest case and will just work fine.
82
-
83
-
```yaml
84
-
# repository branch
85
-
repoBranch: master
86
-
# parent folder of package.json file
87
-
packageFolder: ''
88
-
```
89
-
90
-
#### Upm Package at a Sub-folder
91
-
92
-
The repository is an unity project (with Assets folder). The `package.json` is located at a sub-folder, for example `Assets/package-name` or `Packages/com.namespace.package-name`. The folder structure is same for git tags. You need provide the package folder to make the build pipeline work.
The repository is an unity project (with Assets folder). The `package.json` is located at a sub-folder, for example `Assets/package-name` or `Packages/com.namespace.package-name`. An upm branch is made from the subtree of the package folder, so it can be installed via git url by unity package manager.
104
-
105
-
Then you need double check the git tags, see if it was made from the upm branch or the master branch. Go to the release tab of the repository, find a release/tag, click on the hash link.
106
-
107
-

108
-
109
-
Then tap the `Browse files` button.
110
-
111
-

112
-
113
-
114
-
- If the git tag is made from upm branch, with a `package.json` file at the root path, then you can use upm as default branch and leave the package folder empty.
115
-
```yaml
116
-
# repository branch
117
-
repoBranch: upm
118
-
# parent folder of package.json file
119
-
packageFolder: ''
120
-
```
121
-
- If the git tags is made from master branch, where `package.json` file is located at a sub-folder, then you need provide package folder.
If a repository without valid git tags/releases. Then it can be only installed via git url. Please create an issue on the repository for making GitHub releases. The release name (git tag) need to be a valid semver. A common practice is naming the release name (git tag) as semver with prefix `v`. i.e. `v1.0.0` for version `1.0.0`.
87
+
Please create an issue on the author's repository for making GitHub releases. The git tag should be a valid semver.
132
88
133
-
### Handling Custom Build Script
89
+
### Handling the Custom Build Script
134
90
135
-
The build pipeline simply run `npm publish` on the package folder to bundle and publish package. If what you want is to exclude certain files from the package bundle, you can use `.npmigore` file at the same path of `package.json`. Learn more [here](https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package).
91
+
Build pipelines simply detect the package folder, and run the `npm publish` command in that folder to publish a package. If what you want is to exclude certain files from the package bundle, you can use the `.npmigore` file at the same path of the `package.json` file. Learn more [here](https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package).
136
92
137
-
Custom build script is not supported at the moment. Though we trended to use the standard `npm build` command. We're looking for an example repository to work with to support custom build script. If your package requires one, please [create an issue](https://github.com/openupm/openupm/issues) to start a conversation.
93
+
The custom build script is not supported at the moment. We're looking for an example repository to work with to support the custom build script. If your package do need the feature, please [create an issue](https://github.com/openupm/openupm/issues) to start a conversation.
0 commit comments