-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (126 loc) · 5.03 KB
/
build-process.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
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Build Process
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
env:
CODE_LOCATION: /home/runner/work/tf-whatsup/tf-whatsup/src/
RELEASE_LOCATION: /home/runner/work/tf-whatsup/tf-whatsup/src/TFWhatsUp.Console/bin/Release/net7.0/
PUBLISH_COMMAND_FLAGS: "-c Release -p:PublishSingleFile=true -p:PublishReadyToRun=true -p:PublishReadyToRunShowWarnings=true --sc false"
PUBLISH_COMMAND_FLAGS_SC: "-c Release -p:PublishSingleFile=true -p:PublishReadyToRun=true -p:PublishReadyToRunShowWarnings=true --sc true"
jobs:
build:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.set-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
- name: Restore dependencies
run: dotnet restore
working-directory: "${{env.CODE_LOCATION}}"
- name: Restore tools
run: dotnet tool restore
working-directory: "${{env.CODE_LOCATION}}"
- name: Set Version Number
id: set-version
working-directory: "${{env.CODE_LOCATION}}"
run: |
VERSION=$(dotnet minver -t v -v e)
echo "$VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Build
working-directory: "${{env.CODE_LOCATION}}"
run: dotnet build -c Release --no-restore
- name: Test
working-directory: "${{env.CODE_LOCATION}}"
run: dotnet test -c Release --no-build --verbosity normal
- name: Pack
working-directory: "${{env.CODE_LOCATION}}/TFWhatsUp.Console"
run: dotnet pack -c Release --no-build --verbosity normal
- name: "Save Artifact: NuGet Package"
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: nuget-package
path: "${{env.CODE_LOCATION}}/TFWhatsUp.Console/nupkg/*.nupkg"
publish_artifacts:
runs-on: ubuntu-latest
strategy:
matrix:
RID: ["osx-x64", "linux-x64", "win-x64"]
fail-fast: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
- name: Publish Single-File .EXE - ${{matrix.RID}}
working-directory: "${{env.CODE_LOCATION}}"
run: dotnet publish -r ${{matrix.RID}} ${{env.PUBLISH_COMMAND_FLAGS}}
- name: ZIP Single-File .EXE - ${{matrix.RID}}
working-directory: "${{env.CODE_LOCATION}}"
run: |
mkdir ${{env.CODE_LOCATION}}output
tar cvz -C ${{env.RELEASE_LOCATION}}${{matrix.RID}}/publish -f ${{env.CODE_LOCATION}}output/tfwhatsup_${{matrix.RID}}.tar.gz .
- name: "Save Artifact: ${{matrix.RID}}"
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: tfwhatsup_${{matrix.RID}}
path: "${{env.CODE_LOCATION}}output/tfwhatsup_${{matrix.RID}}.tar.gz"
- name: Clear the publish directories
run: rm -rf ${{env.RELEASE_LOCATION}}${{matrix.RID}}/publish
- name: Publish Self-Contained .EXEs - ${{matrix.RID}}_selfcontained
working-directory: "${{env.CODE_LOCATION}}"
run: dotnet publish -r ${{matrix.RID}} ${{env.PUBLISH_COMMAND_FLAGS_SC}}
- name: ZIP Single-File .EXE - ${{matrix.RID}}_selfcontained
working-directory: "${{env.CODE_LOCATION}}"
run: |
tar cvz -C ${{env.RELEASE_LOCATION}}${{matrix.RID}}/publish -f ${{env.CODE_LOCATION}}output/tfwhatsup_${{matrix.RID}}_sefcontained.tar.gz .
- name: "Save Artifact: ${{matrix.RID}}_selfcontained"
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: tfwhatsup_${{matrix.RID}}_selfcontained
path: "${{env.CODE_LOCATION}}output/tfwhatsup_${{matrix.RID}}_sefcontained.tar.gz"
create_release:
needs: [build, publish_artifacts]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Setup NuGet
uses: NuGet/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
nuget-version: "5.x"
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: See download contents
run: ls -R
- name: Create GitHub Release With Assets
uses: ncipollo/release-action@v1
with:
artifacts: "**/*.tar.gz,**/*.nupkg"
tag: "v${{needs.build.outputs.VERSION}}"
artifactErrorsFailBuild: true
allowUpdates: false
draft: false
generateReleaseNotes: true
prerelease: false
- name: Publish Nuget
working-directory: ""
run: nuget push **/*.nupkg -Source 'https://api.nuget.org/v3/index.json'