Deploy script and links to IPFS

This commit is contained in:
Suzanne Soy 2021-07-09 03:55:37 +01:00
parent 68a1a5c9ca
commit 8ec0f8bb01
3 changed files with 70 additions and 5 deletions

46
deploy.sh Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -euET -o pipefail
usage() {
printf 'Usage: ./deploy.sh v1'\\n
printf ' v1 will be used as the tag name for this version'\\n
}
if [ $# -ne 1 ]; then usage; exit 1; fi
if [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ]; then usage; exit 1; fi
# e.g. v1
version="$1"
commit_hash="$(git log --format=%H -1 HEAD)"
tempdir="$(mktemp -d)"
tempdirgit="$(mktemp -d)"
this_repo="$PWD"
printf "Temporary directory: %s"\\n "$tempdir"
# Clone this specific commit (could use a worktree, but I prefer not modifying the original repo if it can be avoided)
git init "$tempdir"
(cd "$tempdir"; git fetch --depth=1 "$this_repo" "$commit_hash")
(cd "$tempdir"; git checkout "$commit_hash")
(cd "$tempdir"; git log)
(set -x; mv "$tempdir/.git" "$tempdirgit/")
ls -a "$tempdir"
if ! grep '<a id="this-version" href="https://github.com/jsmaniac/git-tutorial/tree/'"$version"'">'"$version"'</a>' "$tempdir/index.html"; then
printf "Error: The version number given on the command-line does not match the one in the HTML source code."\\n
exit 1
fi
# Add to IPFS and get the hash
ipfs_hash="$(ipfs add --pin=true --recursive --hidden --progress --quieter "$tempdir")"
ipfs_hash="$(ipfs cid base32 "$ipfs_hash")"
printf \\n
printf %s\\n "$ipfs_hash"
ipfs name publish --key=git-tutorial "/ipfs/$ipfs_hash"
sed -i -e 's~ipfs-this-hash-placeholder" href="#"~ipfs-this-hash-placeholder" href="ipfs://'"$ipfs_hash"'/"~' index.html
git commit -m 'Stored IPFS hash of this version' index.html
git tag "$1"
git tag "ipfs-$1-${ipfs_hash}"

View File

@ -149,4 +149,6 @@ article#git-tutorial .onlytoc { display: none; }
#git-tutorial input[type='button'] { display: inline-block; margin-top: 0.2em; } #git-tutorial input[type='button'] { display: inline-block; margin-top: 0.2em; }
#git-tutorial .dep-license { display: none; font-size: 80%; width: 100%; overflow-x: auto; } #git-tutorial .dep-license { display: none; font-size: 80%; width: 100%; overflow-x: auto; }
#git-tutorial .article-metadata { color: #333; font-style: italic; } #git-tutorial .article-metadata { color: #333; font-style: italic; }
#git-tutorial .filename { font-family: monospace; }

View File

@ -4,6 +4,15 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" lang="en-GB" xml:lang="en-GB" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" lang="en-GB" xml:lang="en-GB" />
<title>GIT tutorial</title> <title>GIT tutorial</title>
<!-- Replace the "ipfs://…" string below with "#" to obtain the original copy as hosted on IPFS. -->
<link rel="canonical" class="ipfs-this-hash-placeholder" href="#" />
<link rel="alternate" href="https://suzanne.soy/git-tutorial/" />
<!-- These rel="duplicate" links use an HTML encoding of the rfc6249 Metalink/HTTP -->
<!-- Replace the "ipfs://…" string below with "#" to obtain the original copy as hosted on IPFS. -->
<link rel="duplicate" class="ipfs-this-hash-placeholder" href="#" />
<link rel="duplicate" href="https://suzanne.soy/git-tutorial/" />
<!-- Third-party libraries: --> <!-- Third-party libraries: -->
<link rel="stylesheet" href="codemirror-5.60.0/lib/codemirror.css"> <link rel="stylesheet" href="codemirror-5.60.0/lib/codemirror.css">
<script src="codemirror-5.60.0/lib/codemirror.js"></script> <script src="codemirror-5.60.0/lib/codemirror.js"></script>
@ -44,7 +53,14 @@ function ___example(id, f) {
<a href="#" class="permalink"><h1 itemprop="headline">Git tutorial: reimplementing part of GIT in JavaScript</h1></a> <a href="#" class="permalink"><h1 itemprop="headline">Git tutorial: reimplementing part of GIT in JavaScript</h1></a>
<p class="article-metadata">By <a href="https://suzanne.soy/" itemprop="author" rel="author" itemscope="itemscope" itemtype="https://schema.org/Person">Suzanne Soy</a> for <a href="https://ligolang.org/" itemprop="copyrightHolder" itemscope="itemscope" itemtype="https://schema.org/Organization">LIGO</a>. <time itemprop="dateCreated datePublished" datetime="2021-06-29">02021-06-29</time>.</p> <p class="article-metadata">By <a href="https://suzanne.soy/" itemprop="author" rel="author" itemscope="itemscope" itemtype="https://schema.org/Person">Suzanne Soy</a> for <a href="https://ligolang.org/" itemprop="copyrightHolder" itemscope="itemscope" itemtype="https://schema.org/Organization">LIGO</a>. <time itemprop="dateCreated datePublished" datetime="2021-06-29">02021-06-29</time>.</p>
<p>Please send remarks and suggestions to <a href="mailto:git-tutorial@suzanne.soy">git-tutorial@suzanne.soy</a> or simply fork <a href="https://github.com/jsmaniac/git-tutorial">this repository on GitHub</a></p> <p>Please send remarks and suggestions to <a href="mailto:git-tutorial@suzanne.soy">git-tutorial@suzanne.soy</a> or simply fork <a href="https://github.com/jsmaniac/git-tutorial">this repository on GitHub</a>.</p>
<p>This version of the site matches the tag <a id="this-version" href="https://github.com/jsmaniac/git-tutorial/tree/v1">v1</a> on GitHub.
You can access snapshots of this site via IPFS:
<!-- Replace the "ipfs://…" string below with "#" to obtain the original copy as hosted on IPFS. -->
<a class="ipfs-this-hash-placeholder" href="#" title="published shortly after 02021-06-29">v1 (permalink)</a>,
or check the
<a href="ipns://k51qzi5uqu5dggo2mzf6enn9dpcb2qmd4t9tipend4ikqvvmljo6i63lae4soy/">latest version via IPNS/IPFS</a> or
<a href="https://suzanne.soy/git-tutorial/">via HTTPS</a>.</p>
<section id="credits-license"> <section id="credits-license">
<h2>Credits and license</h2> <h2>Credits and license</h2>
@ -863,9 +879,10 @@ END OF TERMS AND CONDITIONS
<p>In order to encourage people to write their own implementation of a version control system, <p>In order to encourage people to write their own implementation of a version control system,
and improve upon the state of the art, the contents of this tutorial (the files and improve upon the state of the art, the contents of this tutorial (the files
<a href="index.html">index.html</a>, <a href="git-tutorial.js">git-tutorial.js</a>, <a class="filename" href="index.html">index.html</a>, <a class="filename" href="git-tutorial.js">git-tutorial.js</a>,
<a href="git-tutorial.css">git-tutorial.css</a> and <a href="README">README</a>) <a class="filename" href="git-tutorial.css">git-tutorial.css</a>, <a class="filename" href="deploy.sh">deploy.sh</a>
and the GIT implementation within are dedicated to the Public Domain, using the and <a class="filename" href="README">README</a>, including the GIT implementation contained within) are dedicated
to the Public Domain, using the
<a href="https://creativecommons.org/publicdomain/zero/1.0/">Creative Commons CC0 1.0 Universal (CC0 1.0) Public Domain Dedication</a>.</p> <a href="https://creativecommons.org/publicdomain/zero/1.0/">Creative Commons CC0 1.0 Universal (CC0 1.0) Public Domain Dedication</a>.</p>
<p>The intent is to enable everyone to freely reuse and share part or all of this material under any license, including the CC0, the <p>The intent is to enable everyone to freely reuse and share part or all of this material under any license, including the CC0, the