[CI] New build action #12
Workflow file for this run
This file contains 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: Dotnet Build | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
on: | |
push: | |
branches: ["dev"] | |
tags: ["*"] | |
paths-ignore: | |
- 'docs/**' | |
pull_request: | |
jobs: | |
build-linux: | |
name: Build and Test on Linux | |
runs-on: ubuntu-latest | |
env: | |
IsTagBuild: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Is Tag Build | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo "IsTagBuild=true" >> $GITHUB_ENV | |
- name: Restore | |
run: dotnet restore | |
- name: Build | |
run: dotnet build "Discord.Net.sln" -v minimal -c Release --no-restore /p:BuildNumber=${{ github.run_number }} /p:IsTagBuild=$(IsTagBuild) | |
- name: Unit Test | |
run: dotnet test "test/Discord.Net.Tests.Unit/Discord.Net.Tests.Unit.csproj" --no-restore --no-build -v minimal -c Release --logger trx | |
- name: Analyzer Test | |
run: dotnet test "test/Discord.Net.Analyzers.Tests/Discord.Net.Analyzers.Tests.csproj" --no-restore --no-build -v minimal -c Release --logger trx | |
build-windows: | |
name: Build, Test and Pack on Windows | |
runs-on: windows-latest | |
env: | |
ArtifactStagingDirectory: "artifacts" | |
IsTagBuild: false | |
DOTNET_INSTALL_DIR: 'C:\Program Files\dotnet' | |
steps: | |
#- name: Cache dotnet | |
# id: cache-dotnet | |
# uses: actions/cache@v4 | |
# with: | |
# path: ${{ env.DOTNET_INSTALL_DIR }} | |
# key: ${{ runner.os }}-dotnet-8 | |
# restore-keys: ${{ runner.os }}-dotnet-8 | |
- name: Setup .NET | |
# if: ${{ steps.cache-dotnet.outputs.cache-hit != 'true' }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- uses: actions/checkout@v4 | |
- name: Is Tag Build | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo "IsTagBuild=true" >> $GITHUB_ENV | |
- name: Restore | |
run: dotnet restore | |
- name: Build | |
env: | |
buildNumber: ${{ github.run_number }} | |
run: dotnet build "Discord.Net.sln" -v minimal -c Release --no-restore /p:BuildNumber=${{ env.buildNumber }} | |
- name: Unit Test | |
run: dotnet test "test/Discord.Net.Tests.Unit/Discord.Net.Tests.Unit.csproj" --no-restore --no-build -v minimal -c Release --logger trx | |
- name: Analyzer Test | |
run: dotnet test "test/Discord.Net.Analyzers.Tests/Discord.Net.Analyzers.Tests.csproj" --no-restore --no-build -v minimal -c Release --logger trx | |
- name: Pack | |
env: | |
buildNumber: ${{ github.run_number }} | |
run: | | |
dotnet pack "src\Discord.Net.Core\Discord.Net.Core.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.buildNumber }} /p:IsTagBuild=${{ env.IsTagBuild }} | |
dotnet pack "src\Discord.Net.Rest\Discord.Net.Rest.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.buildNumber }} /p:IsTagBuild=${{ env.IsTagBuild }} | |
dotnet pack "src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.buildNumber }} /p:IsTagBuild=${{ env.IsTagBuild }} | |
dotnet pack "src\Discord.Net.Commands\Discord.Net.Commands.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.buildNumber }} /p:IsTagBuild=${{ env.IsTagBuild }} | |
dotnet pack "src\Discord.Net.Webhook\Discord.Net.Webhook.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.buildNumber }} /p:IsTagBuild=${{ env.IsTagBuild }} | |
dotnet pack "src\Discord.Net.Providers.WS4Net\Discord.Net.Providers.WS4Net.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.buildNumber }} /p:IsTagBuild=${{ env.IsTagBuild }} | |
dotnet pack "src\Discord.Net.Analyzers\Discord.Net.Analyzers.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.buildNumber }} /p:IsTagBuild=${{ env.IsTagBuild }} | |
dotnet pack "src\Discord.Net.Interactions\Discord.Net.Interactions.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.buildNumber }} /p:IsTagBuild=${{ env.IsTagBuild }} | |
dotnet pack "experiment\Discord.Net.BuildOverrides\Discord.Net.BuildOverrides.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.buildNumber }} /p:IsTagBuild=${{ env.IsTagBuild }} | |
- name: Publish Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: discord-net | |
path: ${{ env.ArtifactStagingDirectory }}/* | |
deploy-windows: | |
name: Windows Deploy | |
runs-on: windows-latest | |
needs: [build-windows, build-linux] | |
#if: github.event_name != 'pull_request' | |
env: | |
IsTagBuild: false | |
ArtifactStagingDirectory: "artifacts" | |
Suffix: "" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Is Tag Build | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo "IsTagBuild=true" >> $GITHUB_ENV | |
- name: Update Suffix | |
if: env.IsTagBuild != 'true' | |
env: | |
buildNumber: ${{ github.run_number }} | |
run: echo "Suffix=${{ env.buildNumber }}" >> $GITHUB_ENV | |
- name: setup NuGet | |
uses: nuget/setup-nuget@v2 | |
with: | |
nuget-version: '6.x' | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: discord-net | |
path: ${{ env.ArtifactStagingDirectory }} | |
- name: Pack Metapackage | |
if: env.IsTagBuild != 'true' | |
run: nuget pack "src/Discord.Net/Discord.Net.nuspec" -OutputDirectory ${{ env.ArtifactStagingDirectory }} -Suffix=${{ env.Suffix }} | |
- name: Pack Metapackage | |
if: env.IsTagBuild == 'true' | |
run: nuget pack "src/Discord.Net/Discord.Net.nuspec" -OutputDirectory ${{ env.ArtifactStagingDirectory }} | |
- name: Push Nightly | |
run: nuget push ${{ env.ArtifactStagingDirectory }}/*.nupkg -Source ${{ vars.NIGHTLY_FEED }} -ApiKey ${{ secrets.NIGHTLY_FEED_API_KEY }} | |
#- name: Push Release | |
# if: env.IsTagBuild == 'true' | |
# run: nuget push ${{ env.ArtifactStagingDirectory }}/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }} |