-
-
Notifications
You must be signed in to change notification settings - Fork 3
125 lines (103 loc) · 3.92 KB
/
Copy pathbuild-module-base.yml
File metadata and controls
125 lines (103 loc) · 3.92 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
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
types: [opened, reopened, synchronize]
workflow_call:
workflow_dispatch:
name: build-module-base
env:
DOTNET_VERSION: 10.0.x
REGISTRY: ghcr.io
jobs:
check-host-deps:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check host dependency list is in sync
run: bash scripts/sync-host-deps.sh
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.nuget/packages
key: module-base-nuget
restore-keys: |
module-base-nuget-
- name: Determine version
id: version
run: |
# Read base version from Directory.Build.props
BASE_VERSION=$(grep -oP '(?<=<Version>)[^<]+' Directory.Build.props)
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
# Tagged release: use tag as version
TAG="${GITHUB_REF#refs/tags/}"
echo "package_version=$TAG" >> "$GITHUB_OUTPUT"
echo "is_release=true" >> "$GITHUB_OUTPUT"
else
# Dev build: append pre-release suffix
echo "package_version=${BASE_VERSION}-dev.${GITHUB_RUN_NUMBER}" >> "$GITHUB_OUTPUT"
echo "is_release=false" >> "$GITHUB_OUTPUT"
fi
- name: Build and Pack ModuleBase
run: dotnet build ModuleBase/ModuleBase.csproj -c Release -o ./publish/ModuleBase -p:PackageVersion=${{ steps.version.outputs.package_version }}
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: OpenShock Desktop Module Base
path: ./publish/ModuleBase/**
retention-days: 1
if-no-files-found: error
publish-github:
needs: [check-host-deps, build]
if: github.event_name == 'push'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
packages: write
steps:
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: OpenShock Desktop Module Base
path: ./packages
- name: Push to GitHub Packages
run: dotnet nuget push "./packages/*.nupkg" --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
publish-nuget:
needs: [check-host-deps, build]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
id-token: write
steps:
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: OpenShock Desktop Module Base
path: ./packages
- name: Login to NuGet.org with trusted publishing
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}
- name: Push to NuGet.org
run: dotnet nuget push "./packages/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --skip-duplicate