-
Notifications
You must be signed in to change notification settings - Fork 21
251 lines (216 loc) · 9.71 KB
/
build-branch.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Build DocBook xslTNG
on: push
jobs:
check_branch:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.check_step.outputs.branch }}
reponame: ${{ steps.check_step.outputs.reponame }}
tag: ${{ steps.check_step.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get branch name, etc.
id: check_step
run: |
raw=${{ github.repository }}
reponame=${raw##*/}
echo "reponame=$reponame" >> $GITHUB_OUTPUT
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw##*/}
echo "branch=$branch" >> $GITHUB_OUTPUT
tag=""
if [ ${{ github.ref_type }} = "tag" ]; then
tag=${{ github.ref_name }}
echo "Running in $reponame on $branch for $tag"
else
echo "Running in $reponame on $branch"
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
build-and-deploy:
name: Build xslTNG on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: check_branch
env:
HAVE_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN != '' }}
HAVE_GPGKEYURI: ${{ secrets.ACCESS_TOKEN != '' && secrets.GPGKEYURI != '' }}
HAVE_SAXON_EE: ${{ secrets.SAXON_PASSPHRASE != '' }}
CIWORKFLOW: yes
CI_SHA1: ${{ github.sha }}
CI_BUILD_NUM: ${{ github.run_number }}
CI_PROJECT_USERNAME: ${{ github.repository_owner }}
CI_PROJECT_REPONAME: ${{ needs.check_branch.outputs.reponame }}
CI_BRANCH: ${{ needs.check_branch.outputs.branch }}
CI_TAG: ${{ needs.check_branch.outputs.tag }}
strategy:
matrix:
os: [macos-11, ubuntu-20.04]
steps:
- name: Install platform-independent Python modules
run: |
python3 -m pip install pygments==2.14.0 click cython
# Test the build on Mac
- name: Install dependencies on Mac
if: matrix.os == 'macos-11'
run: |
brew install rsync libxml2 libxslt sass/sass/sass
python3 -m pip install saxonche
python3 -m pip install --no-binary lxml html5-parser
- name: Checkout the main branch on Mac
if: matrix.os == 'macos-11'
uses: actions/checkout@v3
- name: Get the latest releases (authenticated request on mac)
if: ${{ matrix.os == 'macos-11' && env.HAVE_ACCESS_TOKEN == 'true' }}
run: |
mkdir -p build
# Don’t attempt to use continuation lines here because Windows
curl --request GET --url https://api.github.com/repos/${{ github.repository }}/releases --header 'authorization: Bearer ${{ secrets.ACCESS_TOKEN }}' -o build/releases.json
- name: Build on Mac
if: matrix.os == 'macos-11'
run: |
ls build
./gradlew --stacktrace -PrequireCompileSuccess=true dist
# Test the build on Windows
- name: Install dependencies on Windows
if: matrix.os == 'windows-2019'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install sass
- name: Checkout the main branch on Windows
if: matrix.os == 'windows-2019'
uses: actions/checkout@v3
- name: Get the latest releases (authenticated request on Windows)
if: ${{ matrix.os == 'windows-2019' && env.HAVE_ACCESS_TOKEN == 'true' }}
run: |
mkdir -p build
# Don’t attempt to use continuation lines here because Windows
curl --request GET --url https://api.github.com/repos/${{ github.repository }}/releases --header 'authorization: Bearer ${{ secrets.ACCESS_TOKEN }}' -o build/releases.json
- name: Build on Windows
if: matrix.os == 'windows-2019'
env:
JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
run: |
./gradlew --stacktrace -PrequireCompileSuccess=true -PrequireTestSuccess=false dist
# Test the build on Linux
- name: Install dependencies on Linux
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install epubcheck rsync libxml2-dev libxslt-dev
curl -o /tmp/dart.tar.gz -L https://github.com/sass/dart-sass/releases/download/1.56.0/dart-sass-1.56.0-linux-x64.tar.gz
cd /tmp && tar zxf dart.tar.gz && sudo mv dart-sass/sass /usr/local/bin
python3 -m pip install saxonche
python3 -m pip install --no-binary lxml html5-parser
- name: Checkout the gh-pages branch on Linux
if: matrix.os == 'ubuntu-20.04'
uses: actions/checkout@v3
with:
ref: 'gh-pages'
- name: Save EPUB and PDFs
if: matrix.os == 'ubuntu-20.04'
run: tar cf - epub pdf | gzip > /tmp/save-epub-pdf.tar.gz
- name: Save the current version(s) of the guide
if: matrix.os == 'ubuntu-20.04'
run: |
mkdir /tmp/guide
rsync -var guide/ /tmp/guide/
rm -f /tmp/guide/*.html /tmp/guide/validated.xml
cp guide/index.html /tmp
- name: Checkout the main branch on Linux
if: matrix.os == 'ubuntu-20.04'
uses: actions/checkout@v3
- name: Setup SaxonEE on Linux
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_SAXON_EE == 'true' }}
run: gpg --batch --yes --passphrase ${{ secrets.SAXON_PASSPHRASE }} -d tools/saxon.enc | tar zxf -
- name: Get the latest releases (authenticated request on Windows)
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' }}
run: |
mkdir -p build
# Don’t attempt to use continuation lines here because Windows
curl --request GET --url https://api.github.com/repos/${{ github.repository }}/releases --header 'authorization: Bearer ${{ secrets.ACCESS_TOKEN }}' -o build/releases.json
- name: Build on Linux
if: matrix.os == 'ubuntu-20.04'
run: |
./gradlew --stacktrace -PrequireCompileSuccess=true dist
- name: Cleanup SaxonEE
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_SAXON_EE == 'true' }}
run: rm -rf lib
- name: Restore EPUB and PDFs
if: matrix.os == 'ubuntu-20.04'
run: cd build/website && tar zxf /tmp/save-epub-pdf.tar.gz
- name: Restore previous version(s) of the guide
if: matrix.os == 'ubuntu-20.04'
run: |
rsync -var /tmp/guide/ build/website/guide/
if [ ! -f build/website/guide/index.html ]; then \
mv /tmp/index.html build/website/guide/; \
fi
- name: Deploy main to gh-pages
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/website
token: ${{ secrets.ACCESS_TOKEN }}
branch: gh-pages
target-folder: /
- name: Deploy tagged release to CDN as ${{ env.CI_TAG }}
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/release
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: ${{ github.repository_owner}}/cdn
branch: master
target-folder: /release/xsltng/${{ env.CI_TAG }}
- name: Deploy tagged release to CDN as current
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/release
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: ${{ github.repository_owner}}/cdn
branch: master
target-folder: /release/xsltng/current
- name: Publish release
uses: softprops/action-gh-release@v1
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
with:
draft: false
prerelease: false
fail_on_unmatched_files: true
files: |
build/distributions/docbook-xslTNG-${{ env.CI_TAG }}.zip
build/distributions/docbook-xslTNG-nosaxon-${{ env.CI_TAG }}.zip
- name: Publish to Sonatype
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_GPGKEYURI == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
run: |
curl -s -o secret.gpg ${{ secrets.GPGKEYURI }}
./gradlew -PsonatypeUsername=${{ secrets.SONATYPEUSER }} \
-PsonatypePassword="${{ secrets.SONATYPEPASS }}" \
-Psigning.keyId="${{ secrets.SIGNKEY }}" \
-Psigning.password="${{ secrets.SIGNPSW }}" \
-Psigning.secretKeyRingFile=./secret.gpg \
publish
rm -f secret.gpg
- name: Checkout the CDN
uses: actions/checkout@v3
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
with:
repository: ${{ github.repository_owner}}/cdn
token: ${{ secrets.ACCESS_TOKEN }}
fetch-depth: 0
ref: 'master'
- name: Rebuild the CDN indexes
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
run: bin/git-index-html
- name: Deploy the indexes back to the CDN
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
with:
folder: .
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: ${{ github.repository_owner}}/cdn
branch: master
target-folder: /