-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Release PDFs | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
convert-markdown-to-pdf: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Fetch tags | ||
run: git fetch --tags | ||
|
||
- name: Get latest tag | ||
id: get_tag | ||
run: | | ||
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` || true) | ||
echo "Latest tag: $latest_tag" | ||
echo "::set-output name=tag::$latest_tag" | ||
- name: Calculate new version | ||
id: new_version | ||
run: | | ||
if [ -z "${{ steps.get_tag.outputs.tag }}" ]; then | ||
# No tags found, set initial version | ||
new_version="1.0.0" | ||
else | ||
# Parse the latest version | ||
latest_version=${{ steps.get_tag.outputs.tag }} | ||
IFS='.' read -r -a version_parts <<< "$latest_version" | ||
major=${version_parts[0]} | ||
minor=${version_parts[1]} | ||
patch=${version_parts[2]} | ||
# Increment the patch version | ||
patch=$((patch+1)) | ||
new_version="$major.$minor.$patch" | ||
fi | ||
echo "New version: $new_version" | ||
echo "::set-output name=version::$new_version" | ||
- name: Create new tag | ||
run: | | ||
git tag ${{ steps.new_version.outputs.version }} | ||
git push origin ${{ steps.new_version.outputs.version }} | ||
- name: Build PDFs | ||
run: make | ||
|
||
- name: Install Hub CLI | ||
run: sudo apt-get install -y hub | ||
|
||
- name: Upload PDFs to GitHub Releases | ||
run: | | ||
set -x | ||
cd build | ||
assets=() | ||
for asset in ./*.pdf; do | ||
assets+=("-a" "$asset") | ||
done | ||
tag_name="${{ steps.new_version.outputs.version }}" | ||
hub release create "${assets[@]}" -m "$tag_name" "$tag_name" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Automatically generate PDF from READMEs | ||
|
||
BUILD_FOLDER ?= build | ||
|
||
PDFs = healthcare-ci-pipelines.pdf | ||
|
||
TARGETS = $(PDFs:%=$(BUILD_FOLDER)/%) | ||
|
||
all: $(TARGETS) | ||
|
||
# Step 0: Create build folder | ||
$(BUILD_FOLDER): | ||
mkdir -p $(BUILD_FOLDER) | ||
|
||
# Step 1: Convert mermaid graphs into pngs and generate README-out.md | ||
README-out.md: README.md | ||
docker run \ | ||
-u $(shell id -u):$(shell id -g) \ | ||
-v $(shell pwd):/data \ | ||
-w /data/ \ | ||
minlag/mermaid-cli \ | ||
-i README.md -o README-out.md --outputFormat png \ | ||
--scale 10 | ||
|
||
# Step 2: Generate PDFs from README-out.md using pandoc | ||
$(BUILD_FOLDER)/%.pdf: $(BUILD_FOLDER) README-out.md | ||
docker run \ | ||
-u $(shell id -u):$(shell id -g) \ | ||
-w /data/ \ | ||
-v $(shell pwd):/data \ | ||
ghcr.io/ethan42/pandoctex \ | ||
pandoc README-out.md -f gfm -s \ | ||
--pdf-engine=xelatex \ | ||
-o "$(BUILD_FOLDER)/$*.pdf" \ | ||
-V mainfont="Linux Libertine O" \ | ||
-V monofont="Noto Mono" \ | ||
-V fontsize=12pt \ | ||
-V colorlinks=true -V linkcolor=darkgray -V urlcolor=blue -V toccolor=gray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters