diff options
author | Dave Kerr <dwmkerr@gmail.com> | 2020-10-01 18:06:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 18:06:58 +0800 |
commit | 0bf80bf8b5c63fedf455a8aa0f4c271678f45090 (patch) | |
tree | 083e50fab4d30880f8368980343d78d0a8561de1 | |
parent | 50e2f2e6ce8e82ae8b81ff24688dbb4824ca09a0 (diff) |
build: version number and date in e-book
-rw-r--r-- | .github/workflows/build-on-pull-request.yaml | 7 | ||||
-rw-r--r-- | .github/workflows/release-on-tag.yaml | 7 | ||||
-rwxr-xr-x | scripts/prepare-markdown-for-ebook.sh | 11 |
3 files changed, 22 insertions, 3 deletions
diff --git a/.github/workflows/build-on-pull-request.yaml b/.github/workflows/build-on-pull-request.yaml index dd3f17a..447ceac 100644 --- a/.github/workflows/build-on-pull-request.yaml +++ b/.github/workflows/build-on-pull-request.yaml @@ -14,9 +14,14 @@ jobs: - name: Checkout uses: actions/checkout@v2 + # Set a descriptive version. For PRs it'll be the short sha. + - name: Set Version + id: set_version + run: echo ::set-output name=VERSION::$(git rev-parse --short HEAD) + # Prepare the content files. - name: Prepare Content - run: ./scripts/prepare-markdown-for-ebook.sh + run: ./scripts/prepare-markdown-for-ebook.sh ${{ steps.set_version.outputs.VERSION }} # Create a PDF from the prepared markdown. - name: Prepare PDF diff --git a/.github/workflows/release-on-tag.yaml b/.github/workflows/release-on-tag.yaml index 722ec3d..7c527d1 100644 --- a/.github/workflows/release-on-tag.yaml +++ b/.github/workflows/release-on-tag.yaml @@ -14,9 +14,14 @@ jobs: - name: Checkout uses: actions/checkout@v2 + # Set a descriptive version. For PRs it'll be the short sha. + - name: Set Version + id: set_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + # Prepare the content files. - name: Prepare Content - run: ./scripts/prepare-markdown-for-ebook.sh + run: ./scripts/prepare-markdown-for-ebook.sh ${{ steps.set_version.outputs.VERSION }} # Create a PDF from the prepared markdown. - name: Prepare PDF diff --git a/scripts/prepare-markdown-for-ebook.sh b/scripts/prepare-markdown-for-ebook.sh index 172fd3e..38bd356 100755 --- a/scripts/prepare-markdown-for-ebook.sh +++ b/scripts/prepare-markdown-for-ebook.sh @@ -2,12 +2,21 @@ # This script prepares a `hacker-laws.md` file which is in a format ready to be # exported to PDF or other formats for an e-book. +# Require that we provide the version number and get a date. +version=$1 +date=$(date "+%Y-%m-%d") + +if [ -z $version ]; then + echo "version must be specified: ./prepare-markdown-for-ebook.sh <version>" + exit 1 +fi + # Create the frontmatter. cat << EOF > frontmatter.md --- title: "Hacker Laws" author: "Dave Kerr, github.com/dwmkerr/hacker-laws" -subtitle: "Laws, Theories, Principles and Patterns that developers will find useful." +subtitle: "Laws, Theories, Principles and Patterns that developers will find useful. ${version}, ${date}." --- EOF |