-
-
Notifications
You must be signed in to change notification settings - Fork 107
146 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
name: Image Builder
on:
push:
branches:
- main
paths:
- alpine/freeze/**
- static/freeze/**
- ubuntu/freeze/**
workflow_dispatch:
inputs:
pandoc_version:
description: >-
Pandoc version; must be either `main` or a release number
default: main
type: string
base_system:
description: Docker base system
default: alpine
type: choice
options:
- alpine
- ubuntu
- static
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
base_system: ${{ steps.set-stack.outputs.stack }}
pandoc_version: ${{ steps.set-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: set-stack
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "stack=${{ inputs.base_system }}" >> $GITHUB_OUTPUT
else
# Extract stack from the changed files paths
CHANGED_FILES=${{ git diff --name-only ${{ github.event.before }} ${{ github.event.after }}}
if echo "$CHANGED_FILES" | grep -q "^alpine/"; then
echo "stack=alpine" >> $GITHUB_OUTPUT
elif echo "$CHANGED_FILES" | grep -q "^ubuntu/"; then
echo "stack=ubuntu" >> $GITHUB_OUTPUT
elif echo "$CHANGED_FILES" | grep -q "^static/"; then
echo "stack=static" >> $GITHUB_OUTPUT
fi
fi
- id: set-version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "version=${{ inputs.pandoc_version }}" >> $GITHUB_OUTPUT
else
# Extract version directly from the changed freeze file name
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
FREEZE_FILE=$(echo "$CHANGED_FILES" | grep '\.project\.freeze$' | head -1)
VERSION=$(basename "$FREEZE_FILE" | sed -E 's/pandoc-(.*)\.project\.freeze/\1/')
# If no version found from freeze file, default to main
echo "version=${VERSION:-main}" >> $GITHUB_OUTPUT
fi
# Build images and store them as tar archive
core:
name: minimal and core
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: "pandoc/multiarch"
- name: minimal
timeout-minutes: 25
uses: ./.github/actions/build
with:
image_type: minimal
base_system: ${{ needs.prepare.outputs.base_system }}
pandoc_version: ${{ needs.prepare.outputs.pandoc_version }}
dockerfile: ${{ needs.prepare.outputs.base_system }}/Dockerfile
target: ${{ needs.prepare.outputs.base_system }}-minimal
- name: core
uses: ./.github/actions/build
if: ${{ needs.prepare.outputs.base_system != 'static' }}
with:
image_type: core
base_system: ${{ needs.prepare.outputs.base_system }}
pandoc_version: ${{ needs.prepare.outputs.pandoc_version }}
dockerfile: ${{ needs.prepare.outputs.base_system }}/Dockerfile
target: ${{ needs.prepare.outputs.base_system }}-core
typst:
name: Typst
if: ${{ needs.prepare.outputs.base_system != 'static' }}
needs: [prepare, core]
uses: ./.github/workflows/addon.yaml
secrets: inherit
with:
addon: typst
base_system: ${{ needs.prepare.outputs.base_system }}
pandoc_version: ${{ needs.prepare.outputs.pandoc_version }}
latex:
name: LaTeX
if: ${{ needs.prepare.outputs.base_system != 'static' }}
needs: [prepare, core]
uses: ./.github/workflows/addon.yaml
secrets: inherit
with:
addon: latex
base_system: ${{ needs.prepare.outputs.base_system }}
pandoc_version: ${{ needs.prepare.outputs.pandoc_version }}
extra:
name: Extra
needs: [prepare, latex]
uses: ./.github/workflows/addon.yaml
secrets: inherit
with:
addon: extra
base_system: ${{ needs.prepare.outputs.base_system }}
pandoc_version: ${{ needs.prepare.outputs.pandoc_version }}