raz / commit 19bcd2cb

commit
19bcd2cb387b870f1c5c803c77155a4a6c1e8151
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
b217e0c8
site: every release's tarball since 0.7.1, never made again

download/ keeps each release at its own name, so a program's CI can
pin raz by version and SHA-256. A tarball already there is kept as is:
made again it would differ in its dates. The home page lists the
earlier ones.

patch · log

8 files changed, +61 -31

README.md (history) modified +5 -3

@@ -205,9 +205,11 @@
205205 GitHub then builds and checks the tag, and makes a release of it with
206206 a tarball of `raz`, its `lib/` and its manual pages, made by `make
207207 dist`. A tag pushed before the workflow existed is released from the
208-Actions tab: run "ci" with its name. Then `make site` puts the new
209-tag's tarball on the website (it builds it from the tag, apart from
210-the tree at hand); commit `site/public/` and push to publish it.
208+Actions tab: run "ci" with its name. Then `make site` adds the new
209+tag's tarball to the website's `download/` (it builds it from the tag,
210+apart from the tree at hand); commit `site/public/` and push to publish
211+it. Every release since 0.7.1 stays there, at its own name, and is
212+never made again, so that its SHA-256 holds: programs pin raz by it.
211213
212214 A version of the report is named by its month and a count; the report's
213215 last section says what each version changed.

site/build.py modified +46 -26

@@ -7,7 +7,7 @@
77 any web server. Nothing runs in the reader's browser; the code on the
88 tour's pages is run here, by ./raz, and the output shown is what it
99 printed, so a lesson that stops working fails the build. The home page
10-offers the latest release's tarball, made by make dist from the tag.
10+offers every release's tarball, made by make dist from its tag.
1111
1212 Lessons are site/content/<tour>/NN-name.txt, one folder to a tour (see
1313 TOURS below):
@@ -315,33 +315,42 @@
315315 body = '<div class="spec">%s</div>' % p.stdout
316316 write("spec.html", page("The raz report", body, 0, "spec"))
317317
318+# The first release whose tarball the site offers: the first with the
319+# manual, which make dist packs
320+FIRST_RELEASE = "v0.7.1"
321+
318322 def build_download():
319- """The latest release's tarball, in public/download/ with its SHA-256
320- and /download/latest leading to it; (version, file name, SHA-256).
321- It is made of the tag's own checkout, not of the tree at hand, and
322- kept in build/ to be made once."""
323+ """Every release's tarball from FIRST_RELEASE on, in public/download/
324+ with its SHA-256, and /download/latest leading to the newest; a list
325+ of (version, file name, SHA-256), oldest first. A program's CI can
326+ fetch the version it was written for by its name, so none is ever
327+ taken away. Each is made of its tag's own checkout, not of the tree
328+ at hand. One already in public/download/ is kept as it is, never
329+ made again: a new one would differ in its dates, and so its SHA-256,
330+ which a program's CI may check."""
323331 git = lambda *a: subprocess.run(("git", "-C", ROOT) + a, capture_output=True,
324332 text=True, check=True).stdout.strip()
325- tag = git("describe", "--tags", "--abbrev=0", "--match", "v*")
326- name = "raz-%s-linux-x86_64.tar.gz" % tag[1:]
327- made = os.path.join(ROOT, "build", name)
328- if not os.path.exists(made):
329- tree = tempfile.mkdtemp()
330- try:
331- git("worktree", "add", "--detach", tree, tag)
332- subprocess.run(["make", "-s", "-C", ROOT, "dist", "TREE=" + tree],
333- stdout=subprocess.DEVNULL, check=True)
334- finally:
335- git("worktree", "remove", "--force", tree)
336- digest = hashlib.sha256(open(made, "rb").read()).hexdigest()
337- os.makedirs(os.path.join(OUT, "download"))
338- shutil.copy(made, os.path.join(OUT, "download"))
339- write("download/%s.sha256" % name, "%s %s\n" % (digest, name))
333+ releases = []
334+ for tag in git("tag", "-l", "v*", "--sort=v:refname", "--contains", FIRST_RELEASE).split():
335+ name = "raz-%s-linux-x86_64.tar.gz" % tag[1:]
336+ made = os.path.join(OUT, "download", name)
337+ if not os.path.exists(made):
338+ tree = tempfile.mkdtemp()
339+ try:
340+ git("worktree", "add", "--detach", tree, tag)
341+ subprocess.run(["make", "-s", "-C", ROOT, "dist", "TREE=" + tree],
342+ stdout=subprocess.DEVNULL, check=True)
343+ finally:
344+ git("worktree", "remove", "--force", tree)
345+ shutil.copy(os.path.join(ROOT, "build", name), made)
346+ digest = hashlib.sha256(open(made, "rb").read()).hexdigest()
347+ write("download/%s.sha256" % name, "%s %s\n" % (digest, name))
348+ releases.append((tag[1:], name, digest))
340349 # Cloudflare reads _redirects from the root of what it serves
341- write("_redirects", "/download/latest /download/%s 302\n" % name)
342- return tag[1:], name, digest
350+ write("_redirects", "/download/latest /download/%s 302\n" % releases[-1][1])
351+ return releases
343352
344-def build_home(release):
353+def build_home(releases):
345354 snippet = open(os.path.join(HERE, "content", "home.raz"), encoding="utf-8").read()
346355 tmp = tempfile.mkdtemp()
347356 try:
@@ -355,7 +364,10 @@
355364 text = open(os.path.join(HERE, "content", "home.html"), encoding="utf-8").read()
356365 text = text.replace("@SNIPPET@", highlight(snippet.rstrip("\n")))
357366 text = text.replace("@OUTPUT@", html.escape(stdout.rstrip("\n")))
358- version, name, digest = release
367+ version, name, digest = releases[-1]
368+ earlier = ", ".join('<a href="download/%s">%s</a>' % (n, v)
369+ for v, n, _ in reversed(releases[:-1]))
370+ text = text.replace("@EARLIER@", earlier)
359371 text = text.replace("@VERSION@", version).replace("@TARBALL@", name)
360372 text = text.replace("@DIR@", name[:-len(".tar.gz")]).replace("@SHA256@", digest)
361373 write("index.html", page("raz: a small systems language", text, 0, "home"))
@@ -363,8 +375,16 @@
363375 def main():
364376 if not os.path.exists(RAZ):
365377 sys.exit("make raz first")
366- shutil.rmtree(OUT, ignore_errors=True)
367- os.makedirs(OUT)
378+ # everything is made again but the tarballs (see build_download)
379+ for f in os.listdir(OUT) if os.path.exists(OUT) else []:
380+ path = os.path.join(OUT, f)
381+ if f == "download":
382+ continue
383+ elif os.path.isdir(path):
384+ shutil.rmtree(path)
385+ else:
386+ os.remove(path)
387+ os.makedirs(os.path.join(OUT, "download"), exist_ok=True)
368388 shutil.copy(os.path.join(HERE, "style.css"), OUT)
369389 for f in os.listdir(os.path.join(HERE, "assets")): # the logo and icons
370390 if f not in ("social.html", "render.sh"):

