From 4776d73a52c14de291a33c27dfe741c34ace9ff8 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 09:39:09 +0200 Subject: [PATCH 1/4] Remove git dependency for stable rebuilds --- .gitignore | 1 + scripts/authors.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1ba24b87..af701185 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ compiler/**/*.js .*.generated.ts .tmp/ .DS_Store +.build_cache/ diff --git a/scripts/authors.sh b/scripts/authors.sh index d0d9ead4..415d1d84 100755 --- a/scripts/authors.sh +++ b/scripts/authors.sh @@ -4,10 +4,18 @@ set -e err() { echo "error: line $(caller)"; } trap err ERR +mkdir -p .build_cache cd src/static authors="../../build/static/authors.html" sed "/REPLACETHIS/,$ d" authors.html > "$authors" -git shortlog -sn HEAD | cut -c8- | awk '!seen[$0]++' | sed 's/^/

/' | sed 's/$/<\/p>/' >> "$authors" + +# If we're in a git repo, refresh the cache +if [ -d "../../.git/" ]; then + git shortlog -sn HEAD | cut -c8- | awk '!seen[$0]++' | sed 's/^/

/' | sed 's/$/<\/p>/' > ../../.build_cache/authors +fi + +cat ../../.build_cache/authors >> "$authors" + sed "1,/REPLACETHIS/ d" authors.html >> "$authors" From c9d9fb8edc3cec521194ede2fddb7135ac5275c1 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 10:05:15 +0200 Subject: [PATCH 2/4] Remove git dependency for beta rebuilds --- scripts/version.js | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/scripts/version.js b/scripts/version.js index d153ab1b..301e1aaf 100755 --- a/scripts/version.js +++ b/scripts/version.js @@ -1,6 +1,7 @@ #!/usr/bin/env node const { exec } = require("child_process") +const fs = require("fs") function bump_version(versionstr, component = 2) { const versionarr = versionstr.split(".") @@ -12,21 +13,37 @@ function bump_version(versionstr, component = 2) { } async function add_beta(versionstr) { - return new Promise((resolve, err) => { - exec("git rev-list --count HEAD", (execerr, stdout, stderr) => { - if (execerr) err(execerr) - resolve(versionstr + "pre" + stdout.trim()) + await fs.promises.mkdir(".build_cache", {recursive: true}) + try { + await fs.promises.access(".git") + await new Promise((resolve, err) => { + exec("git rev-list --count HEAD > .build_cache/count", (execerr, stdout, stderr) => { + if (execerr) err(execerr) + resolve(stdout.trim()) + }) }) - }) + } + catch { + ; // Not in a git directory - don't do anything + } + return versionstr + "pre" + (await fs.promises.readFile(".build_cache/count", {encoding: "utf8"})).trim() } async function get_hash() { - return new Promise((resolve, err) => { - exec("git rev-parse --short HEAD", (execerr, stdout, stderr) => { - if (execerr) err(execerr) - resolve(stdout.trim()) + await fs.promises.mkdir(".build_cache", {recursive: true}) + try { + await fs.promises.access(".git") + await new Promise((resolve, err) => { + exec("git rev-parse --short HEAD > .build_cache/hash", (execerr, stdout, stderr) => { + if (execerr) err(execerr) + resolve(stdout.trim()) + }) }) - }) + } + catch { + ; // Not in a git directory - don't do anything + } + return (await fs.promises.readFile(".build_cache/hash", {encoding: "utf8"})).trim() } function make_update_json(versionstr) { @@ -102,7 +119,7 @@ async function main() { make_update_json(manifest.version), ) } catch(e) { - console.warn("updates.json wasn't updated: " + e) + console.warn("Unless you're the buildbot, ignore this error: " + e) } // Save manifest.json From c68e1a59d6dbf75bb75294f066f99f1d9ebb7be2 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 10:42:34 +0200 Subject: [PATCH 3/4] Reduce source archive size For stable and add beta source archive --- scripts/sign | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/sign b/scripts/sign index 194c3187..54926f72 100755 --- a/scripts/sign +++ b/scripts/sign @@ -23,6 +23,7 @@ publish_beta() { scripts/version.js beta sed 's/"name": "Tridactyl"/"name": "Tridactyl: Beta"/' -i build/manifest.json sign_and_submit + tar --exclude-from=<(cat .gitignore | grep -v .build_cache/) --exclude-vcs -czf ../../public_html/betas/tridactyl_source_beta.tar.gz . } build_no_sign_beta(){ @@ -53,7 +54,7 @@ publish_stable() { yarn run build --no-native sed 's/tridactyl.vim.betas@cmcaine/tridactyl.vim@cmcaine/' -i build/manifest.json sign_and_submit - tar --exclude-from=.gitignore -czf ../../public_html/betas/tridactyl_source.tar.gz . + tar --exclude-from=<(cat .gitignore | grep -v .build_cache/) --exclude-vcs -czf ../../public_html/betas/tridactyl_source.tar.gz . } case $1 in From d74a4b9d4ba073b043a838a58766e763f23b84ae Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 10:47:11 +0200 Subject: [PATCH 4/4] Cheer up shellcheck --- scripts/sign | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/sign b/scripts/sign index 54926f72..25bf30c3 100755 --- a/scripts/sign +++ b/scripts/sign @@ -4,7 +4,7 @@ set -e sign_and_submit() { # Don't trust the return value of web-ext sign. - (source AMOKEYS && (web-ext sign -s build --api-key $AMOKEY --api-secret $AMOSECRET "$@" || true)) + (source AMOKEYS && (yarn run web-ext sign -s build --api-key "$AMOKEY" --api-secret "$AMOSECRET" "$@" || true)) } publish_beta_nonewtab() { @@ -23,7 +23,7 @@ publish_beta() { scripts/version.js beta sed 's/"name": "Tridactyl"/"name": "Tridactyl: Beta"/' -i build/manifest.json sign_and_submit - tar --exclude-from=<(cat .gitignore | grep -v .build_cache/) --exclude-vcs -czf ../../public_html/betas/tridactyl_source_beta.tar.gz . + tar --exclude-from=<(.grep -v .build_cache/ .gitignore) --exclude-vcs -czf ../../public_html/betas/tridactyl_source_beta.tar.gz . } build_no_sign_beta(){ @@ -32,9 +32,9 @@ build_no_sign_beta(){ scripts/version.js beta sed 's/"name": "Tridactyl"/"name": "Tridactyl: Beta"/' -i build/manifest.json mkdir -p web-ext-artifacts - $(yarn bin)/web-ext build --source-dir ./build --overwrite-dest + yarn run web-ext build --source-dir ./build --overwrite-dest for f in web-ext-artifacts/*.zip; do - mv $f ${f%.zip}.xpi + mv "$f" "${f%.zip}".xpi done } @@ -43,9 +43,9 @@ build_no_sign_stable(){ yarn run build --no-native sed 's/tridactyl.vim.betas@cmcaine/tridactyl.vim@cmcaine/' -i build/manifest.json mkdir -p web-ext-artifacts - $(yarn bin)/web-ext build --source-dir ./build --overwrite-dest + yarn run web-ext build --source-dir ./build --overwrite-dest for f in web-ext-artifacts/*.zip; do - mv $f ${f%.zip}.xpi + mv "$f" "${f%.zip}".xpi done } @@ -54,7 +54,7 @@ publish_stable() { yarn run build --no-native sed 's/tridactyl.vim.betas@cmcaine/tridactyl.vim@cmcaine/' -i build/manifest.json sign_and_submit - tar --exclude-from=<(cat .gitignore | grep -v .build_cache/) --exclude-vcs -czf ../../public_html/betas/tridactyl_source.tar.gz . + tar --exclude-from=<(grep -v .build_cache/ .gitignore) --exclude-vcs -czf ../../public_html/betas/tridactyl_source.tar.gz . } case $1 in @@ -62,5 +62,6 @@ case $1 in nosignstable) build_no_sign_stable;; nosignbeta) build_no_sign_beta;; nonewtab) publish_beta_nonewtab;; - *|beta) publish_beta;; + beta) publish_beta;; + *) publish_beta;; esac