Skip to content

Commit

Permalink
chore: Refactor website to use 11ty
Browse files Browse the repository at this point in the history
  • Loading branch information
rradczewski committed May 28, 2024
1 parent 9fb6afc commit 2eb7ec9
Show file tree
Hide file tree
Showing 17 changed files with 3,331 additions and 344 deletions.
12 changes: 11 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Go",
"image": "mcr.microsoft.com/devcontainers/go:1.22",
"onCreateCommand": "go get && go mod download && make smoke"
"onCreateCommand": "go get && go mod download && make smoke",
"features": {
"ghcr.io/devcontainers/features/node:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode"
]
}
}
}
22 changes: 19 additions & 3 deletions .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,36 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: website/
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v2
with:
node-version-file: './website/.nvmrc'
cache: 'npm'
cache-dependency-path: './website/package-lock.json'

- name: Bump version in package.json
run: npm pkg set version "${{ steps.trunkver.outputs.trunkver }}"

- name: Generate trunkver
id: trunkver
uses: crftd-tech/trunkver@main
- name: Write trunkver to file
run: echo ${{ steps.trunkver.outputs.trunkver }} > website/version.txt
- name: Install dependencies
run: npm ci
- name: Build website
run: npm run build

- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'website/'
path: 'website/_site/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
11 changes: 11 additions & 0 deletions website/.eleventy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const prismCss = require.resolve("prismjs/themes/prism.css");

const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");

module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPassthroughCopy({
[prismCss]: "prism.css",
"style.css": "style.css",
});
};
1 change: 1 addition & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
1 change: 1 addition & 0 deletions website/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/iron
32 changes: 32 additions & 0 deletions website/_includes/hero.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% assign version = pkg.version | split: "-" %} {% assign timestamp = version |
first %} {% assign sourceRef = version[1] %} {% assign buildRef = version |
slice: 2, version.size | join: "-" %}

<div class="hero">
<div class="hero-grid">
<div class="version timestamp">{{ timestamp }}</div>
<div class="version grid-spacer">-</div>
<div class="version source-ref">
<a href="https://github.com/crftd-tech/trunkver/commit/{{ sourceRef }}"
>{{ sourceRef }}</a
>
</div>
<div class="version grid-spacer">-</div>
<div class="version build-ref">
<a
href="https://github.com/crftd-tech/trunkver/actions/runs/{{ buildRef | split: '-' | first }}/attempts/{{ buildRef | split: '-' | last }}"
>{{ buildRef }}</a
>
</div>
<div class="description timestamp">When it was built</div>
<div class="description grid-spacer">&nbsp;</div>
<div class="description source-ref">What was built</div>
<div class="description grid-spacer">&nbsp;</div>
<div class="description build-ref">How it was built</div>
<div class="code timestamp">date -u +%Y%m%d%H%M%S</div>
<div class="code grid-spacer">&nbsp;</div>
<div class="code source-ref">git rev-parse --short HEAD</div>
<div class="code grid-spacer">&nbsp;</div>
<div class="code build-ref">${CI_JOB_ID}</div>
</div>
</div>
22 changes: 22 additions & 0 deletions website/_includes/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>trunkVer</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="prism.css" />
</head>
<body>
<div class="content">
{{ content }}
<div class="spacer"></div>
<footer>
Made with 🧡 for people &amp; tech, and disregard for busy-work by
<a href="https://crftd.tech">crafted. tech collective</a>.
<br/><small><code>Version: {{ pkg.version }}</code></small>
</footer>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions website/_site/includes/hero/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="hero">
<div class="hero-grid">
<div class="version timestamp">20240527125612.0.0</div>
<div class="version grid-spacer">-</div>
<div class="version source-ref">g13866bd</div>
<div class="version grid-spacer">-</div>
<div class="version build-ref">9253259568</div>
<div class="description timestamp">When it was built</div>
<div class="description grid-spacer">&nbsp;</div>
<div class="description source-ref">What was built</div>
<div class="description grid-spacer">&nbsp;</div>
<div class="description build-ref">How it was built</div>
<div class="code timestamp">date -u +%Y%m%d%H%M%S</div>
<div class="code grid-spacer">&nbsp;</div>
<div class="code source-ref">git rev-parse --short HEAD</div>
<div class="code grid-spacer">&nbsp;</div>
<div class="code build-ref">${CI_JOB_ID}</div>
</div>
</div>
94 changes: 94 additions & 0 deletions website/_site/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>trunkVer</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="prism.css" />
</head>
<body>
<div class="content">
<h1><span class="logo">trunkVer</span></h1>
<p>so we can stop talking about versions and start shipping.</p>
<div class="spacer"></div>
<div class="hero">
<div class="hero-grid">
<div class="version timestamp">0.0.0</div>
<div class="version grid-spacer">-</div>
<div class="version source-ref">
<a href="https://github.com/crftd-tech/trunkver/commit/HEAD"
>HEAD</a
>
</div>
<div class="version grid-spacer">-</div>
<div class="version build-ref">
<a
href="https://github.com/crftd-tech/trunkver/actions/runs/local/attempts/local"
>local</a
>
</div>
<div class="description timestamp">When it was built</div>
<div class="description grid-spacer">&nbsp;</div>
<div class="description source-ref">What was built</div>
<div class="description grid-spacer">&nbsp;</div>
<div class="description build-ref">How it was built</div>
<div class="code timestamp">date -u +%Y%m%d%H%M%S</div>
<div class="code grid-spacer">&nbsp;</div>
<div class="code source-ref">git rev-parse --short HEAD</div>
<div class="code grid-spacer">&nbsp;</div>
<div class="code build-ref">${CI_JOB_ID}</div>
</div>
</div>
<h2>TL;DR</h2>
<p><code>trunkVer</code> is a semVer-compatible versioning scheme for
trunk-based applications and systems that don't follow a release scheme.</p>
<p>It removes the chore of manually bumping version numbers and instead
enriches the version number with three important data points: The
<strong>when</strong>, <strong>what</strong> and <strong>how</strong>.</p>
<h2>Usage</h2>
<h3>GitHub Actions</h3>
<pre class="language-yaml"><code class="language-yaml"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Generate trunkver
<span class="token key atrule">id</span><span class="token punctuation">:</span> trunkver
<span class="token key atrule">uses</span><span class="token punctuation">:</span> crftd<span class="token punctuation">-</span>tech/trunkver@main

