-
Notifications
You must be signed in to change notification settings - Fork 23
Publish plugin to public UPM feed #34
Changes from all commits
fcf4d4f
c5c10e1
f2eed9b
f0d863b
1a4241c
5d8878d
fbad940
e687598
b8f7e6f
72c6ba3
8276ee9
3aab0e9
87951f4
4e66246
5ac58ee
2d814b0
8e6a7c4
f65d0f1
5b3703e
1b78897
822aa4c
fb20c77
73d4100
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
registry=https://pkgs.dev.azure.com/aipmr/MixedReality-Unity-Packages/_packaging/Unity-packages/npm/registry/ | ||
registry=https://microsoft.pkgs.visualstudio.com/Analog/_packaging/MixedReality-UPM-Internal/npm/registry/ | ||
|
||
always-auth=true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,45 +20,65 @@ def main(): | |
parser.add_argument("-o", "--output", help="Output location, will use default build/npm location if unspecified", type=str.lower) | ||
parser.add_argument("-v", "--version", help="Semantic version string for the package", type=str.lower) | ||
parser.add_argument("-p", "--publish", help="Publish the package to NPM feed", action='store_true') | ||
parser.add_argument("-t", "--tarball", help="Publish specified tarball", type=str.lower) | ||
parser.add_argument("-d", "--dryrun", help="Simulate publishing without pushing", action='store_true') | ||
args = parser.parse_args() | ||
|
||
# Copy plugin binaries to project location | ||
if not args.stage: | ||
stage.stage_binaries() | ||
else: | ||
stage.stage_binaries(args.stage) | ||
if not args.tarball: | ||
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. Is there a reason why you start with !tarball instead of checking for args=tarball? It's easier for me to think in the positive case instead of negating the comparator. 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. Well, the script takes the plugin folder into a tarball which then gets pushed to the feed or it can just pack it as a tarball to be pushed later. The initial idea was to push to the internal feed during the packaging stage and store the tarball as an artifact which can be then downloaded during the "publish" stage to be pushed to the public feed. Unfortunately pushing the tarball is cryptically failing on the CI build machine. Long winded way to say this wasn't super intentional. :) |
||
# Copy plugin binaries to project location | ||
if not args.stage: | ||
stage.stage_binaries() | ||
else: | ||
stage.stage_binaries(args.stage) | ||
|
||
git_root = oshelpers.fixpath(githelpers.get_root()) | ||
git_root = oshelpers.fixpath(githelpers.get_root()) | ||
|
||
# Default output path is under build/unity | ||
npm_package_location = oshelpers.fixpath(git_root, constants.build_root, "npm") | ||
if args.output: | ||
npm_package_location = args.output | ||
# Default output path is under build/unity | ||
npm_package_location = oshelpers.fixpath(git_root, constants.build_root, "npm") | ||
if args.output: | ||
npm_package_location = args.output | ||
|
||
if not os.path.isdir(npm_package_location): | ||
os.mkdir(npm_package_location) | ||
if not os.path.isdir(npm_package_location): | ||
os.mkdir(npm_package_location) | ||
|
||
unity_project_full_path = oshelpers.fixpath(git_root, constants.unity_project_dir, "Assets", constants.spatializer_plugin_name) | ||
npm_package_full_path = oshelpers.fixpath(npm_package_location, constants.spatializer_plugin_name + "." + args.version) | ||
# Specify the package version before packing | ||
result = subprocess.run(["cmd", "/c", "npm version", args.version, "--allow-same-version"], cwd=unity_project_full_path) | ||
local_copy = False | ||
if args.publish: | ||
npm_command = ["cmd", "/c", "npm publish"] | ||
else: | ||
local_copy = True | ||
npm_command = ["cmd", "/c", "npm pack"] | ||
result = subprocess.run(npm_command, cwd=unity_project_full_path) | ||
if (result.returncode != 0): | ||
print("Package generation failed!") | ||
print(result.stdout) | ||
print(result.stderr) | ||
unity_project_full_path = oshelpers.fixpath(git_root, constants.unity_project_dir, "Assets", constants.spatializer_plugin_name) | ||
# Specify the package version before packing | ||
result = subprocess.run(["cmd", "/c", "npm version", args.version, "--allow-same-version"], cwd=unity_project_full_path) | ||
local_copy = False | ||
if args.publish: | ||
npm_command = ["cmd", "/c", "npm publish", "--dry-run" if args.dryrun else ""] | ||
else: | ||
local_copy = True | ||
npm_command = ["cmd", "/c", "npm pack"] | ||
print(npm_command) | ||
result = subprocess.run(npm_command, cwd=unity_project_full_path) | ||
if (result.returncode != 0): | ||
print("Package generation failed!") | ||
print(result.stdout) | ||
print(result.stderr) | ||
else: | ||
if local_copy: | ||
npm_package_full_path = oshelpers.fixpath(unity_project_full_path, constants.spatializer_npm_package_name + "-" + args.version + ".tgz") | ||
shutil.move(npm_package_full_path, npm_package_location) | ||
print("Package successfully generated: " + npm_package_full_path) | ||
for file in os.listdir(npm_package_location): | ||
if file.endswith(".tgz"): | ||
print("Package successfully moved to " + oshelpers.fixpath(npm_package_location, file)) | ||
else: | ||
print("Package successfully published") | ||
else: | ||
if local_copy: | ||
shutil.move(oshelpers.fixpath(unity_project_full_path, constants.spatializer_npm_package_name + "-" + args.version + ".tgz"), npm_package_location) | ||
print("Package successfully generated: " + npm_package_full_path) | ||
if not os.path.exists(args.tarball): | ||
print("Can't find tarball " + args.tarball) | ||
exit | ||
npm_command = ["cmd", "/c", "npm publish", args.tarball, "--dry-run" if args.dryrun else ""] | ||
print(npm_command) | ||
result = subprocess.run(npm_command) | ||
if (result.returncode != 0): | ||
print("Package generation failed!") | ||
print(result.stdout) | ||
print(result.stderr) | ||
else: | ||
print("Package successfully published") | ||
print("Published tarball!") | ||
|
||
if __name__ == '__main__': | ||
main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the name of the feed includes the word "Internal". Is this a staging feed before the package goes to an external feed? It's obvious that I don't know how all of this works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the packaging stage we publish to an internal feed, which can be then tested to make sure everything is good. Once the build is "approved" after the packaging phase, the publishing phase then pushes the plugin to both nuget and UPM public feeds. There are two separate .npmrc files that correspond to internal and public feeds, these are under "tools" subdir. These get placed (and renamed to ".npmrc") under the plugin hierarchy depending on which feed we need to publish to.