Update Actions and deploy using the configured Pages URL
CI / test (3.9) (push) Canceled after 0s
CI / test (3.x) (push) Canceled after 0s
Pages / build (push) Canceled after 0s
Pages / deploy (push) Canceled after 0s

This commit is contained in:
MeghdadFadaee committed 2026-11-04 21:59:48 +03:30
1 parent 1a445e94a3
commit 4902720c80
6 files changed
+64 -18

No files matched your search

+13 -5
View File
@@ -6,10 +6,11 @@ import hashlib
import io
import json
from pathlib import Path
import shutil
import re
import tarfile
ROOT = Path(__file__).resolve().parents[1]
DEFAULT_SITE_URL = 'https://meghdadfadaee.github.io/shell-gleam'
PACKAGE_FILES = (
'setup.sh', 'deploy.sh', 'README.md', 'LICENSE', 'VERSION',
'src/server_status.py', 'src/install.py', 'config/default.json',
@@ -19,12 +20,19 @@ ASSETS = ('index.html', 'style.css', 'app.js', 'favicon.svg', 'social.svg')
def build(output, site_url):
site_url = site_url.rstrip('/')
if not re.fullmatch(r'https?://[A-Za-z0-9.-]+(?::[0-9]+)?(?:/[A-Za-z0-9._~%-]+)*', site_url):
raise ValueError('site URL must be an HTTP(S) origin with an optional path')
# Pages can report HTTP when HTTPS enforcement is disabled, even when TLS works.
# Remote installation always uses verified HTTPS.
site_url = re.sub(r'^http:', 'https:', site_url)
output = Path(output).resolve()
if output == ROOT or ROOT.is_relative_to(output):
raise ValueError('output must not contain the source repository')
output.mkdir(parents=True, exist_ok=True)
for name in ASSETS:
shutil.copyfile(ROOT / 'site' / name, output / name)
source = (ROOT / 'site' / name).read_text()
(output / name).write_text(source.replace(DEFAULT_SITE_URL, site_url))
(output / '.nojekyll').write_text('')
buffer = io.BytesIO()
with gzip.GzipFile(fileobj=buffer, mode='wb', filename='', mtime=0) as compressed:
@@ -45,12 +53,12 @@ def build(output, site_url):
(output / 'downloads').mkdir(exist_ok=True)
(output / artifact).write_bytes(data)
(output / 'downloads/SHA256SUMS').write_text(digest + ' ' + Path(artifact).name + '\n')
template = (ROOT / 'scripts/bootstrap.sh').read_text()
template = (ROOT / 'scripts/bootstrap.sh').read_text().replace(DEFAULT_SITE_URL, site_url)
installer = template.replace('@@SHA256@@', digest).replace('@@ARCHIVE@@', artifact).replace('@@SITE_URL@@', site_url.rstrip('/'))
(output / 'setup.sh').write_text(installer)
(output / 'setup.sh').chmod(0o755)
manifest = {'name': 'shell-gleam', 'version': (ROOT / 'VERSION').read_text().strip(),
'archive': artifact, 'sha256': digest, 'files': list(PACKAGE_FILES)}
'site_url': site_url, 'archive': artifact, 'sha256': digest, 'files': list(PACKAGE_FILES)}
(output / 'release.json').write_text(json.dumps(manifest, indent=2) + '\n')
print('Built ShellGleam site: ' + str(output))
return manifest
@@ -59,6 +67,6 @@ def build(output, site_url):
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--output', type=Path, default=ROOT / '_site')
parser.add_argument('--site-url', default='https://meghdadfadaee.github.io/shell-gleam')
parser.add_argument('--site-url', default=DEFAULT_SITE_URL)
args = parser.parse_args()
build(args.output, args.site_url)