Skip to content

Commit adfc64b

Browse files
committed
Added publishing to CI/CD if tag is present
1 parent 4aeca52 commit adfc64b

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

.github/workflows/cicd.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,28 @@ jobs:
1919
- uses: actions/setup-dotnet@v1
2020
with:
2121
dotnet-version: "5.0.x"
22+
- name: Set RELEASE_VERSION
23+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
2224
- name: Restore Packages
2325
run: dotnet restore
2426
- name: Build
2527
run: dotnet build --configuration Release --verbosity minimal
2628
- name: Test
2729
run: dotnet test SpotifyAPI.Web.Tests
30+
- name: Publish to NuGET
31+
run: ./publish.sh
32+
if: startsWith( github.ref, 'refs/tags/')
33+
env:
34+
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
35+
- name: Publish to GH Release
36+
uses: actions/create-release@v1
37+
if: startsWith( github.ref, 'refs/tags/')
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
with:
41+
tag_name: ${{ github.ref }}
42+
release_name: SpotifyAPI Web ${{ RELEASE_VERSION }}
43+
body: |
44+
TODO
45+
draft: true
46+
prerelease: false

SpotifyAPI.Web/SpotifyAPI.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<NoWarn>1591</NoWarn>
2727
</PropertyGroup>
2828

29-
<PropertyGroup Condition="'$(APPVEYOR)' == 'true'">
29+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
3030
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
3131
</PropertyGroup>
3232

publish.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ set -e
44

55
echo "Publishing..."
66

7-
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
8-
alias nuget="mono /usr/local/bin/nuget.exe"
9-
107
cd ./SpotifyAPI.Web
11-
dotnet pack -c Release SpotifyAPI.Web.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME"
12-
nuget push "./bin/Release/SpotifyAPI.Web.$APPVEYOR_REPO_TAG_NAME.nupkg"\
8+
dotnet pack -c Release SpotifyAPI.Web.csproj -p:PackageVersion="$RELEASE_VERSION"
9+
nuget push "./bin/Release/SpotifyAPI.Web.$RELEASE_VERSION.nupkg"\
1310
-ApiKey "$NUGET_TOKEN"\
1411
-NonInteractive\
1512
-Source https://www.nuget.org/api/v2/package
1613

1714
cd ../SpotifyAPI.Web.Auth
18-
dotnet pack -c Release SpotifyAPI.Web.Auth.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME"
19-
nuget push "./bin/Release/SpotifyAPI.Web.Auth.$APPVEYOR_REPO_TAG_NAME.nupkg"\
15+
dotnet pack -c Release SpotifyAPI.Web.Auth.csproj -p:PackageVersion="$RELEASE_VERSION"
16+
nuget push "./bin/Release/SpotifyAPI.Web.Auth.$RELEASE_VERSION.nupkg"\
2017
-ApiKey "$NUGET_TOKEN"\
2118
-NonInteractive\
2219
-Source https://www.nuget.org/api/v2/package

0 commit comments

Comments
 (0)