Skip to content

Commit 21a2d9e

Browse files
authored
Use git versioning for guide (#67)
Also, fix a minor issue where from PR's, the git tags are not available so we can't number the doc properly.
1 parent e35d2b2 commit 21a2d9e

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

.github/workflows/docker-publish.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
steps:
2424
- name: Checkout repository
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4.1.1
2626

2727
# Set up QEMU for cross-platform builds below
2828
- name: Set up QEMU
@@ -92,11 +92,15 @@ jobs:
9292

9393
steps:
9494
- name: Checkout repository
95-
uses: actions/checkout@v3
95+
uses: actions/[email protected]
96+
with:
97+
fetch-depth: 0
98+
fetch-tags: true
9699

97100
- name: Run the action on guide
98101
uses: trustedcomputinggroup/markdown@latest
99102
with:
103+
extra-build-options: "--gitversion"
100104
input-md: guide.md
101105
output-pdf: guide.pdf
102106
output-tex: guide.tex

build.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ if test "${do_gitversion}" == "yes"; then
149149

150150
# TODO: Should we fail if dirty?
151151
raw_version="$(git describe --always --tags)"
152+
echo "Git version: ${raw_version}"
152153
IFS='-' read -r -a dash_hunks <<< "${raw_version}"
153154

154155
# Could be one of:
@@ -262,11 +263,21 @@ sed 's/^---$/\\newpage/g;1s/\\newpage/---/g' "${build_dir}/${input_file}.1" > "$
262263
# While we're doing this, transform the case to all-caps.
263264
sed '0,/\\tableofcontents/s/^# \(.*\)/\\section*\{\U\1\}/g' "${build_dir}/${input_file}.2" > "${build_dir}/${input_file}.3"
264265

265-
# Grab the date from the front matter and generate the full date and year.
266-
DATE="$(grep date: "${input_file}" | head -n 1 | cut -d ' ' -f 2)"
266+
if test "${do_gitversion}" == "yes"; then
267+
# If using the git information for versioning, grab the date from there
268+
DATE="$(git show -s --date=format:'%Y/%m/%d' --format=%ad)"
269+
else
270+
# Else, grab the date from the front matter and generate the full date and year.
271+
DATE="$(grep date: "${input_file}" | head -n 1 | cut -d ' ' -f 2)"
272+
fi
273+
267274
YEAR="$(date --date="${DATE}" +%Y)"
268275
DATE_ENGLISH="$(date --date="${DATE}" "+%B %-d, %Y")"
269276

277+
echo "Date: ${DATE}"
278+
echo "Year: ${YEAR}"
279+
echo "Date (English): ${DATE_ENGLISH}"
280+
270281
# Run Pandoc
271282
export MERMAID_FILTER_THEME="forest"
272283
export MERMAID_FILTER_FORMAT="pdf"
@@ -292,6 +303,7 @@ if [ -n "${pdf_output}" ]; then
292303
--top-level-division=section \
293304
--variable=block-headings \
294305
--variable=numbersections \
306+
--metadata=date:"${DATE}" \
295307
--metadata=date-english:"${DATE_ENGLISH}" \
296308
--metadata=year:"${YEAR}" \
297309
--metadata=titlepage:true \

guide.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
---
22
title: "TCG Markdown User's Guide"
3-
version: 0.1
4-
revision: 1
5-
date-english: December 17, 2023
6-
date: 2023/12/17
7-
year: 2023
83
type: GUIDANCE
94
status: DRAFT
105
template: bluetop

0 commit comments

Comments
 (0)