Skip to content

Commit

Permalink
Merge pull request #83 from TSRBerry/publish-nuget
Browse files Browse the repository at this point in the history
Publish to NuGet.org package registry
  • Loading branch information
JoeStrout authored Jul 1, 2023
2 parents 8511e25 + bb0a075 commit 5e4f43f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish on Github Packages
name: Publish NuGet packages

on:
workflow_run:
Expand All @@ -12,9 +12,12 @@ on:
permissions:
packages: write

env:
PACKAGE_NAME: "org.miniscript.MiniScript"

jobs:
check_nuget:
name: Check what kind of Nuget release is required
name: Check what kind of NuGet release is required
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
Expand All @@ -30,10 +33,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Get latest nuget package version
- name: Get latest package version from Github Packages
id: nuget-ver
run: |
export NUGET_VER=$(gh api -H "Accept: application/vnd.github+json" /users/${{ github.repository_owner }}/packages/nuget/Miniscript/versions | jq '.[0].name' | tr -d '"' | awk -F'-' '{print $1}')
export NUGET_VER=$(gh api -H "Accept: application/vnd.github+json" /users/${{ github.repository_owner }}/packages/nuget/${{ env.PACKAGE_NAME }}/versions | jq '.[0].name' | tr -d '"' | awk -F'-' '{print $1}')
echo "version=${NUGET_VER}" >> $GITHUB_OUTPUT
- name: Compare vs current version
Expand All @@ -45,7 +48,7 @@ jobs:
|| echo "new-version=false" >> $GITHUB_OUTPUT
nuget:
name: Release Nuget package
name: Release NuGet package
runs-on: ubuntu-latest
needs: check_nuget
if: ${{ github.event.workflow_run.conclusion == 'success' }}
Expand All @@ -67,8 +70,11 @@ jobs:
- name: Package
run: |
[[ "${{ needs.check_nuget.outputs.release }}" == "true" ]] \
&& dotnet pack -c Release \
|| dotnet pack -c Release --version-suffix $(git rev-parse --short HEAD)
&& dotnet pack -c Release -p:RepositoryBranch="master" -p:RepositoryCommit="$(git rev-parse HEAD)" \
|| dotnet pack -c Release -p:RepositoryBranch="master" -p:RepositoryCommit="$(git rev-parse HEAD)" --version-suffix "p$(git rev-parse --short HEAD)"
- name: Publish to GitHub Packages
run: dotnet nuget push "bin/Release/${{ env.PACKAGE_NAME }}.*.nupkg" --source "github" --api-key "${{ secrets.GHPR_TOKEN }}"

- name: Publish Nuget package
run: dotnet nuget push "bin/Release/Miniscript.*.nupkg" --source "github" --api-key "${{ secrets.GHPR_TOKEN }}"
- name: Publish to NuGet
run: dotnet nuget push "bin/Release/${{ env.PACKAGE_NAME }}.*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json
Binary file added Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion MiniScript-cs/Miniscript.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Copyright>Copyright © $([System.DateTime]::UtcNow.Year) Joe Strout ($([System.DateTime]::UtcNow.ToString("s")))</Copyright>
<ProjectGuid>{C3806B8F-9702-4B39-B6D9-9ECBC298565F}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Miniscript</RootNamespace>
<AssemblyName>Miniscript</AssemblyName>
<TargetFrameworks>net45;net5.0</TargetFrameworks>
<PackageId>org.miniscript.MiniScript</PackageId>
<VersionPrefix>1.6.1</VersionPrefix>
<Authors>Joe Strout</Authors>
<Title>MiniScript</Title>
<Description>C# implementation of the MiniScript scripting language</Description>
<Copyright>Copyright © $([System.DateTime]::UtcNow.Year) Joe Strout ($([System.DateTime]::UtcNow.ToString("s")))</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://miniscript.org/</PackageProjectUrl>
<PackageIcon>Icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>miniscript;programming language</PackageTags>
<PackageReleaseNotes>Please visit https://github.com/JoeStrout/miniscript/blob/master/MiniScript-Release-Notes.txt to read the release notes.</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JoeStrout/miniscript</RepositoryUrl>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
Expand All @@ -29,4 +40,10 @@
<Externalconsole>true</Externalconsole>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<None Include="../Icon.png" Pack="true" PackagePath="/"/>
<None Include="../README.md" Pack="true" PackagePath="/"/>
</ItemGroup>

</Project>

0 comments on commit 5e4f43f

Please sign in to comment.