From b1a86874e7ef388816183439cd6553954d655f7b Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:07:08 +1000 Subject: [PATCH 01/14] chore: add GitHubFlow/v1 spec --- GitVersion.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 GitVersion.yml diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 000000000..58c304159 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1 @@ +workflow: GitHubFlow/v1 \ No newline at end of file From 38d3114854b53711ff5b2e37f952fe4b5242f8d1 Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:19:25 +1000 Subject: [PATCH 02/14] feat: add ci --- .github/workflows/ci.yaml | 230 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..2a05f363c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,230 @@ +name: Build & Publish + +on: + push: + paths-ignore: + - "docfx/**" + branches: ["main", "dev"] + pull_request: + branches: ["main", "dev"] + workflow_dispatch: + +env: + BUILD_TYPE: Release + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v1 + with: + versionSpec: 6.x + + - name: Execute GitVersion + uses: gittools/actions/gitversion/execute@v1 + with: + useConfigFile: true + + build_windows: + needs: setup + runs-on: windows-latest + steps: + - name: Prepare env + shell: bash + run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + + - name: Visual Studio environment + shell: cmd + run: | + :: See https://github.com/microsoft/vswhere/wiki/Find-VC + for /f "usebackq delims=*" %%i in (`vswhere -latest -property installationPath`) do ( + call "%%i"\Common7\Tools\vsdevcmd.bat -arch=x64 -host_arch=x64 + ) + + :: Loop over all environment variables and make them global. + for /f "delims== tokens=1,2" %%a in ('set') do ( + echo>>"%GITHUB_ENV%" %%a=%%b + ) + + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Build + run: | + mkdir -p build + cd build + cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} .. + cmake --build . --config ${{env.BUILD_TYPE}} -- /m:16 + + - name: Clean build directory + run: | + mkdir -p build/addons/counterstrikesharp/bin/win64 + mv build/${{env.BUILD_TYPE}}/*.dll build/addons/counterstrikesharp/bin/win64 + mkdir build/output/ + mv build/addons build/output + + - uses: actions/upload-artifact@v4 + with: + name: counterstrikesharp-build-windows-${env:GitVersion_SemVer} + path: build/output/ + + build_linux: + needs: setup + runs-on: ubuntu-latest + # Could not figure out how to run in a container only on some matrix paths, so I've split it out into its own build. + container: + image: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest + steps: + - name: Prepare env + shell: bash + run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Build + run: | + mkdir -p build + cd build + cmake -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} .. + cmake --build . --config ${{env.BUILD_TYPE}} -- -j16 + + - name: Clean build directory + run: | + mkdir build/output/ + mv build/addons build/output + + - uses: actions/upload-artifact@v4 + with: + name: counterstrikesharp-build-linux-${env:GitVersion_SemVer} + path: build/output/ + + build_managed: + needs: setup + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Prepare env + shell: bash + run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + + # We don't need expensive submodules for the managed side. + - uses: actions/checkout@v4 + + - name: Build runtime v${env:GitVersion_SemVer} + uses: actions/setup-dotnet@v4 + with: + dotnet-version: "8.0.x" + + - name: Install dependencies + run: dotnet restore managed/CounterStrikeSharp.sln + + - name: Run tests + run: dotnet test --logger trx --results-directory "TestResults-${env:GitVersion_SemVer}" managed/CounterStrikeSharp.API.Tests/CounterStrikeSharp.API.Tests.csproj + + - name: Upload dotnet test results + uses: actions/upload-artifact@v4 + with: + name: test-results-${env:GitVersion_SemVer} + path: TestResults-${env:GitVersion_SemVer} + if: ${{ always() }} + + - name: Publish artifacts + run: | + dotnet publish -c Release \ + /p:Version=${GitVersion_FullSemVer} \ + /p:AssemblyVersion=${GitVersion_AssemblySemVer} \ + /p:InformationalVersion=${GitVersion_InformationalVersion} \ + managed/CounterStrikeSharp.API + + dotnet pack -c Release \ + /p:Version=${GitVersion_FullSemVer} \ + /p:AssemblyVersion=${GitVersion_AssemblySemVer} \ + /p:InformationalVersion=${GitVersion_InformationalVersion} \ + managed/CounterStrikeSharp.API + + - uses: actions/upload-artifact@v4 + with: + name: counterstrikesharp-build-api-${env:GitVersion_SemVer} + path: managed/CounterStrikeSharp.API/bin/Release + + publish: + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + permissions: + contents: write + needs: ["setup", "build_linux", "build_windows", "build_managed"] + runs-on: ubuntu-latest + steps: + - name: Prepare env + shell: bash + run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + + - uses: actions/download-artifact@v4 + with: + name: counterstrikesharp-build-windows-${env:GitVersion_SemVer} + path: build/windows + + - uses: actions/download-artifact@v4 + with: + name: counterstrikesharp-build-linux-${env:GitVersion_SemVer} + path: build/linux + + - uses: actions/download-artifact@v4 + with: + name: counterstrikesharp-build-api-${env:GitVersion_SemVer} + path: build/api + + # TODO: This stuff should really be in a matrix + - name: Add API to Artifacts + run: | + mkdir -p build/linux/addons/counterstrikesharp/api + mkdir -p build/windows/addons/counterstrikesharp/api + cp -r build/api/net8.0/publish/* build/linux/addons/counterstrikesharp/api + cp -r build/api/net8.0/publish/* build/windows/addons/counterstrikesharp/api + + - name: Zip Builds + run: | + (cd build/linux && zip -qq -r ../../counterstrikesharp-linux-${env:GitVersion_SemVer}.zip *) + (cd build/windows && zip -qq -r ../../counterstrikesharp-windows-${env:GitVersion_SemVer}.zip *) + + - name: Add dotnet runtime + run: | + mkdir -p build/linux/addons/counterstrikesharp/dotnet + curl -s -L https://download.visualstudio.microsoft.com/download/pr/c1371dc2-eed2-47be-9af3-ae060dbe3c7d/bd509e0a87629764ed47608466d183e6/aspnetcore-runtime-8.0.3-linux-x64.tar.gz \ + | tar xvz -C build/linux/addons/counterstrikesharp/dotnet + + mkdir -p build/windows/addons/counterstrikesharp/dotnet + curl -s -L https://download.visualstudio.microsoft.com/download/pr/086d1dd6-57a5-437a-a1ef-549cf702fb48/dd4a8fe6c53a1016a414d6f2925c1323/aspnetcore-runtime-8.0.3-win-x64.zip -o dotnet.zip + unzip -qq dotnet.zip -d build/windows/addons/counterstrikesharp/dotnet + + - name: Zip Builds + run: | + (cd build/linux && zip -qq -r ../../counterstrikesharp-with-runtime-linux-${env:GitVersion_SemVer}.zip *) + (cd build/windows && zip -qq -r ../../counterstrikesharp-with-runtime-windows-${env:GitVersion_SemVer}.zip *) + + - name: Release + id: release + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ needs.setup.outputs.buildnumber }} + files: | + counterstrikesharp-windows-${env:GitVersion_SemVer}.zip + counterstrikesharp-with-runtime-windows-${env:GitVersion_SemVer}.zip + counterstrikesharp-linux-${env:GitVersion_SemVer}.zip + counterstrikesharp-with-runtime-linux-${env:GitVersion_SemVer}.zip + + - name: Publish NuGet package + run: | + dotnet nuget push build/api/CounterStrikeSharp.API.${env:GitVersion_SemVer}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + dotnet nuget push build/api/CounterStrikeSharp.API.${env:GitVersion_SemVer}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + + - name: Send Notification to Discord + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + uses: Ilshidur/action-discord@0.3.2 + with: + args: "A new release of CS# has been tagged (v${{ needs.setup.outputs.buildnumber }}) at ${{ steps.release.outputs.url }}" From 411ad31a1b459df0c3131b0deb26fea2e38ad5f3 Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:21:34 +1000 Subject: [PATCH 03/14] fix: ci --- .github/workflows/ci.yaml | 83 ++------------------------------------- 1 file changed, 3 insertions(+), 80 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2a05f363c..085cd9657 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: Build & Publish +name: CI on: push: @@ -19,7 +19,7 @@ jobs: - name: Install GitVersion uses: gittools/actions/gitversion/setup@v1 with: - versionSpec: 6.x + versionSpec: 6.0.x - name: Execute GitVersion uses: gittools/actions/gitversion/execute@v1 @@ -150,81 +150,4 @@ jobs: - uses: actions/upload-artifact@v4 with: name: counterstrikesharp-build-api-${env:GitVersion_SemVer} - path: managed/CounterStrikeSharp.API/bin/Release - - publish: - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - permissions: - contents: write - needs: ["setup", "build_linux", "build_windows", "build_managed"] - runs-on: ubuntu-latest - steps: - - name: Prepare env - shell: bash - run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV - - - uses: actions/download-artifact@v4 - with: - name: counterstrikesharp-build-windows-${env:GitVersion_SemVer} - path: build/windows - - - uses: actions/download-artifact@v4 - with: - name: counterstrikesharp-build-linux-${env:GitVersion_SemVer} - path: build/linux - - - uses: actions/download-artifact@v4 - with: - name: counterstrikesharp-build-api-${env:GitVersion_SemVer} - path: build/api - - # TODO: This stuff should really be in a matrix - - name: Add API to Artifacts - run: | - mkdir -p build/linux/addons/counterstrikesharp/api - mkdir -p build/windows/addons/counterstrikesharp/api - cp -r build/api/net8.0/publish/* build/linux/addons/counterstrikesharp/api - cp -r build/api/net8.0/publish/* build/windows/addons/counterstrikesharp/api - - - name: Zip Builds - run: | - (cd build/linux && zip -qq -r ../../counterstrikesharp-linux-${env:GitVersion_SemVer}.zip *) - (cd build/windows && zip -qq -r ../../counterstrikesharp-windows-${env:GitVersion_SemVer}.zip *) - - - name: Add dotnet runtime - run: | - mkdir -p build/linux/addons/counterstrikesharp/dotnet - curl -s -L https://download.visualstudio.microsoft.com/download/pr/c1371dc2-eed2-47be-9af3-ae060dbe3c7d/bd509e0a87629764ed47608466d183e6/aspnetcore-runtime-8.0.3-linux-x64.tar.gz \ - | tar xvz -C build/linux/addons/counterstrikesharp/dotnet - - mkdir -p build/windows/addons/counterstrikesharp/dotnet - curl -s -L https://download.visualstudio.microsoft.com/download/pr/086d1dd6-57a5-437a-a1ef-549cf702fb48/dd4a8fe6c53a1016a414d6f2925c1323/aspnetcore-runtime-8.0.3-win-x64.zip -o dotnet.zip - unzip -qq dotnet.zip -d build/windows/addons/counterstrikesharp/dotnet - - - name: Zip Builds - run: | - (cd build/linux && zip -qq -r ../../counterstrikesharp-with-runtime-linux-${env:GitVersion_SemVer}.zip *) - (cd build/windows && zip -qq -r ../../counterstrikesharp-with-runtime-windows-${env:GitVersion_SemVer}.zip *) - - - name: Release - id: release - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ needs.setup.outputs.buildnumber }} - files: | - counterstrikesharp-windows-${env:GitVersion_SemVer}.zip - counterstrikesharp-with-runtime-windows-${env:GitVersion_SemVer}.zip - counterstrikesharp-linux-${env:GitVersion_SemVer}.zip - counterstrikesharp-with-runtime-linux-${env:GitVersion_SemVer}.zip - - - name: Publish NuGet package - run: | - dotnet nuget push build/api/CounterStrikeSharp.API.${env:GitVersion_SemVer}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate - dotnet nuget push build/api/CounterStrikeSharp.API.${env:GitVersion_SemVer}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate - - - name: Send Notification to Discord - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - uses: Ilshidur/action-discord@0.3.2 - with: - args: "A new release of CS# has been tagged (v${{ needs.setup.outputs.buildnumber }}) at ${{ steps.release.outputs.url }}" + path: managed/CounterStrikeSharp.API/bin/Release \ No newline at end of file From e45ff941f97b2c4fb49bd918064ac3c1f99c490a Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:23:19 +1000 Subject: [PATCH 04/14] fix: ci --- .github/workflows/ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 085cd9657..017a459f6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,6 +21,11 @@ jobs: with: versionSpec: 6.0.x + - uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + - name: Execute GitVersion uses: gittools/actions/gitversion/execute@v1 with: From 72964af75e32662043eea206e40a88c84b3236ea Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:24:10 +1000 Subject: [PATCH 05/14] chore: remove submodules --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 017a459f6..f475d7157 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,6 @@ jobs: - uses: actions/checkout@v4 with: - submodules: "recursive" fetch-depth: 0 - name: Execute GitVersion From cc3dfa8ce77e565428b91b217be18c30be477dce Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:26:59 +1000 Subject: [PATCH 06/14] fix: CI --- .github/workflows/ci.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f475d7157..5648c6246 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -119,7 +119,7 @@ jobs: # We don't need expensive submodules for the managed side. - uses: actions/checkout@v4 - - name: Build runtime v${env:GitVersion_SemVer} + - name: Build runtime v${{ env.GitVersion_SemVer }} uses: actions/setup-dotnet@v4 with: dotnet-version: "8.0.x" @@ -139,16 +139,16 @@ jobs: - name: Publish artifacts run: | - dotnet publish -c Release \ - /p:Version=${GitVersion_FullSemVer} \ - /p:AssemblyVersion=${GitVersion_AssemblySemVer} \ - /p:InformationalVersion=${GitVersion_InformationalVersion} \ + dotnet publish -c Release + /p:Version=${GitVersion_FullSemVer} + /p:AssemblyVersion=${GitVersion_AssemblySemVer} + /p:InformationalVersion=${GitVersion_InformationalVersion} managed/CounterStrikeSharp.API - dotnet pack -c Release \ - /p:Version=${GitVersion_FullSemVer} \ - /p:AssemblyVersion=${GitVersion_AssemblySemVer} \ - /p:InformationalVersion=${GitVersion_InformationalVersion} \ + dotnet pack -c Release + /p:Version=${GitVersion_FullSemVer} + /p:AssemblyVersion=${GitVersion_AssemblySemVer} + /p:InformationalVersion=${GitVersion_InformationalVersion} managed/CounterStrikeSharp.API - uses: actions/upload-artifact@v4 From beb09f2cab88be4ad40bdf251aed6af0845d788d Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:28:02 +1000 Subject: [PATCH 07/14] fix: concurrency --- .github/workflows/ci.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5648c6246..54ab1fae0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,5 +1,12 @@ name: CI +env: + BUILD_TYPE: Release + +# Remove default permissions of GITHUB_TOKEN for security +# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs +permissions: {} + on: push: paths-ignore: @@ -9,8 +16,10 @@ on: branches: ["main", "dev"] workflow_dispatch: -env: - BUILD_TYPE: Release +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.sha }} + cancel-in-progress: true + jobs: setup: From 989aa78205a9bfed6ea1cb1dd94c76e550d6a0d1 Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:31:16 +1000 Subject: [PATCH 08/14] fix: env --- .github/workflows/ci.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 54ab1fae0..e31454e26 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -39,6 +39,13 @@ jobs: with: useConfigFile: true + - name: Set Version Env + shell: bash + run: | + echo "GitVersion_SemVer=${GitVersion_SemVer::7}" >> $GITHUB_ENV + echo "GitVersion_AssemblySemVer=${GitVersion_AssemblySemVer::7}" >> $GITHUB_ENV + echo "GitVersion_InformationalVersion=${GitVersion_InformationalVersion::7}" >> $GITHUB_ENV + build_windows: needs: setup runs-on: windows-latest From 3b2de72b5be0b8d4e988b1ab842c5764cb1d5dd1 Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:34:19 +1000 Subject: [PATCH 09/14] fix: use step outputs --- .github/workflows/ci.yaml | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e31454e26..bf6efb8ca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,6 +24,11 @@ concurrency: jobs: setup: runs-on: ubuntu-latest + outputs: + gitversion_semver: ${{ steps.gitversion.outputs.semVer }} + gitversion_fullsemver: ${{ steps.gitversion.outputs.fullSemVer }} + gitversion_assemblysemver: ${{ steps.gitversion.outputs.assemblySemVer }} + gitversion_informationalversion: ${{ steps.gitversion.outputs.informationalVersion }} steps: - name: Install GitVersion uses: gittools/actions/gitversion/setup@v1 @@ -35,17 +40,11 @@ jobs: fetch-depth: 0 - name: Execute GitVersion + id: gitversion uses: gittools/actions/gitversion/execute@v1 with: useConfigFile: true - - name: Set Version Env - shell: bash - run: | - echo "GitVersion_SemVer=${GitVersion_SemVer::7}" >> $GITHUB_ENV - echo "GitVersion_AssemblySemVer=${GitVersion_AssemblySemVer::7}" >> $GITHUB_ENV - echo "GitVersion_InformationalVersion=${GitVersion_InformationalVersion::7}" >> $GITHUB_ENV - build_windows: needs: setup runs-on: windows-latest @@ -87,7 +86,7 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: counterstrikesharp-build-windows-${env:GitVersion_SemVer} + name: counterstrikesharp-build-windows-${{ needs.setup.outputs.gitversion_semver }} path: build/output/ build_linux: @@ -119,7 +118,7 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: counterstrikesharp-build-linux-${env:GitVersion_SemVer} + name: counterstrikesharp-build-linux-${{ needs.setup.outputs.gitversion_semver }} path: build/output/ build_managed: @@ -135,7 +134,7 @@ jobs: # We don't need expensive submodules for the managed side. - uses: actions/checkout@v4 - - name: Build runtime v${{ env.GitVersion_SemVer }} + - name: Build runtime v${{ needs.setup.outputs.gitversion_semver }} uses: actions/setup-dotnet@v4 with: dotnet-version: "8.0.x" @@ -144,30 +143,30 @@ jobs: run: dotnet restore managed/CounterStrikeSharp.sln - name: Run tests - run: dotnet test --logger trx --results-directory "TestResults-${env:GitVersion_SemVer}" managed/CounterStrikeSharp.API.Tests/CounterStrikeSharp.API.Tests.csproj + run: dotnet test --logger trx --results-directory "TestResults-${{ needs.setup.outputs.gitversion_semver }}" managed/CounterStrikeSharp.API.Tests/CounterStrikeSharp.API.Tests.csproj - name: Upload dotnet test results uses: actions/upload-artifact@v4 with: - name: test-results-${env:GitVersion_SemVer} - path: TestResults-${env:GitVersion_SemVer} + name: test-results-${{ needs.setup.outputs.gitversion_semver }} + path: TestResults-${{ needs.setup.outputs.gitversion_semver }} if: ${{ always() }} - name: Publish artifacts run: | dotnet publish -c Release - /p:Version=${GitVersion_FullSemVer} - /p:AssemblyVersion=${GitVersion_AssemblySemVer} - /p:InformationalVersion=${GitVersion_InformationalVersion} + /p:Version=${{ needs.setup.outputs.gitversion_semver }} + /p:AssemblyVersion=${{ needs.setup.outputs.gitversion_assemblySemver }} + /p:InformationalVersion=${{ needs.setup.outputs.gitversion_informationalversion }} managed/CounterStrikeSharp.API dotnet pack -c Release - /p:Version=${GitVersion_FullSemVer} - /p:AssemblyVersion=${GitVersion_AssemblySemVer} - /p:InformationalVersion=${GitVersion_InformationalVersion} + /p:Version=${{ needs.setup.outputs.gitversion_semver }} + /p:AssemblyVersion=${{ needs.setup.outputs.gitversion_assemblySemver }} + /p:InformationalVersion=${{ needs.setup.outputs.gitversion_informationalversion }} managed/CounterStrikeSharp.API - uses: actions/upload-artifact@v4 with: - name: counterstrikesharp-build-api-${env:GitVersion_SemVer} + name: counterstrikesharp-build-api-${{ needs.setup.outputs.gitversion_semver }} path: managed/CounterStrikeSharp.API/bin/Release \ No newline at end of file From a5cbba2c7dc71f7590c2bb635249f5ea8b522c6a Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:37:41 +1000 Subject: [PATCH 10/14] fix: backslashes --- .github/workflows/ci.yaml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bf6efb8ca..0841d465a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.sha }} cancel-in-progress: true - jobs: setup: runs-on: ubuntu-latest @@ -154,16 +153,16 @@ jobs: - name: Publish artifacts run: | - dotnet publish -c Release - /p:Version=${{ needs.setup.outputs.gitversion_semver }} - /p:AssemblyVersion=${{ needs.setup.outputs.gitversion_assemblySemver }} - /p:InformationalVersion=${{ needs.setup.outputs.gitversion_informationalversion }} + dotnet publish -c Release \ + /p:Version=${{ needs.setup.outputs.gitversion_semver }} \ + /p:AssemblyVersion=${{ needs.setup.outputs.gitversion_assemblySemver }} \ + /p:InformationalVersion=${{ needs.setup.outputs.gitversion_informationalversion }} \ managed/CounterStrikeSharp.API - dotnet pack -c Release - /p:Version=${{ needs.setup.outputs.gitversion_semver }} - /p:AssemblyVersion=${{ needs.setup.outputs.gitversion_assemblySemver }} - /p:InformationalVersion=${{ needs.setup.outputs.gitversion_informationalversion }} + dotnet pack -c Release \ + /p:Version=${{ needs.setup.outputs.gitversion_semver }} \ + /p:AssemblyVersion=${{ needs.setup.outputs.gitversion_assemblySemver }} \ + /p:InformationalVersion=${{ needs.setup.outputs.gitversion_informationalversion }} \ managed/CounterStrikeSharp.API - uses: actions/upload-artifact@v4 From bd82ec39d13c07e0da36ac01159ba113ccab30f7 Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 16:48:07 +1000 Subject: [PATCH 11/14] feat: add semver to cmake --- .github/workflows/ci.yaml | 8 ++++++-- makefiles/shared.cmake | 6 +++--- src/mm_plugin.cpp | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0841d465a..f8321fb04 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,7 +50,9 @@ jobs: steps: - name: Prepare env shell: bash - run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + run: | + echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + echo "SEMVER=${{ needs.setup.outputs.gitversion_semver }}" >> $GITHUB_ENV - name: Visual Studio environment shell: cmd @@ -97,7 +99,9 @@ jobs: steps: - name: Prepare env shell: bash - run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + run: | + echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + echo "SEMVER=${{ needs.setup.outputs.gitversion_semver }}" >> $GITHUB_ENV - uses: actions/checkout@v4 with: diff --git a/makefiles/shared.cmake b/makefiles/shared.cmake index abb26c72c..9f873b727 100644 --- a/makefiles/shared.cmake +++ b/makefiles/shared.cmake @@ -35,10 +35,10 @@ else() add_definitions(-DGITHUB_SHA="Local") endif() -if(DEFINED ENV{BUILD_NUMBER}) - add_definitions(-DBUILD_NUMBER="$ENV{BUILD_NUMBER}") +if(DEFINED ENV{SEMVER}) + add_definitions(-DSEMVER="$ENV{SEMVER}") else() - add_definitions(-DBUILD_NUMBER="0") + add_definitions(-DSEMVER="Local") endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/src/mm_plugin.cpp b/src/mm_plugin.cpp index 88c126340..965e9ff44 100644 --- a/src/mm_plugin.cpp +++ b/src/mm_plugin.cpp @@ -34,7 +34,7 @@ #include "scripting/script_engine.h" #include "tier0/vprof.h" -#define VERSION_STRING "v" BUILD_NUMBER " @ " GITHUB_SHA +#define VERSION_STRING "v" SEMVER " @ " GITHUB_SHA #define BUILD_TIMESTAMP __DATE__ " " __TIME__ counterstrikesharp::GlobalClass* counterstrikesharp::GlobalClass::head = nullptr; From 128ac5fefdc0c65ab63c57adc3271381c4d222b1 Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 17:06:19 +1000 Subject: [PATCH 12/14] chore: dry-run publish --- .github/workflows/ci.yaml | 93 ++++++++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f8321fb04..ac48e9a4a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,12 +8,6 @@ env: permissions: {} on: - push: - paths-ignore: - - "docfx/**" - branches: ["main", "dev"] - pull_request: - branches: ["main", "dev"] workflow_dispatch: concurrency: @@ -87,7 +81,7 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: counterstrikesharp-build-windows-${{ needs.setup.outputs.gitversion_semver }} + name: counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }} path: build/output/ build_linux: @@ -121,7 +115,7 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: counterstrikesharp-build-linux-${{ needs.setup.outputs.gitversion_semver }} + name: counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }} path: build/output/ build_managed: @@ -171,5 +165,84 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: counterstrikesharp-build-api-${{ needs.setup.outputs.gitversion_semver }} - path: managed/CounterStrikeSharp.API/bin/Release \ No newline at end of file + name: counterstrikesharp-api-${{ needs.setup.outputs.gitversion_semver }} + path: managed/CounterStrikeSharp.API/bin/Release + + publish: + # if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + # permissions: + # contents: write + needs: ["setup", "build_linux", "build_windows", "build_managed"] + runs-on: ubuntu-latest + steps: + - name: Prepare env + shell: bash + run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + + - uses: actions/download-artifact@v4 + with: + name: counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }} + path: build/windows + + - uses: actions/download-artifact@v4 + with: + name: counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }} + path: build/linux + + - uses: actions/download-artifact@v4 + with: + name: counterstrikesharp-api-${{ needs.setup.outputs.gitversion_semver }} + path: build/api + + # TODO: This stuff should really be in a matrix + - name: Add API to Artifacts + run: | + mkdir -p build/linux/addons/counterstrikesharp/api + mkdir -p build/windows/addons/counterstrikesharp/api + cp -r build/api/net8.0/publish/* build/linux/addons/counterstrikesharp/api + cp -r build/api/net8.0/publish/* build/windows/addons/counterstrikesharp/api + + - name: Zip Builds + run: | + (cd build/linux && zip -qq -r ../../counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }}.zip *) + (cd build/windows && zip -qq -r ../../counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }}.zip *) + + - name: Add dotnet runtime + run: | + mkdir -p build/linux/addons/counterstrikesharp/dotnet + curl -s -L https://download.visualstudio.microsoft.com/download/pr/c1371dc2-eed2-47be-9af3-ae060dbe3c7d/bd509e0a87629764ed47608466d183e6/aspnetcore-runtime-8.0.3-linux-x64.tar.gz \ + | tar xvz -C build/linux/addons/counterstrikesharp/dotnet + + mkdir -p build/windows/addons/counterstrikesharp/dotnet + curl -s -L https://download.visualstudio.microsoft.com/download/pr/086d1dd6-57a5-437a-a1ef-549cf702fb48/dd4a8fe6c53a1016a414d6f2925c1323/aspnetcore-runtime-8.0.3-win-x64.zip -o dotnet.zip + unzip -qq dotnet.zip -d build/windows/addons/counterstrikesharp/dotnet + + - name: Zip Builds + run: | + (cd build/linux && zip -qq -r ../../counterstrikesharp-with-runtime-linux-${{ needs.setup.outputs.gitversion_semver }}.zip *) + (cd build/windows && zip -qq -r ../../counterstrikesharp-with-runtime-windows-${{ needs.setup.outputs.gitversion_semver }}.zip *) + + # - name: Release + # id: release + # uses: softprops/action-gh-release@v1 + # with: + # tag_name: v${{ needs.setup.outputs.gitversion_semver }} + # files: | + # counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }}.zip + # counterstrikesharp-with-runtime-windows-${{ needs.setup.outputs.gitversion_semver }}.zip + # counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }}.zip + # counterstrikesharp-with-runtime-linux-${{ needs.setup.outputs.gitversion_semver }}.zip + + - name: Publish NuGet package + run: | + echo "dry run publish" + echo "${{ needs.setup.outputs.gitversion_semver }}" + # dotnet nuget push build/api/CounterStrikeSharp.API.${{ needs.setup.outputs.gitversion_semver }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + # dotnet nuget push build/api/CounterStrikeSharp.API.${{ needs.setup.outputs.gitversion_semver }}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + + # - name: Send Notification to Discord + # env: + # DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + # uses: Ilshidur/action-discord@0.3.2 + # with: + # args: "A new release of CS# has been tagged (v${{ needs.setup.outputs.buildnumber }}) at ${{ steps.release.outputs.url }}" From f62fe613cda021c673b3e0d0b5b795fd6c6403d4 Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 17:16:53 +1000 Subject: [PATCH 13/14] fix: add back PR runs --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ac48e9a4a..7daefcba8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,6 +8,8 @@ env: permissions: {} on: + pull_request: + branches: ["main", "dev"] workflow_dispatch: concurrency: From 2765ad645110dd58c649536274f0b30017df6282 Mon Sep 17 00:00:00 2001 From: roflmuffin Date: Mon, 24 Mar 2025 17:30:44 +1000 Subject: [PATCH 14/14] feat: overwrite old cmake-single-platform --- .../{ci.yaml => build-and-publish.yml} | 49 ++-- .github/workflows/cmake-single-platform.yml | 248 ------------------ 2 files changed, 25 insertions(+), 272 deletions(-) rename .github/workflows/{ci.yaml => build-and-publish.yml} (85%) delete mode 100644 .github/workflows/cmake-single-platform.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/build-and-publish.yml similarity index 85% rename from .github/workflows/ci.yaml rename to .github/workflows/build-and-publish.yml index 7daefcba8..4919ee3c9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/build-and-publish.yml @@ -1,4 +1,4 @@ -name: CI +name: Build & Publish env: BUILD_TYPE: Release @@ -8,13 +8,14 @@ env: permissions: {} on: + push: + paths-ignore: + - "docfx/**" + branches: ["main"] + tags: + - "v*" pull_request: - branches: ["main", "dev"] - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.number || github.sha }} - cancel-in-progress: true + branches: ["main"] jobs: setup: @@ -171,9 +172,9 @@ jobs: path: managed/CounterStrikeSharp.API/bin/Release publish: - # if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - # permissions: - # contents: write + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'roflmuffin/CounterStrikeSharp' }} + permissions: + contents: write needs: ["setup", "build_linux", "build_windows", "build_managed"] runs-on: ubuntu-latest steps: @@ -224,23 +225,23 @@ jobs: (cd build/linux && zip -qq -r ../../counterstrikesharp-with-runtime-linux-${{ needs.setup.outputs.gitversion_semver }}.zip *) (cd build/windows && zip -qq -r ../../counterstrikesharp-with-runtime-windows-${{ needs.setup.outputs.gitversion_semver }}.zip *) - # - name: Release - # id: release - # uses: softprops/action-gh-release@v1 - # with: - # tag_name: v${{ needs.setup.outputs.gitversion_semver }} - # files: | - # counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }}.zip - # counterstrikesharp-with-runtime-windows-${{ needs.setup.outputs.gitversion_semver }}.zip - # counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }}.zip - # counterstrikesharp-with-runtime-linux-${{ needs.setup.outputs.gitversion_semver }}.zip + - name: Release + id: release + uses: softprops/action-gh-release@v1 + with: + append_body: true + body: | + Please refer to [CHANGELOG.md](https://github.com/roflmuffin/CounterStrikeSharp/blob/${{ github.ref_name }}/CHANGELOG.md) for details. + files: | + counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }}.zip + counterstrikesharp-with-runtime-windows-${{ needs.setup.outputs.gitversion_semver }}.zip + counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }}.zip + counterstrikesharp-with-runtime-linux-${{ needs.setup.outputs.gitversion_semver }}.zip - name: Publish NuGet package run: | - echo "dry run publish" - echo "${{ needs.setup.outputs.gitversion_semver }}" - # dotnet nuget push build/api/CounterStrikeSharp.API.${{ needs.setup.outputs.gitversion_semver }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate - # dotnet nuget push build/api/CounterStrikeSharp.API.${{ needs.setup.outputs.gitversion_semver }}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + dotnet nuget push build/api/CounterStrikeSharp.API.${{ needs.setup.outputs.gitversion_semver }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + dotnet nuget push build/api/CounterStrikeSharp.API.${{ needs.setup.outputs.gitversion_semver }}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate # - name: Send Notification to Discord # env: diff --git a/.github/workflows/cmake-single-platform.yml b/.github/workflows/cmake-single-platform.yml deleted file mode 100644 index 5c75fb4b2..000000000 --- a/.github/workflows/cmake-single-platform.yml +++ /dev/null @@ -1,248 +0,0 @@ -name: Build & Publish - -on: - push: - paths-ignore: - - "docfx/**" - branches: ["main", "dev"] - pull_request: - branches: ["main", "dev"] - -env: - BUILD_TYPE: Release - -jobs: - setup: - permissions: - contents: write - runs-on: ubuntu-latest - outputs: - buildnumber: ${{ steps.buildnumber.outputs.build_number }} - steps: - - name: Generate build number - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - id: buildnumber - uses: onyxmueller/build-tag-number@v1 - with: - token: ${{secrets.github_token}} - - build_windows: - needs: setup - runs-on: windows-latest - steps: - - name: Prepare env - shell: bash - run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV - - - name: Fallback build number - if: ${{ github.event_name == 'pull_request' || github.ref != 'refs/heads/main' }} - shell: bash - run: echo "BUILD_NUMBER=0" >> $GITHUB_ENV - - - name: Main build number - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: echo "BUILD_NUMBER=${{ needs.setup.outputs.buildnumber }}" >> $GITHUB_ENV - - - name: Visual Studio environment - shell: cmd - run: | - :: See https://github.com/microsoft/vswhere/wiki/Find-VC - for /f "usebackq delims=*" %%i in (`vswhere -latest -property installationPath`) do ( - call "%%i"\Common7\Tools\vsdevcmd.bat -arch=x64 -host_arch=x64 - ) - - :: Loop over all environment variables and make them global. - for /f "delims== tokens=1,2" %%a in ('set') do ( - echo>>"%GITHUB_ENV%" %%a=%%b - ) - - - uses: actions/checkout@v3 - with: - submodules: "recursive" - - - name: Build - run: | - mkdir -p build - cd build - cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} .. - cmake --build . --config ${{env.BUILD_TYPE}} -- /m:16 - - - name: Clean build directory - run: | - mkdir -p build/addons/counterstrikesharp/bin/win64 - mv build/${{env.BUILD_TYPE}}/*.dll build/addons/counterstrikesharp/bin/win64 - mkdir build/output/ - mv build/addons build/output - - - uses: actions/upload-artifact@v4 - with: - name: counterstrikesharp-build-windows-${{ env.GITHUB_SHA_SHORT }} - path: build/output/ - - build_linux: - needs: setup - runs-on: ubuntu-latest - # Could not figure out how to run in a container only on some matrix paths, so I've split it out into its own build. - container: - image: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest - steps: - - name: Prepare env - shell: bash - run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV - - - name: Fallback build number - if: ${{ github.event_name == 'pull_request' || github.ref != 'refs/heads/main' }} - shell: bash - run: echo "BUILD_NUMBER=0" >> $GITHUB_ENV - - - name: Main build number - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: echo "BUILD_NUMBER=${{ needs.setup.outputs.buildnumber }}" >> $GITHUB_ENV - - - uses: actions/checkout@v3 - with: - submodules: "recursive" - - - name: Build - run: | - mkdir -p build - cd build - cmake -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} .. - cmake --build . --config ${{env.BUILD_TYPE}} -- -j16 - - - name: Clean build directory - run: | - mkdir build/output/ - mv build/addons build/output - - - uses: actions/upload-artifact@v4 - with: - name: counterstrikesharp-build-linux-${{ env.GITHUB_SHA_SHORT }} - path: build/output/ - - build_managed: - needs: setup - permissions: - contents: write - runs-on: ubuntu-latest - steps: - - name: Prepare env - shell: bash - run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV - - - name: Fallback build number - if: ${{ github.event_name == 'pull_request' || github.ref != 'refs/heads/main' }} - shell: bash - run: echo "BUILD_NUMBER=0" >> $GITHUB_ENV - - - name: Main build number - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: echo "BUILD_NUMBER=${{ needs.setup.outputs.buildnumber }}" >> $GITHUB_ENV - - # We don't need expensive submodules for the managed side. - - uses: actions/checkout@v3 - - - name: Build runtime v${{ env.BUILD_NUMBER }} - uses: actions/setup-dotnet@v3 - with: - dotnet-version: "8.0.x" - - - name: Install dependencies - run: dotnet restore managed/CounterStrikeSharp.sln - - - name: Run tests - run: dotnet test --logger trx --results-directory "TestResults-${{ env.GITHUB_SHA_SHORT }}" managed/CounterStrikeSharp.API.Tests/CounterStrikeSharp.API.Tests.csproj - - - name: Upload dotnet test results - uses: actions/upload-artifact@v4 - with: - name: test-results-${{ env.GITHUB_SHA_SHORT }} - path: TestResults-${{ env.GITHUB_SHA_SHORT }} - if: ${{ always() }} - - - name: Publish artifacts - run: | - dotnet publish -c Release /p:Version=1.0.${{ env.BUILD_NUMBER }} managed/CounterStrikeSharp.API - dotnet pack -c Release /p:Version=1.0.${{ env.BUILD_NUMBER }} managed/CounterStrikeSharp.API - - - uses: actions/upload-artifact@v4 - with: - name: counterstrikesharp-build-api-${{ env.GITHUB_SHA_SHORT }} - path: managed/CounterStrikeSharp.API/bin/Release - - publish: - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - permissions: - contents: write - needs: ["setup", "build_linux", "build_windows", "build_managed"] - runs-on: ubuntu-latest - steps: - - name: Prepare env - shell: bash - run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV - - - uses: actions/download-artifact@v4 - with: - name: counterstrikesharp-build-windows-${{ env.GITHUB_SHA_SHORT }} - path: build/windows - - - uses: actions/download-artifact@v4 - with: - name: counterstrikesharp-build-linux-${{ env.GITHUB_SHA_SHORT }} - path: build/linux - - - uses: actions/download-artifact@v4 - with: - name: counterstrikesharp-build-api-${{ env.GITHUB_SHA_SHORT }} - path: build/api - - # TODO: This stuff should really be in a matrix - - name: Add API to Artifacts - run: | - mkdir -p build/linux/addons/counterstrikesharp/api - mkdir -p build/windows/addons/counterstrikesharp/api - cp -r build/api/net8.0/publish/* build/linux/addons/counterstrikesharp/api - cp -r build/api/net8.0/publish/* build/windows/addons/counterstrikesharp/api - - - name: Zip Builds - run: | - (cd build/linux && zip -qq -r ../../counterstrikesharp-build-${{ needs.setup.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip *) - (cd build/windows && zip -qq -r ../../counterstrikesharp-build-${{ needs.setup.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip *) - - - name: Add dotnet runtime - run: | - mkdir -p build/linux/addons/counterstrikesharp/dotnet - curl -s -L https://download.visualstudio.microsoft.com/download/pr/c1371dc2-eed2-47be-9af3-ae060dbe3c7d/bd509e0a87629764ed47608466d183e6/aspnetcore-runtime-8.0.3-linux-x64.tar.gz \ - | tar xvz -C build/linux/addons/counterstrikesharp/dotnet - - mkdir -p build/windows/addons/counterstrikesharp/dotnet - curl -s -L https://download.visualstudio.microsoft.com/download/pr/086d1dd6-57a5-437a-a1ef-549cf702fb48/dd4a8fe6c53a1016a414d6f2925c1323/aspnetcore-runtime-8.0.3-win-x64.zip -o dotnet.zip - unzip -qq dotnet.zip -d build/windows/addons/counterstrikesharp/dotnet - - - name: Zip Builds - run: | - (cd build/linux && zip -qq -r ../../counterstrikesharp-with-runtime-build-${{ needs.setup.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip *) - (cd build/windows && zip -qq -r ../../counterstrikesharp-with-runtime-build-${{ needs.setup.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip *) - - - name: Release - id: release - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ needs.setup.outputs.buildnumber }} - files: | - counterstrikesharp-build-${{ needs.setup.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip - counterstrikesharp-with-runtime-build-${{ needs.setup.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip - counterstrikesharp-build-${{ needs.setup.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip - counterstrikesharp-with-runtime-build-${{ needs.setup.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip - - - name: Publish NuGet package - run: | - dotnet nuget push build/api/CounterStrikeSharp.API.1.0.${{ needs.setup.outputs.buildnumber }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate - dotnet nuget push build/api/CounterStrikeSharp.API.1.0.${{ needs.setup.outputs.buildnumber }}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate - - - name: Send Notification to Discord - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - uses: Ilshidur/action-discord@0.3.2 - with: - args: "A new release of CS# has been tagged (v${{ needs.setup.outputs.buildnumber }}) at ${{ steps.release.outputs.url }}"