feat: implement playtime restriction feature #196
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: .NET CI/CD | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - "**" | |
| tags: | |
| - 'v*' | |
| release: | |
| types: [created] | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| if: startsWith(github.ref, 'refs/tags/') == false && contains(github.event.head_commit.message, '[no ci]') == false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Install dependencies | |
| run: nuget restore | |
| - name: Build | |
| run: dotnet build -c Release -p:DebugType=None -p:DebugSymbols=false | |
| - name: Create development artifacts | |
| run: | | |
| mkdir artifacts | |
| mkdir artifacts\shared\MapChooserSharp.API\ | |
| mkdir artifacts\plugins\MapChooserSharp\ | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\MapChooserSharp.dll" -Destination "artifacts\plugins\MapChooserSharp\MapChooserSharp.dll" -Force | |
| Copy-Item -Path "MapChooserSharp.API\bin\Release\*\MapChooserSharp.API.dll" -Destination "artifacts\shared\MapChooserSharp.API\MapChooserSharp.API.dll" -Force | |
| Copy-Item -Path "lang\" -Destination "artifacts\plugins\MapChooserSharp\" -Recurse -Force | |
| - name: Compress artifacts | |
| run: | | |
| Compress-Archive -Path artifacts/* -Destination MapChooserSharp-Development.zip | |
| - name: Upload development assets | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: MapChooserSharp-Development | |
| path: | | |
| MapChooserSharp-Development.zip | |
| publish: | |
| runs-on: windows-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Install dependencies | |
| run: nuget restore | |
| - name: Build | |
| run: dotnet publish -c Release -p:DebugType=None -p:DebugSymbols=false | |
| - name: Create release artifacts | |
| run: | | |
| mkdir artifacts | |
| mkdir artifacts\shared\MapChooserSharp.API\ | |
| mkdir artifacts\plugins\MapChooserSharp\ | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\MapChooserSharp.dll" -Destination "artifacts\plugins\MapChooserSharp\MapChooserSharp.dll" -Force | |
| Copy-Item -Path "MapChooserSharp.API\bin\Release\*\MapChooserSharp.API.dll" -Destination "artifacts\shared\MapChooserSharp.API\MapChooserSharp.API.dll" -Force | |
| Copy-Item -Path "lang\" -Destination "artifacts\plugins\MapChooserSharp\" -Recurse -Force | |
| - name: Copy and create linux x64 artifact | |
| run: | | |
| mkdir artifacts-linux-x64\ | |
| Copy-Item -Path "artifacts\*" -Destination "artifacts-linux-x64\" -Force -Recurse | |
| - name: Copy and create artifacts with dependencies | |
| run: | | |
| mkdir artifacts-linux-x64-with-dependencies\ | |
| mkdir artifacts-windows-x64-with-dependencies\ | |
| Copy-Item -Path "artifacts-linux-x64\*" -Destination "artifacts-linux-x64-with-dependencies\" -Force -Recurse | |
| Copy-Item -Path "artifacts\*" -Destination "artifacts-windows-x64-with-dependencies\" -Force -Recurse | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\Dapper.dll" -Destination "artifacts-windows-x64-with-dependencies\plugins\MapChooserSharp\Dapper.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\Dapper.dll" -Destination "artifacts-linux-x64-with-dependencies\plugins\MapChooserSharp\Dapper.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\System.Data.SQLite.dll" -Destination "artifacts-windows-x64-with-dependencies\plugins\MapChooserSharp\System.Data.SQLite.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\System.Data.SQLite.dll" -Destination "artifacts-linux-x64-with-dependencies\plugins\MapChooserSharp\System.Data.SQLite.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\MySqlConnector.dll" -Destination "artifacts-windows-x64-with-dependencies\plugins\MapChooserSharp\MySqlConnector.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\MySqlConnector.dll" -Destination "artifacts-linux-x64-with-dependencies\plugins\MapChooserSharp\MySqlConnector.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\Npgsql.dll" -Destination "artifacts-windows-x64-with-dependencies\plugins\MapChooserSharp\Npgsql.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\Npgsql.dll" -Destination "artifacts-linux-x64-with-dependencies\plugins\MapChooserSharp\Npgsql.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\ZLinq.dll" -Destination "artifacts-windows-x64-with-dependencies\plugins\MapChooserSharp\ZLinq.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\ZLinq.dll" -Destination "artifacts-linux-x64-with-dependencies\plugins\MapChooserSharp\ZLinq.dll" -Force | |
| - name: Copy runtime artifacts | |
| run: | | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\runtimes\win-x64\native\SQLite.Interop.dll" -Destination "artifacts-windows-x64-with-dependencies\plugins\MapChooserSharp\SQLite.Interop.dll" -Force | |
| Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\runtimes\linux-x64\native\SQLite.Interop.dll" -Destination "artifacts-linux-x64-with-dependencies\plugins\MapChooserSharp\SQLite.Interop.dll" -Force | |
| - name: TNCSSPluginFoundation Download from GitHub | |
| run: Invoke-WebRequest https://github.com/fltuna/TNCSSPluginFoundation/releases/latest/download/TNCSSPluginFoundation.zip -OutFile TNCSSPluginFoundation.zip | |
| - name: TNCSSPluginFoundation Extract ZIP and put into artifacts | |
| run: Expand-Archive -Path TNCSSPluginFoundation.zip -DestinationPath TNCSSPluginFoundation-Extracted\ | |
| - name: Copy TNCSSPluginFoundation to with dependencies artifacts | |
| run: | | |
| Copy-Item -Path "TNCSSPluginFoundation-Extracted\*" -Destination "artifacts-windows-x64-with-dependencies\" -Force -Recurse | |
| Copy-Item -Path "TNCSSPluginFoundation-Extracted\*" -Destination "artifacts-linux-x64-with-dependencies\" -Force -Recurse | |
| - name: NativeVoteAPI Download from GitHub | |
| run: Invoke-WebRequest https://github.com/fltuna/NativeVoteAPI-CS2/releases/latest/download/NativeVoteAPI.zip -OutFile NativeVoteAPI.zip | |
| - name: NativeVoteAPI Extract ZIP and put into artifacts | |
| run: Expand-Archive -Path NativeVoteAPI.zip -DestinationPath NativeVoteAPI-Extracted\ | |
| - name: Copy NativeVoteAPI to with dependencies artifacts | |
| run: | | |
| Copy-Item -Path "NativeVoteAPI-Extracted\*" -Destination "artifacts-windows-x64-with-dependencies\" -Force -Recurse | |
| Copy-Item -Path "NativeVoteAPI-Extracted\*" -Destination "artifacts-linux-x64-with-dependencies\" -Force -Recurse | |
| - name: Compress artifacts | |
| run: | | |
| Compress-Archive -Path artifacts/* -Destination MapChooserSharp-win-x64.zip | |
| Compress-Archive -Path artifacts-linux-x64/* -Destination MapChooserSharp-linux-x64.zip | |
| Compress-Archive -Path artifacts-windows-x64-with-dependencies/* -Destination MapChooserSharp-win-x64-with-dependencies.zip | |
| Compress-Archive -Path artifacts-linux-x64-with-dependencies/* -Destination MapChooserSharp-linux-x64-with-dependencies.zip | |
| - name: Upload release assets | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-artifacts | |
| path: | | |
| MapChooserSharp-win-x64.zip | |
| MapChooserSharp-linux-x64.zip | |
| MapChooserSharp-win-x64-with-dependencies.zip | |
| MapChooserSharp-linux-x64-with-dependencies.zip | |
| release: | |
| runs-on: windows-latest | |
| needs: publish | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-artifacts | |
| path: artifacts/ | |
| - name: check files | |
| run : | | |
| tree | |
| - name: Create Release and Upload Asset | |
| run: | | |
| gh release create "${{ github.ref_name }}" --title "Release ${{ github.ref_name }}" --generate-notes --draft=false artifacts/*.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-nuget: | |
| runs-on: windows-latest | |
| needs: release | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v1 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Install dependencies | |
| run: dotnet restore | |
| working-directory: MapChooserSharp.API | |
| - name: Build | |
| run: dotnet build -c Release -p:DebugType=None -p:DebugSymbols=false | |
| working-directory: MapChooserSharp.API | |
| - name: Pack | |
| run: dotnet pack --configuration Release | |
| working-directory: MapChooserSharp.API | |
| - name: Extract version | |
| id: package_version | |
| run: | | |
| $xml = [Xml] (Get-Content MapChooserSharp.API/MapChooserSharp.API.csproj) | |
| $version = $xml.Project.PropertyGroup.PackageVersion | |
| echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| shell: pwsh | |
| - name: Publish to Nuget | |
| run: | | |
| dotnet nuget push "bin/Release/MapChooserSharp.API.${{env.VERSION}}.nupkg" --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json | |
| working-directory: MapChooserSharp.API |