1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # soil/sourcehut.sh <function name>
|
5 |
|
6 | set -o nounset
|
7 | set -o pipefail
|
8 | set -o errexit
|
9 |
|
10 | # Relevant docs:
|
11 | #
|
12 | # https://man.sr.ht/tutorials/getting-started-with-builds.md
|
13 | # https://man.sr.ht/builds.sr.ht/#secrets
|
14 | # https://man.sr.ht/builds.sr.ht/compatibility.md
|
15 | #
|
16 | # Basically, it supports up to 4 files called .builds/*.yml.
|
17 | # And we need to upload an SSH key as secret via the web UI.
|
18 |
|
19 | keygen() {
|
20 | ssh-keygen -t rsa -b 4096 -C "andyc sr.ht" -f rsa_srht
|
21 | }
|
22 |
|
23 | #
|
24 | # Run remotely
|
25 | #
|
26 |
|
27 | publish-html-assuming-ssh-key() {
|
28 | local job_name=$1
|
29 |
|
30 | if true; then
|
31 | soil/web-worker.sh deploy-job-results 'srht-' $JOB_ID $job_name JOB_ID JOB_URL
|
32 | else
|
33 | soil/web-worker.sh deploy-test-wwz # dummy data that doesn't depend on the build
|
34 | fi
|
35 |
|
36 | local commit_hash
|
37 | # written by save-metadata in soil/worker.sh
|
38 | commit_hash=$(cat _tmp/soil/commit-hash.txt)
|
39 |
|
40 | # Note: the directory structure will be overlapping, unlike Github which has
|
41 | # GITHUB_RUN_NUMBER
|
42 | #
|
43 | # srht-jobs/
|
44 | # 1234/foo.wwz # individual jobs
|
45 | # 1235/bar.wwz
|
46 | # git-0101abab/index.html # commit hash
|
47 |
|
48 | time soil/web-worker.sh remote-event-job-done 'srht-' "git-$commit_hash"
|
49 | }
|
50 |
|
51 | #
|
52 | # For create-cache.yml
|
53 | #
|
54 |
|
55 | compress-dir() {
|
56 | local dir=$1
|
57 |
|
58 | local out_dir=_tmp/deps-cache
|
59 | mkdir -p $out_dir
|
60 |
|
61 | local name=$(basename $dir)
|
62 |
|
63 | local out=$out_dir/$name.tar.xz
|
64 |
|
65 | log "Compressing $dir -> $out"
|
66 |
|
67 | tar --create --xz --file $out $dir
|
68 | ls -l $out
|
69 | }
|
70 |
|
71 | compress-deps() {
|
72 | ### Compress output of tarball-deps and spec-deps
|
73 |
|
74 | compress-dir _deps/cpython-full
|
75 | compress-dir _deps/re2c-1.0.3
|
76 | compress-dir _deps/cmark-0.29.0
|
77 |
|
78 | compress-dir _deps/spec-bin
|
79 | }
|
80 |
|
81 | "$@"
|