<span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Print trunkver
<span class="token key atrule">env</span><span class="token punctuation">:</span>
<span class="token key atrule">TRUNKVER</span><span class="token punctuation">:</span> $
<span class="token key atrule">run</span><span class="token punctuation">:</span> <span class="token punctuation">|</span><span class="token scalar string">
echo "$TRUNKVER"</span></code></pre>
<h3>Docker</h3>
<pre class="language-sh"><code class="language-sh"><span class="token function">docker</span> run ghcr.io/crftd-tech/trunkver:latest --build-ref <span class="token string">"<span class="token variable">$CI_JOB_ID</span>"</span> --source-ref <span class="token string">"g<span class="token variable"><span class="token variable">$(</span><span class="token function">git</span> rev-parse <span class="token parameter variable">--short</span> HEAD<span class="token variable">)</span></span>"</span></code></pre>
<h3>Other CIs</h3>
<pre class="language-sh"><code class="language-sh"><span class="token function">curl</span> <span class="token parameter variable">-sSL</span> https://github.com/crftd-tech/trunkver/releases/latest/download/trunkver_linux_amd64 <span class="token parameter variable">-o</span> trunkver
<span class="token function">chmod</span> +x trunkver
./trunkver</code></pre>
<h2>FAQ</h2>
<ul>
<li>
<p><strong>Why only use the MAJOR semVer part as a timestamp?</strong><br>
Tools (e.g. compliance, audit trails) might still classify a version based on semVer semantics, hence trunkVer always defensively implies breaking changes between versions.</p>
</li>
<li>
<p><strong>Why do you use the PRERELEASE semVer part for source information and not build?</strong><br>
Because OCI tags don't support <code>+</code> (see <a href="https://github.com/distribution/distribution/issues/1201">distribution/distribution#1201</a> and <a href="https://github.com/opencontainers/distribution-spec/issues/154">opencontainers/distribution-spec#154</a>. We'd rather have one consistent version across artifacts. Semantically, the only relevant portion for sorting of a trunkVer is
the MAJOR version, and a conflict (as in creating two artifacts in the
very same second) should be avoided.</p>
</li>
</ul>
<h2>Links</h2>
<ul>
<li><a href="https://github.com/crftd-tech/trunkver">https://github.com/crftd-tech/trunkver</a></li>
<li><a href="https://crftd.tech/">https://crftd.tech/</a></li>
</ul>

<div class="spacer"></div>
<footer>
Made with 🧡 for people &amp; tech, and disregard for busy-work by
<a href="https://crftd.tech">crafted. tech collective</a>.
<br/><small><code>Version: 0.0.0-HEAD-local</code></small>
</footer>
</div>
</body>
</html>
140 changes: 140 additions & 0 deletions website/_site/prism.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/

code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;

-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;

-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}

pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}

pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}

@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}

/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}

:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}

.token.punctuation {
color: #999;
}

.token.namespace {
opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #9a6e3a;
/* This background color was intended by the author of this theme. */
background: hsla(0, 0%, 100%, .5);
}

.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}

.token.function,
.token.class-name {
color: #DD4A68;
}

.token.regex,
.token.important,
.token.variable {
color: #e90;
}

.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}

.token.entity {
cursor: help;
}
Loading

0 comments on commit 2eb7ec9

Please sign in to comment.