forked from PHOENIXCONTACT/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (93 loc) · 3.07 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
name: Build
on:
workflow_call:
inputs:
dotnet_sdk_version:
required: true
type: string
SETUP_NODE:
required: false
type: boolean
default: true
NPM_PACKAGE_SOURCE:
description: 'Target in the format `//<registry-server/path>/`'
required: false
type: string
NODE_VERSION:
required: false
type: string
default: '20'
ARTIFACTS_PATH:
type: string
default: artifacts/packages/
MORYX_COMMERCIAL_BUILD:
required: false
type: boolean
default: true
secrets:
npm_auth_token:
required: false
myget_auth_token:
required: false
myget_user:
required: false
myget_pass:
required: false
outputs:
artifacts_path:
value: ${{ inputs.ARTIFACTS_PATH }}
jobs:
Build:
runs-on: ubuntu-latest
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
MORYX_COMMERCIAL_BUILD: ${{ inputs.MORYX_COMMERCIAL_BUILD }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
id: cache-nuget
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: 🔧 Setup Node version
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NODE_VERSION }}
if: ${{ inputs.SETUP_NODE == true }}
- name: 🔧 Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ inputs.dotnet_sdk_version }}
- name: 🔧 Setup nuget
uses: nuget/setup-nuget@v1
- name: 🗝️ Authenticate npm registry
run: npm config set ${{ inputs.NPM_PACKAGE_SOURCE }}:_authToken ${{ secrets.npm_auth_token }}
if: inputs.NPM_PACKAGE_SOURCE != ''
- name: "🗝️ Authenticate MyGet"
uses: moryx-industry/nuget-setapikey@v1
with:
sources-file: './myget.feeds'
api-key: ${{ secrets.myget_auth_token }}
registry-user: ${{ secrets.myget_user }}
registry-pass: ${{ secrets.myget_pass }}
- name: 🧰 Setup BuildToolkit
uses: moryx-industry/setup-buildtoolkit@update/commercial-by-default
- name: ♺ Execute nuget restore
run: nuget restore
if: steps.cache-nuget.outputs.cache-hit != 'true'
- name: Debug
run: Write-Host $env:MORYX_COMMERCIAL_BUILD
shell: pwsh - name: 🔨 Execute dotnet build
run: |
.\set-version.ps1 -RefName ${{ github.ref_name }} -IsTag ${{ github.ref_type == 'tag' && 1 || 0 }} -BuildNumber ${{ github.run_number }} -CommitHash ${{ github.sha }}
.\build.ps1 -PackageSource ${{ github.workspace }}/.nuget/packages
shell: pwsh
- name: ⬆️ Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: artifacts/build/
retention-days: 1
if-no-files-found: error