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 - uses: actions/setup-dotnet@v1
with: with:
dotnet-version: "5.0.x" dotnet-version: "5.0.x"
- name: Set RELEASE_VERSION
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Restore Packages - name: Restore Packages
run: dotnet restore run: dotnet restore
- name: Build - name: Build
run: dotnet build --configuration Release --verbosity minimal run: dotnet build --configuration Release --verbosity minimal
- name: Test - name: Test
run: dotnet test SpotifyAPI.Web.Tests 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> <NoWarn>1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(APPVEYOR)' == 'true'"> <PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup> </PropertyGroup>

View File

@ -4,19 +4,16 @@ set -e
echo "Publishing..." 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 cd ./SpotifyAPI.Web
dotnet pack -c Release SpotifyAPI.Web.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME" dotnet pack -c Release SpotifyAPI.Web.csproj -p:PackageVersion="$RELEASE_VERSION"
nuget push "./bin/Release/SpotifyAPI.Web.$APPVEYOR_REPO_TAG_NAME.nupkg"\ nuget push "./bin/Release/SpotifyAPI.Web.$RELEASE_VERSION.nupkg"\
-ApiKey "$NUGET_TOKEN"\ -ApiKey "$NUGET_TOKEN"\
-NonInteractive\ -NonInteractive\
-Source https://www.nuget.org/api/v2/package -Source https://www.nuget.org/api/v2/package
cd ../SpotifyAPI.Web.Auth cd ../SpotifyAPI.Web.Auth
dotnet pack -c Release SpotifyAPI.Web.Auth.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME" dotnet pack -c Release SpotifyAPI.Web.Auth.csproj -p:PackageVersion="$RELEASE_VERSION"
nuget push "./bin/Release/SpotifyAPI.Web.Auth.$APPVEYOR_REPO_TAG_NAME.nupkg"\ nuget push "./bin/Release/SpotifyAPI.Web.Auth.$RELEASE_VERSION.nupkg"\
-ApiKey "$NUGET_TOKEN"\ -ApiKey "$NUGET_TOKEN"\
-NonInteractive\ -NonInteractive\
-Source https://www.nuget.org/api/v2/package -Source https://www.nuget.org/api/v2/package