-
Notifications
You must be signed in to change notification settings - Fork 425
211 lines (178 loc) · 7.82 KB
/
publish_linux+windows.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
205
206
207
208
209
210
211
################################################################################
# Build Release Packages for Major Platforms
#
# - Builds release packages on multiple operating systems.
#
# - Some packages may have to be supplemented with manually-built releases
# to account for code-signing and/or notarization requirements.
#
################################################################################
name: Publish Linux+Windows
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
required: true
description: "Specify a ref (tag, branch, or sha) to build. If you specify a tag and a release exists, then artifacts will be attached to it."
jobs:
publish_packages:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
############################################################
# Ubuntu latest is a normal build.
# Package building requires rpm in order to generate
# .rpm packages. The runner already includes this by
# default.
############################################################
- os: ubuntu-latest
name: Standard
cmake_command: "cmake ../.. -DCMAKE_BUILD_TYPE=Release"
build_command: "cmake --build . --config Release --target package"
sha_command: "sha256sum"
stat_command: "stat"
artifacts: "tidy-%s-Linux-64bit.deb tidy-%s-Linux-64bit.rpm"
############################################################
# We won't actually build macOS, because CMake is broken.
# We have a separate build script for macOS that's better
# than CMake's results anyway.
############################################################
#- os: macOS-latest
# name: X86_64 & Arm64
# cmake_command: "cmake ../.. -DCMAKE_BUILD_TYPE=Release '-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64'"
# build_command: "cmake --build . --config Release --target package"
# sha_command: "shasum -a 256"
# stat_command: "gstat"
# artifacts: "tidy-%s-macOS-x86_64+arm64.pkg"
############################################################
# The standard Windows build is using MSVC 19 as of now.
# Package building requires nsis and wixtoolset, both of
# which can be installed via choco, which is already
# installed. Note: looks like wixtoolset is already
# installed.
############################################################
- os: windows-latest
name: MSVC
cmake_command: "cmake ../.. -DCMAKE_BUILD_TYPE=Release"
build_command: "cmake --build . --config Release --target package"
sha_command: "sha256sum"
stat_command: "stat"
artifacts: "tidy-%s-win64.exe tidy-%s-win64.msi tidy-%s-win64.zip"
steps:
############################################################
# Install Windows Pre-Requisites
############################################################
- name: Install Windows Requirements
if: ${{matrix.os == 'windows-latest'}}
run: |
choco install nsis -y
############################################################
# Install macOS Pre-Requisites
############################################################
- name: Install macOS Requirements
if: ${{matrix.os == 'macOS-latest'}}
run: |
brew install coreutils
############################################################
# Checkput the repository.
############################################################
- name: Checkout Self
uses: actions/checkout@v2
############################################################
# Get the version number. The output isn't available until
# we exit this step.
############################################################
- name: Get Tidy Version
id: getversion
working-directory: ${{github.workspace}}
shell: bash
run: |
echo "::set-output name=version::$(head -1 version.txt)"
############################################################
# Print the version number, which is now available from
# the previous step.
############################################################
- name: Print Tidy Version
shell: bash
run: |
echo "Tidy version is ${{ steps.getversion.outputs.version }}."
############################################################
# Configure and Build
############################################################
- name: Configure and Build
working-directory: ${{github.workspace}}/build/cmake
shell: bash
run: |
${{matrix.cmake_command}}
${{matrix.build_command}}
############################################################
# Move Files and Make Checksums
############################################################
- name: Move Files and Make Checksums
working-directory: ${{github.workspace}}/build/cmake
shell: bash
run: |
ls -al
mkdir artifacts
array="${{matrix.artifacts}}"
for i in ${array[@]}; do
filename=$(printf "$i\n" ${{ steps.getversion.outputs.version }})
${{matrix.sha_command}} "$filename" > "artifacts/${filename}.sha256"
mv "$filename" "artifacts/"
done
############################################################
# Build Manifest Partials for binaries.html-tidy.org
############################################################
- name: Build Manifest Partials
working-directory: ${{github.workspace}}/build/cmake/artifacts
shell: bash
run: |
ls -al
manifest="../binaries-partial.yml"
touch "${manifest}"
for filename in *.*[^sha256]; do
filesize=$(numfmt --to=si --suffix=B $(wc -c < ${filename}))
modified=$(${{matrix.stat_command}} -c %y "${filename}" | cut -d'.' -f1)
modified="${modified//-//}"
sha256=$(${{matrix.sha_command}} "${filename}" | awk '{print $1}')
echo " - filename: ${filename}" >> "${manifest}"
echo " filesize: ${filesize}" >> "${manifest}"
echo " modified: ${modified}" >> "${manifest}"
echo " describe: ''" >> "${manifest}"
echo " sha256: ${sha256}" >> "${manifest}"
echo "" >> "${manifest}"
done;
cat "${manifest}"
############################################################
# Release the artifacts (existing tag specified)
############################################################
- name: Release to Existing Tag
if: ${{github.event.inputs.tag}}
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{github.event.inputs.tag}}"
files: "${{github.workspace}}/build/cmake/artifacts/*"
############################################################
# Release the artifacts (done via release)
############################################################
- name: Release via Publish Release
if: ${{!github.event.inputs.tag}}
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: "${{github.workspace}}/build/cmake/artifacts/*"
############################################################
# Post the manifest to the run results.
############################################################
- name: Post the Manifest
uses: actions/upload-artifact@v2
with:
name: "partials_for_website-${{matrix.os}}.yml"
path: ${{github.workspace}}/build/cmake/binaries-partial.yml