forked from actions/runner
-
-
Notifications
You must be signed in to change notification settings - Fork 17
117 lines (112 loc) · 4.2 KB
/
build-publish.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
name: Emulator CI/CD
on:
workflow_dispatch:
inputs:
version:
# 0.0.0
type: string
changelog:
type: string
push:
branches:
- main
- releases/*
# paths-ignore:
# - '**.md'
pull_request:
run-name: ${{ github.event_name == 'workflow_dispatch' && (inputs.version && format('Publish version:{0} sha:{1}', inputs.version, github.sha) || format('Emulator CI/CD sha:{0}', github.sha)) || '' }}
jobs:
build:
strategy:
matrix:
runtime:
- linux-x64
- linux-arm
- linux-arm64
- alpine-x64
- alpine-arm
- alpine-arm64
- win-x86
- win-x64
- win-arm64
- osx-x64
- osx-arm64
fxdependent: [ true, false ]
runs-on: ${{ contains(matrix.runtime, 'osx') && 'macos-latest' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- run: dotnet msbuild src/dir.proj -t:GenerateConstant -p:RunnerVersion=${{ inputs.version || '3.0.0' }} -p:PackageRuntime=${{ !matrix.fxdependent && matrix.runtime || 'Any' }}
- run: dotnet publish src/Runner.Client ${{ matrix.fxdependent && '--no-self-contained -p:RuntimeFrameworkVersion=6.0.0' || '--sc' }} -c Release -p:BUILD_OS=${{ matrix.fxdependent && 'Any' || startsWith(matrix.runtime, 'win-') && 'Windows' || startsWith(matrix.runtime, 'osx-') && 'OSX' || 'Linux' }} -r ${{ matrix.runtime }} -p:Version=${{ inputs.version || '3.0.0' }} -o output
- name: Package tar
if: ${{ !startsWith(matrix.runtime, 'win-') }}
run: |
tar czf ../runner.server-${{matrix.runtime}}${{ matrix.fxdependent && '-fxdependent' || '' }}.tar.gz ./*
working-directory: output
- name: Package zip
if: ${{ startsWith(matrix.runtime, 'win-') }}
run: |
zip -r ../runner.server-${{matrix.runtime}}${{ matrix.fxdependent && '-fxdependent' || '' }}.zip ./*
working-directory: output
- uses: actions/upload-artifact@v3
with:
name: runner.server-${{matrix.runtime}}${{ matrix.fxdependent && '-fxdependent' || '' }}
path: 'runner.server-${{matrix.runtime}}*'
publish-to-github:
if: inputs.version
runs-on: ubuntu-latest
needs: build
continue-on-error: true
steps:
- uses: actions/download-artifact@v3
with:
path: "artifacts"
- uses: ncipollo/release-action@v1
with:
artifacts: "artifacts/**/*.zip,artifacts/**/*.tar.gz"
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ inputs.version }}
commit: ${{ github.sha }}
body: |
# Changes
${{ fromjson(inputs.changelog) }}
publish:
if: inputs.version
needs: publish-to-github
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: GenerateConstant
run: dotnet msbuild ./dir.proj -t:GenerateConstant -p:RunnerVersion=${{ inputs.version }} -p:PackageRuntime=any
shell: pwsh
working-directory: ./src
- name: Restore
run: dotnet restore -p:RuntimeFrameworkVersion=6.0.0
shell: pwsh
working-directory: ./src/Runner.Client
- name: Build
run: dotnet build --no-restore -c Release -p:BUILD_OS=Any -p:Version=${{ inputs.version }} -p:RuntimeFrameworkVersion=6.0.0
shell: pwsh
working-directory: ./src/Runner.Client
- name: Pack
run: |
dotnet pack --no-restore -c Release --no-build -p:Version=${{ inputs.version }} -p:RuntimeFrameworkVersion=6.0.0 -p:CHANGELOG_URL=https://github.com/ChristopherHX/runner.server/releases/tag/v${{ inputs.version }}
shell: pwsh
working-directory: ./src/Runner.Client
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: nupkg
path: src/Runner.Client/nupkg
- name: Push to Nuget
if: env.GHARUN != ''
run: dotnet nuget push ./*.nupkg --api-key $($ENV:GHARUN) --source https://api.nuget.org/v3/index.json
shell: pwsh
working-directory: ./src/Runner.Client/nupkg
env:
GHARUN: ${{secrets.GHARUN}}