Skip to content

Use git versioning for guide #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4.1.1

# Set up QEMU for cross-platform builds below
- name: Set up QEMU
Expand Down Expand Up @@ -92,11 +92,15 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/[email protected]
with:
fetch-depth: 0
fetch-tags: true

- name: Run the action on guide
uses: trustedcomputinggroup/markdown@latest
with:
extra-build-options: "--gitversion"
input-md: guide.md
output-pdf: guide.pdf
output-tex: guide.tex
Expand Down
16 changes: 14 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ if test "${do_gitversion}" == "yes"; then

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

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

# Grab the date from the front matter and generate the full date and year.
DATE="$(grep date: "${input_file}" | head -n 1 | cut -d ' ' -f 2)"
if test "${do_gitversion}" == "yes"; then
# If using the git information for versioning, grab the date from there
DATE="$(git show -s --date=format:'%Y/%m/%d' --format=%ad)"
else
# Else, grab the date from the front matter and generate the full date and year.
DATE="$(grep date: "${input_file}" | head -n 1 | cut -d ' ' -f 2)"
fi

YEAR="$(date --date="${DATE}" +%Y)"
DATE_ENGLISH="$(date --date="${DATE}" "+%B %-d, %Y")"

echo "Date: ${DATE}"
echo "Year: ${YEAR}"
echo "Date (English): ${DATE_ENGLISH}"

# Run Pandoc
export MERMAID_FILTER_THEME="forest"
export MERMAID_FILTER_FORMAT="pdf"
Expand All @@ -292,6 +303,7 @@ if [ -n "${pdf_output}" ]; then
--top-level-division=section \
--variable=block-headings \
--variable=numbersections \
--metadata=date:"${DATE}" \
--metadata=date-english:"${DATE_ENGLISH}" \
--metadata=year:"${YEAR}" \
--metadata=titlepage:true \
Expand Down
5 changes: 0 additions & 5 deletions guide.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
---
title: "TCG Markdown User's Guide"
version: 0.1
revision: 1
date-english: December 17, 2023
date: 2023/12/17
year: 2023
type: GUIDANCE
status: DRAFT
template: bluetop
Expand Down