From 0d321f232cc10f2755d9a21028ab2160f18c040f Mon Sep 17 00:00:00 2001 From: Yaakov Date: Wed, 22 Mar 2023 20:10:21 +1100 Subject: [PATCH] Push packages regularly to GitHub Packages (#1206) Publish the latest code from master branch to GitHub Packages as Alpha-tagged prerelease NuGet packages. --- .github/workflows/steamkit2-build.yaml | 33 ++++++++++++++++++++++++ .github/workflows/steamkit2-release.yaml | 9 +++++++ Directory.Build.props | 6 ++--- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.github/workflows/steamkit2-build.yaml b/.github/workflows/steamkit2-build.yaml index d2207b340..14172f90a 100644 --- a/.github/workflows/steamkit2-build.yaml +++ b/.github/workflows/steamkit2-build.yaml @@ -21,6 +21,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Setup .NET Core uses: actions/setup-dotnet@v3 @@ -61,6 +63,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Setup .NET Core uses: actions/setup-dotnet@v3 @@ -83,6 +87,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Setup .NET Core uses: actions/setup-dotnet@v3 @@ -110,6 +116,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v1 @@ -133,3 +141,28 @@ jobs: with: name: NetHook2 path: 'Resources/NetHook2/Release/*.dll' + + gh-packages: + name: Publish to GitHub Packages + if: github.event_name != 'pull_request' + permissions: + packages: write + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + + - name: Create NuGet Package + run: dotnet pack --configuration Release SteamKit2/SteamKit2/SteamKit2.csproj + + - name: Publish NuGet Package to GitHub Packages + run: | + dotnet nuget push SteamKit2\SteamKit2\bin\Release\SteamKit2.*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/SteamRE/index.json diff --git a/.github/workflows/steamkit2-release.yaml b/.github/workflows/steamkit2-release.yaml index bbe145c08..6354730c0 100644 --- a/.github/workflows/steamkit2-release.yaml +++ b/.github/workflows/steamkit2-release.yaml @@ -4,6 +4,9 @@ on: release: types: [ published ] +permissions: + packages: write + jobs: publish-nupkg: name: Publish NuGet Package @@ -12,6 +15,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Setup .NET Core uses: actions/setup-dotnet@v3 @@ -41,3 +46,7 @@ jobs: run: | nuget setapikey ${{ secrets.NUGET_API_KEY }} nuget push SteamKit2/SteamKit2/bin/Release/SteamKit2.${{ github.event.release.tag_name }}.nupkg -Source https://api.nuget.org/v3/index.json + + - name: Publish NuGet Package to GitHub Packages + run: | + dotnet nuget push SteamKit2/SteamKit2/bin/Release/SteamKit2.${{ github.event.release.tag_name }}.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/SteamRE/index.json \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index b7f535720..310bfc85f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,11 +5,11 @@ - $(SteamKitBaseVersion).$(GITHUB_RUN_NUMBER) - $(SteamKitBaseVersion).0 + $(SteamKitBaseVersion)-Alpha.$(GITHUB_RUN_NUMBER) + $(SteamKitBaseVersion) $(SteamKitBaseVersion) - $(SteamKitVersion) + $(SteamKitBaseVersion) $(SteamKitVersion) $(GITHUB_REF.Substring(11))