Added publishing to CI/CD if tag is present

This commit is contained in:
Jonas Dellinger 2020-11-14 10:21:38 +01:00
parent 4aeca5216d
commit adfc64b957
3 changed files with 24 additions and 8 deletions

View File

@ -19,9 +19,28 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"
- name: Set RELEASE_VERSION
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Restore Packages
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --verbosity minimal
- name: Test
run: dotnet test SpotifyAPI.Web.Tests
- name: Publish to NuGET
run: ./publish.sh
if: startsWith( github.ref, 'refs/tags/')
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
- name: Publish to GH Release
uses: actions/create-release@v1
if: startsWith( github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: SpotifyAPI Web ${{ RELEASE_VERSION }}
body: |
TODO
draft: true
prerelease: false

View File

@ -26,7 +26,7 @@
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(APPVEYOR)' == 'true'">
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

View File

@ -4,19 +4,16 @@ set -e
echo "Publishing..."
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
alias nuget="mono /usr/local/bin/nuget.exe"
cd ./SpotifyAPI.Web
dotnet pack -c Release SpotifyAPI.Web.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME"
nuget push "./bin/Release/SpotifyAPI.Web.$APPVEYOR_REPO_TAG_NAME.nupkg"\
dotnet pack -c Release SpotifyAPI.Web.csproj -p:PackageVersion="$RELEASE_VERSION"
nuget push "./bin/Release/SpotifyAPI.Web.$RELEASE_VERSION.nupkg"\
-ApiKey "$NUGET_TOKEN"\
-NonInteractive\
-Source https://www.nuget.org/api/v2/package
cd ../SpotifyAPI.Web.Auth
dotnet pack -c Release SpotifyAPI.Web.Auth.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME"
nuget push "./bin/Release/SpotifyAPI.Web.Auth.$APPVEYOR_REPO_TAG_NAME.nupkg"\
dotnet pack -c Release SpotifyAPI.Web.Auth.csproj -p:PackageVersion="$RELEASE_VERSION"
nuget push "./bin/Release/SpotifyAPI.Web.Auth.$RELEASE_VERSION.nupkg"\
-ApiKey "$NUGET_TOKEN"\
-NonInteractive\
-Source https://www.nuget.org/api/v2/package