Skip to content

Commit

Permalink
feat(NuGet): Support NuGet GitHub Packages (#18)
Browse files Browse the repository at this point in the history
* support pushing NuGet packages to GitHub packages

* alternate conflict check
  • Loading branch information
jsteinich authored Dec 23, 2020
1 parent c86aaf8 commit f3ed13c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ npx jsii-release-nuget [DIR]
|Option|Required|Description|
|------|--------|-----------|
|`NUGET_API_KEY`|Required|[NuGet API Key](https://www.nuget.org/account/apikeys) with "Push" permissions|
|`NUGET_SERVER`|Optional|NuGet Server URL (defaults to nuget.org)|

**Publish to GitHub Packages**

* Set `NUGET_SERVER` to `https://nuget.pkg.github.com/(`org or user`).
* Set `NUGET_API_KEY` to a token with write packages permissions.
* Make sure the repository url in the project file matches the org or user used for the server

## PyPI

Expand All @@ -177,7 +184,7 @@ npx jsii-release-pypi [DIR]
## Roadmap

- [X] GitHub Support: Maven
- [ ] GitHub Support: NuGet
- [X] GitHub Support: NuGet
- [ ] CodeArtifact Support: Maven
- [ ] CodeArtifact Support: NuGet
- [ ] CodeArtifact Support: Python
Expand Down
4 changes: 2 additions & 2 deletions bin/jsii-release-nuget
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi

echo "Publishing NuGet packages..."

nuget_source="https://api.nuget.org/v3/index.json"
nuget_source="${NUGET_SERVER:-"https://api.nuget.org/v3/index.json"}"
nuget_symbol_source="https://nuget.smbsrc.net/"

log=$(mktemp -d)/log.txt
Expand All @@ -50,7 +50,7 @@ for package_dir in ${packages}; do
# If push failed, check if this was caused because we are trying to publish
# the same version again, which is not an error by searching for a magic string in the log
# ugly, yes!
if cat ${log} | grep -q "already exists and cannot be modified"; then
if cat ${log} | grep -q -e "already exists and cannot be modified" -e "409 (Conflict)"; then
echo "⚠️ Artifact already published. Skipping"
elif [ "${exit_code}" -ne 0 ]; then
echo "❌ Release failed"
Expand Down

0 comments on commit f3ed13c

Please sign in to comment.