forked from MonkeyModdingTroop/MonkeyLoader.ModTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (111 loc) · 4.3 KB
/
build.yml
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
135
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build
# Trigger the action on push to master
on:
workflow_call: {} # Allow reusing this workflow
push:
branches:
- master # Run for pushes to master
pull_request:
branches:
- '*' # Run the workflow for all pull requests
# Sets permissions of the GITHUB_TOKEN to allow reading packages
permissions:
packages: read
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NuGetDirectory: ${{ github.workspace}}/nuget
defaults:
run:
shell: pwsh
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "ci"
cancel-in-progress: false
jobs:
Generate-Packages:
uses: ResoniteModdingGroup/ReferencePackages/.github/workflows/generator.yml@main
secrets: inherit
Build:
runs-on: ubuntu-latest
needs: [ Generate-Packages ]
steps:
# Setup environment
- name: Checkout
uses: actions/checkout@v4
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
source-url: https://nuget.pkg.github.com/ResoniteModdingGroup/index.json
- name: Add MonkeyLoader NuGet Source
run: dotnet nuget add source https://pkg.munally.com/MonkeyModdingTroop/index.json
- name: Restore NuGet Package Cache
uses: actions/cache/restore@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
# Build and test projects
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-restore --no-build
- name: Move NuGet Packages
run: mv (Get-ChildItem -Recurse ./ -Include *.nupkg) ./
# Removes the version number from the package name
- name: Rename NuGet Packages
run: Get-ChildItem -Include *.nupkg -Path ./* | Rename-Item -NewName { $_.Name -Replace '\.\d+\.\d+\.\d+.*$','.nupkg' }
# Publish the NuGet package(s) as an artifact, so they can be used in the following jobs
- name: Upload NuGet Packages Artifact
uses: actions/upload-artifact@v4
with:
name: NuGet Packages
if-no-files-found: error
retention-days: 7
path: ./*.nupkg
# Only when it's not from a PR to avoid any funny packages in the cache
- name: Save NuGet Package Cache
if: ${{ github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
Validate-NuGet:
runs-on: ubuntu-latest
needs: [ Build ]
steps:
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
source-url: https://nuget.pkg.github.com/ResoniteModdingGroup/index.json
- name: Add MonkeyLoader NuGet Source
run: dotnet nuget add source https://pkg.munally.com/MonkeyModdingTroop/index.json
- name: Restore NuGet Package Cache
uses: actions/cache/restore@v4
with:
save-always: true
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install NuGet Validator
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
- name: Download NuGet Packages Artifact
uses: actions/download-artifact@v4
with:
name: NuGet Packages
path: ${{ env.NuGetDirectory }}
# Validate metadata and content of the NuGet package
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
# If some rules are not applicable, you can disable them
# using the --excluded-rules or --excluded-rule-ids option
- name: Validate Package(s)
run: meziantou.validate-nuget-package (Get-ChildItem -Recurse "${{ env.NuGetDirectory }}" -Include *.nupkg) --excluded-rules IconMustBeSet