site/content/home.html (history) modified +4 -1

@@ -75,5 +75,8 @@
7575 $ raz run Hello.raz</code></pre>
7676 <p>The link works since raz finds <code>lib/</code> beside its real path. The
7777 manual pages are in <code>man/</code>: <code>man ./man/raz-tutorial.7</code>.
78-The address <code>download/latest</code> always leads to the newest release.</p>
78+The address <code>download/latest</code> always leads to the newest release,
79+and <code>download/raz-@VERSION@-linux-x86_64.tar.gz</code> to this one, for
80+good. Earlier releases: @EARLIER@; each has its SHA-256 beside it, with
81+<code>.sha256</code> added to its name.</p>
7982 <p class="sha">SHA-256 <code>@SHA256@</code></p>

site/public/download/raz-0.7.1-linux-x86_64.tar.gz (history) added

Binary file; the patch has it.

site/public/download/raz-0.7.1-linux-x86_64.tar.gz.sha256 (history) added +1 -0

@@ -0,0 +1 @@
1+e3900f480fb559587e16e741d604f3b1b04db0f890c33aa79402574172c44ced raz-0.7.1-linux-x86_64.tar.gz

site/public/download/raz-0.8.0-linux-x86_64.tar.gz (history) added

Binary file; the patch has it.

site/public/download/raz-0.8.0-linux-x86_64.tar.gz.sha256 (history) added +1 -0

@@ -0,0 +1 @@
1+fa1e62fb39cbbcab340b86ac2630687475ad150a4d53bde5bfc4f5fc10149276 raz-0.8.0-linux-x86_64.tar.gz

site/public/index.html (history) modified +4 -1

@@ -121,7 +121,10 @@
121121 $ raz run Hello.raz</code></pre>
122122 <p>The link works since raz finds <code>lib/</code> beside its real path. The
123123 manual pages are in <code>man/</code>: <code>man ./man/raz-tutorial.7</code>.
124-The address <code>download/latest</code> always leads to the newest release.</p>
124+The address <code>download/latest</code> always leads to the newest release,
125+and <code>download/raz-0.9.0-linux-x86_64.tar.gz</code> to this one, for
126+good. Earlier releases: <a href="download/raz-0.8.0-linux-x86_64.tar.gz">0.8.0</a>, <a href="download/raz-0.7.1-linux-x86_64.tar.gz">0.7.1</a>; each has its SHA-256 beside it, with
127+<code>.sha256</code> added to its name.</p>
125128 <p class="sha">SHA-256 <code>c1387747ef3350efb19b35edf2769612fe323ecb08cff34906065b530fc71a09</code></p>
126129
127130 </main>