-
-
Notifications
You must be signed in to change notification settings - Fork 1
145 lines (123 loc) · 4.98 KB
/
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Publish
on:
workflow_dispatch:
inputs:
sign:
description: 'Code Sign'
type: boolean
required: false
default: true
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
GITHUB_ACTIONS: true
jobs:
build:
runs-on: ubuntu-latest
outputs:
SemVer: ${{ steps.gitversion.outputs.SemVer }}
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: 5.x
- name: Determine Version
uses: gittools/actions/gitversion/execute@v0.10.2
id: gitversion
- name: Display GitVersion outputs
run: |
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
global-json-file: global.json
- name: Build and Publish Package
run: |
publish() {
output_path="./Artifacts/input_display_$1_${{ steps.gitversion.outputs.SemVer }}"
dotnet publish src/InputDisplay \
--configuration Release --self-contained \
--output "$output_path" \
-r $1 -p:DebugType=None -p:DebugSymbols=false \
-p:Version='${{ steps.gitversion.outputs.SemVer }}'
if [[ "$1" == *"win"* ]]; then
find "$output_path" -name "*.sh" -delete
else
find "$output_path" -name "*.cmd" -delete
fi
}
publish "win-x64"
publish "linux-x64"
publish "osx-x64"
- name: Zip artifacts
run: cd ./Artifacts; zip -r ../artifacts.zip *
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: app
path: artifacts.zip
sign:
runs-on: windows-latest
needs: build
if: github.event.inputs.sign == 'true' && github.ref == 'refs/heads/master' && needs.build.outputs.CommitsSinceVersionSource > 0
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: app
- name: Unzip artifacts
run: Expand-Archive -Path .\artifacts.zip -DestinationPath .\Artifacts
- name: Sign exe
uses: markeytos/code-sign-action@v1.01
with:
certificate: '${{ secrets.CERTIFICATE }}'
password: '${{ secrets.PASSWORD }}'
certificatesha1: '${{ secrets.CERTIFICATESHA1 }}'
folder: .\Artifacts\input_display_win-x64_${{ needs.build.outputs.SemVer }}
timestampUrl: 'http://timestamp.digicert.com'
recursive: true
- name: Zip artifacts
run: |
Remove-Item ./artifacts.zip
Compress-Archive -Path ./Artifacts/* -Destination artifacts.zip
- name: Upload artifact for deployment
uses: actions/upload-artifact@v3
with:
name: app
path: artifacts.zip
release:
runs-on: ubuntu-latest
needs: [ build, sign ]
if: | #Only release if there has been a commit/version change
always()
&& github.ref == 'refs/heads/master' && needs.build.outputs.CommitsSinceVersionSource > 0
&& needs.build.result == 'success'
&& (needs.sign.result == 'success' || needs.sign.result == 'skipped')
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: app
- name: Unzip Artifacts
run: unzip artifacts.zip -d ./Artifacts
- name: Zip Platform Artifacts
run: |
cd Artifacts
for subdir in */; do
dirname=$(basename "$subdir")
cd "$subdir"
zip -r "../$dirname.zip" *
cd ..
done
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.build.outputs.SemVer }}
name: Release ${{ needs.build.outputs.SemVer }}
artifacts: "./Artifacts/*.zip"
token: ${{ secrets.GITHUB_TOKEN }}