-
-
Notifications
You must be signed in to change notification settings - Fork 102
152 lines (130 loc) · 4.64 KB
/
build.yaml
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
name: Image Builder
on:
push:
# Build and publish: configure build via commit message
branches:
- master
paths-ignore:
- '.dockerignore'
- '.github/FUNDING.yml'
- 'docs/*'
- 'LICENSE'
- 'README.md'
- 'SECURITY.md'
- 'release-checklist.md'
pull_request:
# Build, but don't push on pull requests
schedule:
- cron: '33 6 * * 1,4'
jobs:
configure:
name: Configure
runs-on: ubuntu-latest
outputs:
pandoc-version: ${{ steps.config.outputs.pandoc-version }}
stacks: ${{ steps.config.outputs.stacks }}
build: ${{ steps.config.outputs.build }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.after }}
- name: Configure build
id: config
run: |
if [ 'schedule' = "${{ github.event_name }}" ]; then
pandoc_versions="['edge']"
stacks="['alpine','ubuntu','static']"
build=true
else
# Determine PANDOC_VERSION for Makefile based on commit message.
# We are looking for if the string `release=...`. If it exists,
# and if it is followed by a comma-separated list of versions,
# then those should be built. Otherwise, build the `master` branch
# (which is # the `edge` image).
versions=$(git log --pretty='%B' -1 | \
sed -ne 's#.*\brelease=\(.*\)$#\1#p' | \
sed -e 's# *, *#\n#g' | \
sed -ne 's#^\([0-9]*\(\.[0-9]*\)*\)*$#"\1"#p' | \
tr '\n' ',')
if [ -z "$versions" ]; then
versions="'edge'"
fi
pandoc_versions="[${versions}]"
# Get and clean stacks
stacks=$(git log --pretty='%B' -1 | \
sed -ne 's#.*\bstack=\(.*\)$#\1#p' | \
sed -e 's# *, *#\n#g' | \
sed -ne 's#^\(alpine\|ubuntu\|static\)$#"\1"#p' | \
tr '\n' ',')
if [ -z "$stacks" ]; then
stacks="'alpine', 'ubuntu', 'static'"
fi
stacks="[${stacks}]"
# Don't build if commit message has a line 'skip build'
build=true
if git log --pretty='%B' -1 | grep -ie '^skip[ -]build$'; then
build=false
fi
fi
printf "Setting outputs:\n"
printf " - pandoc-versions: %s\n" "$pandoc_versions"
printf " - stacks: %s\n" "$stacks"
printf " - build: %s\n" "$build"
printf 'pandoc-version=%s\n' "$pandoc_versions" >> $GITHUB_OUTPUT
printf 'stacks=%s\n' "$stacks" >> $GITHUB_OUTPUT
printf 'build=%s\n' "$build" >> $GITHUB_OUTPUT
# Build images and store them as tar archive
build:
if: ${{ fromJSON( needs.configure.outputs.build ) }}
name: Build
runs-on: ubuntu-latest
needs: configure
strategy:
fail-fast: false
matrix:
stack: ${{ fromJSON( needs.configure.outputs.stacks ) }}
version: ${{ fromJSON( needs.configure.outputs.pandoc-version ) }}
env:
PANDOC_VERSION: ${{ matrix.version }}
STACK: ${{ matrix.stack }}
steps:
- uses: actions/checkout@v4
- name: Show config
run: make show-args
- name: Build minimal image
run: make minimal
- name: Test minimal image
run: make test-minimal
# We can't build statically linked core or latex images
- name: Build core image
if: ${{ matrix.stack != 'static' }}
run: make core
- name: Build LaTeX image
if: ${{ matrix.stack != 'static' }}
run: make latex
- name: Build extra image
if: ${{ matrix.stack != 'static' }}
run: make extra
- name: Test core image
if: ${{ matrix.stack != 'static' }}
run: make test-core
- name: Test LaTeX image
if: ${{ matrix.stack != 'static' }}
run: make test-latex
- name: Test extra image
if: ${{ matrix.stack != 'static' }}
run: make test-extra
- name: Push
if: >-
(github.event_name == 'push' || github.event_name == 'schedule') &&
github.repository == 'pandoc/dockerfiles'
run: |
# Log into registry
echo "${{ secrets.DOCKER_HUB_TOKEN }}" |
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
make push-minimal
if [ "$STACK" != 'static' ]; then
make push-core
make push-latex
make push-extra
fi