-
-
Notifications
You must be signed in to change notification settings - Fork 4
204 lines (172 loc) · 6.42 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# This workflow will publish the project
name: Publish
on:
workflow_dispatch:
inputs:
config-file:
type: string
default: "./publish/config.json"
target-os:
type: choice
default: all
options:
- windows
- linux
- macos
- all
target-runtime:
type: choice
default: all
options:
- x86
- x64
- arm
- arm64
- all
release:
types: [published]
env:
dotnet-version: 8.x
default-config-file: "./publish/config.json"
default-target-os: all
default-target-runtime: all
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.publish-config-parser.outputs.profiles }}
status: ${{ steps.checker.outputs.status }}
project-file: ${{ steps.publish-config-parser.outputs.project-file }}
output-name: ${{ steps.publish-config-parser.outputs.output-name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- id: inputs
shell: bash
run: |
config_file='${{ github.event.inputs.config-file }}'
target_os='${{ github.event.inputs.target-os }}'
target_runtime='${{ github.event.inputs.target-runtime }}'
echo "config-file=${config_file:=${{ env.default-config-file }}}" >> $GITHUB_OUTPUT
echo "target-os=${target_os:=${{ env.default-target-os }}}" >> $GITHUB_OUTPUT
echo "target-runtime=${target_runtime:=${{ env.default-target-runtime }}}" >> $GITHUB_OUTPUT
- name: Parse configuration "${{ github.event.inputs.config-file }}"
id: publish-config-parser
uses: ./.github/actions/publish-config-parser
with:
config-file: ${{ env.config-file }}
tags: "${{ env.target-os }},${{ env.target-runtime }}"
env:
config-file: ${{ steps.inputs.outputs.config-file }}
target-os: ${{ steps.inputs.outputs.target-os }}
target-runtime: ${{ steps.inputs.outputs.target-runtime }}
- name: Check profiles
id: checker
run: |
profiles='${{ steps.publish-config-parser.outputs.profiles }}'
length=$( echo $profiles | jq '.include | length' )
if(( $length > 0 )); then
echo "status=success" >> $GITHUB_OUTPUT
else
echo "status=failure" >> $GITHUB_OUTPUT
echo "No suitable publish profile found"
fi
publish:
name: Publish
needs: prepare
if: needs.prepare.outputs.status == 'success'
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJson(needs.prepare.outputs.matrix)}}
env:
output-name: ${{ needs.prepare.outputs.output-name }}
project-file: ${{ needs.prepare.outputs.project-file }}
configuration: ${{ matrix.configuration }}
framework: ${{ matrix.framework }}
runtime: ${{ matrix.runtime }}
publish-options: ${{ matrix.options }}
output-path: 'publish/output/${{ matrix.configuration }}/${{ matrix.framework }}/${{ matrix.runtime }}'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.dotnet-version }}
- id: version-number
uses: finebits/github-actions/version-number@v1
- uses: finebits/github-actions/pre-build/replace@v1
with:
file: ./src/Eppie.CLI/Eppie.CLI/Options/AuthorizationOptions.cs
placeholder: '\"<Gmail-ClientId>\"'
value: "${{ secrets.GMAIL_CLIENT_ID }}"
- uses: finebits/github-actions/pre-build/replace@v1
with:
file: ./src/Eppie.CLI/Eppie.CLI/Options/AuthorizationOptions.cs
placeholder: '\"<Gmail-ClientSecret>\"'
value: "${{ secrets.GMAIL_CLIENT_SECRET }}"
- uses: finebits/github-actions/pre-build/replace@v1
with:
file: ./src/Eppie.CLI/Eppie.CLI/Options/AuthorizationOptions.cs
placeholder: '\"<Outlook-ClientId>\"'
value: "${{ secrets.OUTLOOK_CLIENT_ID }}"
- name: Publish ${{ env.output-name }} [${{ env.version-short }}]
run: |
dotnet publish "${{ env.project-file }}" --output "${{ env.output-path }}" --configuration "${{ env.configuration }}" --framework "${{ env.framework }}" --runtime "${{ env.runtime }}" --property:Version="${{ env.version-full }}" ${{ env.publish-options }}
env:
version-full: "${{ steps.version-number.outputs.suffix-githash-version }}"
version-short: "${{ steps.version-number.outputs.suffix-version }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "${{ env.output-name }}-${{ env.runtime }} [${{ env.version-short }}]"
path: "${{ env.output-path }}"
env:
artifact-name: "${{ env.output-name }}"
version-short: "${{ steps.version-number.outputs.suffix-version }}"
upload-assets:
name: Upload Assets
if: github.event_name == 'release'
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
env:
artifacts-root: artifacts
assets-root: assets
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: "${{ env.artifacts-root }}"
- name: Prepare Assets
shell: bash
run: |
asset_root="${{ env.assets-root }}"
mkdir -p "${asset_root}"
artifact_pattern="${{ env.artifacts-root }}/*"
for item in $artifact_pattern ; do
if [ -d "$item" ] ; then
item_name="${item##*/}"
# remove version
asset_name="${item_name% [*}"
if [[ "$asset_name" == *"-osx-"* || "$asset_name" == *"-linux-"* ]]; then
tar -czf "$asset_root/${asset_name}.tar.gz" -C "$item" . && echo "Archiving of the asset '$asset_name' has been completed successfully." || echo "::warning::Failed to archive asset '$asset_name'"
else
zip -rjq "$asset_root/${asset_name}.zip" "$item" && echo "Archiving of the asset '$asset_name' has been completed successfully." || echo "::warning::Failed to archive asset '$asset_name'"
fi
fi
done
- name: Upload All Assets
uses: finebits/github-actions/upload-release-asset@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.release.tag_name }}
path: "${{ env.assets-root }}/*"