-
-
Notifications
You must be signed in to change notification settings - Fork 759
134 lines (111 loc) · 6.29 KB
/
dotnet.yml
File metadata and controls
134 lines (111 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Dotnet Build
on:
push:
branches: ["dev"]
tags: ["*"]
paths-ignore:
- 'docs/**'
pull_request:
paths-ignore:
- 'docs/**'
workflow_dispatch:
jobs:
build:
name: Build and Test
runs-on: ubuntu-22.04
env:
ArtifactStagingDirectory: "artifacts"
IsTagBuild: false
DOTNET_INSTALL_DIR: "/usr/share/dotnet"
steps:
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Is Tag Build
if: startsWith(github.ref, 'refs/tags/')
run: echo "IsTagBuild=true" >> $GITHUB_ENV
- name: Generate Beta Suffix
if: env.IsTagBuild == 'true' && contains(github.ref_name, '-')
env:
REF_NAME: ${{ github.ref_name }}
run: echo "Suffix=${REF_NAME##*-}" >> $GITHUB_ENV
- name: Generate Suffix
if: env.IsTagBuild != 'true'
run: echo "Suffix=nightly.$(date +'%Y%m%d').${{ github.run_number }}" >> $GITHUB_ENV
- name: Restore
run: dotnet restore ./Discord.Net.sln -v minimal --locked-mode
- name: Build
run: dotnet build "Discord.Net.sln" -v minimal -c Release --no-restore /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=${{ env.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: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: failure() || success()
with:
files: ./**/*.trx
- name: Pack
env:
buildNumber: $Suffix
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.Suffix }} /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.Suffix }} /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.Suffix }} /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.Suffix }} /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.Suffix }} /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.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
dotnet pack "tools\Discord.Net.Dave\Discord.Net.Dave.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.Suffix }} /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.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
- name: Publish Artifacts
uses: actions/upload-artifact@v5
with:
name: discord-net
path: ${{ env.ArtifactStagingDirectory }}/*
deploy:
name: Deploy
runs-on: ubuntu-22.04
needs: [build]
if: github.event_name != 'pull_request'
env:
IsTagBuild: false
ArtifactStagingDirectory: "artifacts"
REPOSITORY_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
steps:
- uses: actions/checkout@v5
- name: Is Tag Build
if: startsWith(github.ref, 'refs/tags/')
run: echo "IsTagBuild=true" >> $GITHUB_ENV
- name: Generate Beta Suffix
if: env.IsTagBuild == 'true' && contains(github.ref_name, '-')
env:
REF_NAME: ${{ github.ref_name }}
run: echo "Suffix=-${REF_NAME##*-}" >> $GITHUB_ENV
- name: Generate Suffix
if: env.IsTagBuild != 'true'
run: echo "Suffix=-nightly.$(date +'%Y%m%d').${{ github.run_number }}" >> $GITHUB_ENV
- name: setup NuGet
uses: nuget/setup-nuget@v2
with:
nuget-version: '6.x'
- name: Download artifacts
uses: actions/download-artifact@v6
with:
name: discord-net
path: ${{ env.ArtifactStagingDirectory }}
- name: Pack Metapackage
run: nuget pack "src/Discord.Net/Discord.Net.nuspec" -OutputDirectory ${{ env.ArtifactStagingDirectory }} -NonInteractive -p "suffix=${{ env.Suffix }}"
- name: Set API Keys
run: |
nuget setApiKey ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json
nuget setApiKey ${{ secrets.NIGHTLY_FEED_API_KEY }} -Source ${{ vars.NIGHTLY_FEED }}
nuget setApiKey ${{ secrets.GITHUB_TOKEN }} -Source ${{ env.REPOSITORY_URL }}
- name: Push Nightly
if: vars.PUSH_NIGHTLY_CUSTOM == 'true'
run: nuget push "${{ env.ArtifactStagingDirectory }}/*.nupkg" -SkipDuplicate -Source ${{ vars.NIGHTLY_FEED }}
- name: Push Nightly to GitHub Pacakges
if: vars.PUSH_NIGHTLY_GITHUB == 'true'
run: nuget push "${{ env.ArtifactStagingDirectory }}/*.nupkg" -SkipDuplicate -Source ${{ env.REPOSITORY_URL }}
- name: Push Release
if: env.IsTagBuild == 'true' && vars.PUSH_NUGET == 'true'
run: nuget push "${{ env.ArtifactStagingDirectory }}/*.nupkg" -SkipDuplicate -Source https://api.nuget.org/v3/index.json