diff --git a/.github/release-please-config.json b/.github/release-please-config.json new file mode 100644 index 0000000..8bfd5bd --- /dev/null +++ b/.github/release-please-config.json @@ -0,0 +1,18 @@ +{ + "release-type": "simple", + "bump-minor-pre-major": true, + "packages": { + ".": { + "release-type": "simple", + "extra-files": [ + { + "type": "generic", + "path": "README.md" + } + ], + "changelog-path": ".github/CHANGELOG.md" + } + } +} + + diff --git a/.github/release-please-manifest.json b/.github/release-please-manifest.json new file mode 100644 index 0000000..466df71 --- /dev/null +++ b/.github/release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0" +} diff --git a/.github/workflows/build-on-pull-request.yaml b/.github/workflows/build-on-pull-request.yaml index c530184..f3b2cc5 100644 --- a/.github/workflows/build-on-pull-request.yaml +++ b/.github/workflows/build-on-pull-request.yaml @@ -2,52 +2,3 @@ name: "Validate Pull Request" on: pull_request: -jobs: - test-website-build: - runs-on: ubuntu-24.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Test Website Build - run: | - cd .github/website - make install - make build - cp -r build/. '../pages' - ls -al "../pages" - - prepare-pdf: - runs-on: ubuntu-24.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - - # 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 ${{ steps.set_version.outputs.VERSION }} - - # Create a PDF from the prepared markdown. - - name: Prepare PDF - uses: docker://pandoc/latex:2.9 - with: - args: "-V toc-title:\"Table Of Contents\" --toc --pdf-engine=pdflatex --standalone --output hacker-laws.pdf hacker-laws.md" - - # Publish the PDF and intermediate markdown as an artifact. - - name: Publish PDF Artifact - uses: actions/upload-artifact@master - with: - name: hacker-laws.pdf - path: hacker-laws.pdf - - - name: Publish Intermediate Markdown Artifact - uses: actions/upload-artifact@master - with: - name: hacker-laws.md - path: hacker-laws.md - diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml new file mode 100644 index 0000000..d077280 --- /dev/null +++ b/.github/workflows/cicd.yaml @@ -0,0 +1,80 @@ +name: CI/CD + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + test-website-build: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Test Website Build + run: | + cd .github/website + make install + make build + cp -r build/. '../pages' + ls -al "../pages" + + release: + needs: test-website-build + runs-on: ubuntu-24.04 + outputs: + released: ${{ steps.release-please.outputs.release_created }} + tag: ${{ steps.release-please.outputs.tag_name }} + steps: + - uses: googleapis/release-please-action@v4 + id: release-please + with: + manifest-file: .github/release-please-manifest.json + config-file: .github/release-please-config.json + + release-pdf: + runs-on: ubuntu-24.04 + needs: release + if: ${{ needs.release.outputs.released }} + steps: + - name: Checkout + uses: actions/checkout@v5 + + # Set a descriptive version. For PRs it'll be the short sha. + - name: Check Version + run: echo "${VERSION}" + env: + VERSION: ${{ needs.release.outputs.tag }} + + # Set a descriptive version. For PRs it'll be the short sha. + - name: Prepare Markdown + run: | + # Set the env vars we use (version set for clarity). + export DATE=$(date +%F) + export VERSION="${VERSION}" + make prepare-markdown + env: + VERSION: ${{ needs.release.outputs.tag }} + + # Create the PDF files. + - name: Create PDF + run: make create-pdf + + # Publish the PDF and intermediate markdown as an artifact. + # - name: Publish PDF Artifact + # uses: actions/upload-artifact@3 + # with: + # name: hacker-laws.pdf + # path: hacker-laws.pdf + + - name: Attach assets to GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload "${{ needs.release.outputs.tag }}" --clobber hacker-laws.pdf hacker-laws.md diff --git a/README.md b/README.md index f44ea09..ea59e88 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +--- +title: "Hacker Laws" +author: "Dave Kerr, github.com/dwmkerr/hacker-laws" +subtitle: "Laws, Theories, Principles, and Patterns that developers will find useful. ${VERSION}, ${DATE}." +version: ${VERSION} +--- +
-*(Image Reference: By Daniels219 at English Wikipedia, Creative Commons Attribution-Share Alike 3.0 Unported, https://en.wikipedia.org/wiki/File:AmdahlsLaw.svg)*
As can be seen, even a program which is 50% parallelisable will benefit very little beyond 10 processing units, whereas a program which is 95% parallelisable can still achieve significant speed improvements with over a thousand processing units.
@@ -275,7 +277,6 @@ As a person's understanding and experience in a domain grows, they may well enco
Real-world examples:
-* [Apple vs. FBI: Why This Anti-Terror Hawk Switched Sides](https://fortune.com/2016/03/10/apple-fbi-lindsay-graham/) - In 2016 Senator Lindsey Graham changed his stance on Apple creating a 'backdoor' in their encryption of devices. Initially Graham had been critical of Apple challenging a request to create a 'backdoor', which he saw as necessary to investigate potential terrorist plots. However, by Graham's own admission, as he learned more about the technical complexity of the domain, he realised that he had assumed it to be far more simple than he had realised, and that such a backdoor could have serious negative consequences. This could potentially be considered an example of the Dunning-Kruger effect - a cyber-security expert would likely understand immediately how such a backdoor could be exploited, as they have deep understanding of the domain, a layperson might assume that phone security is more similar to _physical security_ where the practice of having a 'master key' for law enforcement is possible, but this analogy does not apply sufficiently well to describe modern encryption in cyber-security.
### Fitts' Law
@@ -285,7 +286,6 @@ Fitts' law predicts that the time required to move to a target area is a functio
-## Translations
-
-Thanks to a number of wonderful contributors, Hacker Laws is available in a number of languages. Please consider sponsoring moderators!
-
-| Language | Moderator | Status |
-|----------|-----------|--------|
-| [AR Arabic / Arabic](./translations/ar-AR.md) | [Abdurrahman Rajab - a0m0rajab](https://github.com/a0m0rajab) | . |
-| [🇮🇩 Bahasa Indonesia / Indonesian](./translations/pt-BR.md) | [arywidiantara](https://github.com/arywidiantara) | [](https://gitlocalize.com/repo/2513/id?utm_source=badge) |
-| [🇧🇷 Brasileiro / Brazilian](./translations/pt-BR.md) | [Eugênio Moreira](https://github.com/eugenioamn), [Leonardo Costa](https://github.com/leofc97) | [](https://gitlocalize.com/repo/2513/pt-BR?utm_source=badge) |
-| [🇨🇳 中文 / Chinese](https://github.com/nusr/hacker-laws-zh) | [Steve Xu](https://github.com/nusr) | Partially complete |
-| [🇩🇪 Deutsch / German](./translations/de.md) | [Vikto](https://github.com/viktodergunov) | [](https://gitlocalize.com/repo/2513/de?utm_source=badge) |
-| [🇫🇷 Français / French](./translations/fr.md) | [Kevin Bockelandt](https://github.com/KevinBockelandt) | [](https://gitlocalize.com/repo/2513/fr?utm_source=badge) |
-| [🇬🇷 ελληνικά / Greek](./translations/el.md) | [Panagiotis Gourgaris](https://github.com/0gap) | [](https://gitlocalize.com/repo/2513/el?utm_source=badge) |
-| [🇮🇹 Italiano / Italian](https://github.com/csparpa/hacker-laws-it) | [Claudio Sparpaglione](https://github.com/csparpa) | Partially complete |
-| [🇯🇵 JP 日本語 / Japanese](./translations/jp.md) | [Fumikazu Fujiwara](https://github.com/freddiefujiwara)| [](https://gitlocalize.com/repo/2513/ja?utm_source=badge) |
-| [🇰🇷 한국어 / Korean](https://github.com/codeanddonuts/hacker-laws-kr) | [Doughnut](https://github.com/codeanddonuts) | Partially complete |
-| [🇱🇻 Latviešu Valoda / Latvian](./translations/lv.md) | [Arturs Jansons](https://github.com/iegik) | [](https://gitlocalize.com/repo/2513/lv?utm_source=badge) |
-| [🇮🇷 فارسی / Persian](./translations/fa.md) | [MohammadErfan Gooneh](https://github.com/MEgooneh) | . |
-| [🇵🇱 Polski / Polish](./translations/pl.md) | [Mariusz Kogen](https://github.com/k0gen) | [](https://gitlocalize.com/repo/2513/pl?utm_source=badge) |
-| [🇷🇺 Русская версия / Russian](https://github.com/solarrust/hacker-laws) | [Alena Batitskaya](https://github.com/solarrust) | Partially complete |
-| [🇪🇸 Castellano / Spanish](./translations/es-ES.md) | [Manuel Rubio](https://github.com/manuel-rubio) ([Sponsor](https://github.com/sponsors/manuel-rubio)) | Partially complete |
-| [🇹🇷 Türkçe / Turkish](https://github.com/umutphp/hacker-laws-tr) | [Umut Işık](https://github.com/umutphp) | [](https://gitlocalize.com/repo/2513/tr?utm_source=badge) |
-| [🇺🇦 українська мова / Ukrainian](./translations/uk.md) | [Nazar](https://github.com/troyane), [Helga Lastivka](https://github.com/HelgaLastivka) | [](https://gitlocalize.com/repo/2513/uk?utm_source=badge) |
-| [🇻🇳 Tiếng Việt / Vietnamese](./translations/vu.md) | [Nguyên](https://github.com/truonghoangnguyen), [Trương Hoàng](https://github.com/truonghoangnguyen) | [](https://gitlocalize.com/repo/2513/vi?utm_source=badge) |
-
-If you would like to update a translation, follow the [Translators Contributor Guide](https://github.com/dwmkerr/hacker-laws/blob/main/.github/contributing.md#translations).
-
-## Related Projects
-
-- [Tip of the Day](https://tips.darekkay.com/html/hacker-laws-en.html) - Receive a daily hacker law/principle.
-- [Hacker Laws CLI](https://github.com/umutphp/hacker-laws-cli) - List, view and see random laws from the terminal!
-- [Hacker Laws Action](https://github.com/marketplace/actions/hacker-laws-action) - Adds a random Hacker Law to a pull request as a small gift for the contributor, thanks [Umut Işık](https://github.com/umutphp)
-
-## Contributing
-
-Please do contribute! [Raise an issue](https://github.com/dwmkerr/hacker-laws/issues/new) if you'd like to suggest an addition or change, or [Open a pull request](https://github.com/dwmkerr/hacker-laws/compare) to propose your own changes.
-
-Please be sure to read the [Contributing Guidelines](./.github/contributing.md) for requirements on text, style and so on. Please be aware of the [Code of Conduct](./.github/CODE_OF_CONDUCT.md) when engaging in discussions on the project.
-
-## TODO
-
-Hi! If you land here, you've clicked on a link to a topic I've not written up yet, sorry about this - this is work in progress!
-
-Feel free to [Raise an Issue](https://github.com/dwmkerr/hacker-laws/issues) requesting more details, or [Open a Pull Request](https://github.com/dwmkerr/hacker-laws/pulls) to submit your proposed definition of the topic.
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..4403d61
--- /dev/null
+++ b/makefile
@@ -0,0 +1,22 @@
+default: help
+
+.PHONY: help
+help: # Show help for each of the Makefile recipes.
+ @grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done
+
+.PHONY: prepare-markdown
+prepare-markdown: # Prepare the markdown for PDF output.
+ ./scripts/prepare-markdown-for-ebook.sh "README.md" "hacker-laws.md"
+
+.PHONY: create-pdf
+create-pdf: # Create the PDF.
+ docker run --rm \
+ --platform linux/amd64 \
+ -v ${PWD}:/data \
+ pandoc/latex:3.6 \
+ -V toc-title:"Table Of Contents" \
+ --toc \
+ --pdf-engine=lualatex \
+ --standalone \
+ --output hacker-laws.pdf \
+ hacker-laws.md
diff --git a/scripts/prepare-markdown-for-ebook.sh b/scripts/prepare-markdown-for-ebook.sh
index 4a0171f..cb5dbe0 100755
--- a/scripts/prepare-markdown-for-ebook.sh
+++ b/scripts/prepare-markdown-for-ebook.sh
@@ -1,32 +1,33 @@
#!/usr/bin/env bash
-# This script prepares a `hacker-laws.md` file for export to PDF or e-book format.
-# Require a version number and get the current date.
-version=$1
-date=$(date "+%Y-%m-%d")
+# Fail on errors.
+set -e -o pipefail
-if [ -z "$version" ]; then
- echo "Usage: $0