-
-
Notifications
You must be signed in to change notification settings - Fork 324
88 lines (76 loc) · 2.92 KB
/
create-release.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
################################################################################
### Build MonoGame.Extended (Develop)
### Clones the `develop` branch and performs a build, test, then pack of the
### Monogame.Extended source code. Once the build job is finished, the deploy
### job will upload the nupkg files created to the MonoGame.Extended GitHub
###
### - Only runs on a push to the `develop` branch
################################################################################
name: "Create Release"
on:
workflow_dispatch:
inputs:
prerelease:
description: 'Is this a prerelease?'
required: true
type: boolean
default: true
source-feed:
description: 'Which source feed to publish to?'
required: true
type: choice
options:
- GitHub
- NuGet
default: 'GitHub'
jobs:
build:
name: "Build MonoGame.Extended"
runs-on: ubuntu-latest
env:
IS_PRERELEASE: ${{ inputs.prerelease || '' }}
BUILD_NUMBER: ${{ inputs.prerelease && github.run_number || '' }}
steps:
- name: Clone Repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.prerelease && 'develop' || 'main' }}
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Build MonoGame.Extended
run: dotnet build MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
- name: Test MonoGame.Extended
run: dotnet test MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
- name: Pack MonoGame.Extended
run: dotnet pack MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
- name: Pack Kni.Extended
run: dotnet pack KNI.Extended.sln --nologo --verbosity minimal --configuration Release
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: ./.artifacts/source/package/release/*.nupkg
deploy:
name: "Deploy NuGets"
runs-on: ubuntu-latest
needs: [ build ]
permissions:
packages: write
contents: write
steps:
- name: "Download Artifacts"
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./.artifacts
- name: "Push Packages"
env:
SOURCE_URL: ${{ inputs.source-feed == 'GitHub' && 'https://nuget.pkg.github.com/craftworkgames/index.json' || inputs.source-feed == 'NuGet' && 'https://api.nuget.org/v3/index.json' }}
API_KEY: ${{ inputs.source-feed == 'GitHub' && secrets.GITHUB_TOKEN || inputs.source-feed == 'NuGet' && secrets.NUGET_ACCESS_TOKEN }}
run: |
PACKAGES=(".artifacts/*.nupkg")
for PACKAGE in "${PACKAGES[@]}"; do
dotnet nuget push "$PACKAGE" --source "$SOURCE_URL" --skip-duplicate --api-key "$API_KEY"
done