Add Gitea Actions release workflow and package_dist script for automated shippable releases
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
name: Release Shippables
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.12'
|
||||||
|
|
||||||
|
- name: Assemble Shippables
|
||||||
|
run: |
|
||||||
|
python package_dist.py
|
||||||
|
|
||||||
|
- name: Publish Release
|
||||||
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
dist/*
|
||||||
|
api_key: ${{ secrets.TAG_TOKEN }}
|
||||||
|
token: ${{ secrets.TAG_TOKEN }}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import tarfile
|
||||||
|
import zipfile
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
DIST_DIR = "dist"
|
||||||
|
OUT_DIR = "out"
|
||||||
|
|
||||||
|
def make_zip(source_dir, output_zip):
|
||||||
|
with zipfile.ZipFile(output_zip, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||||
|
for root, _, files in os.walk(source_dir):
|
||||||
|
for file in files:
|
||||||
|
full_path = os.path.join(root, file)
|
||||||
|
rel_path = os.path.relpath(full_path, source_dir)
|
||||||
|
zf.write(full_path, rel_path)
|
||||||
|
|
||||||
|
def make_tar_gz(source_dir, output_tar):
|
||||||
|
with tarfile.open(output_tar, "w:gz") as tf:
|
||||||
|
for root, _, files in os.walk(source_dir):
|
||||||
|
for file in files:
|
||||||
|
full_path = os.path.join(root, file)
|
||||||
|
rel_path = os.path.relpath(full_path, source_dir)
|
||||||
|
tf.add(full_path, arcname=rel_path)
|
||||||
|
|
||||||
|
def generate_checksums(dist_dir):
|
||||||
|
checksum_file = os.path.join(dist_dir, "SHA256SUMS.txt")
|
||||||
|
lines = []
|
||||||
|
for fname in sorted(os.listdir(dist_dir)):
|
||||||
|
if fname == "SHA256SUMS.txt":
|
||||||
|
continue
|
||||||
|
fpath = os.path.join(dist_dir, fname)
|
||||||
|
if os.path.isfile(fpath):
|
||||||
|
with open(fpath, "rb") as f:
|
||||||
|
digest = hashlib.sha256(f.read()).hexdigest()
|
||||||
|
lines.append(f"{digest} {fname}")
|
||||||
|
with open(checksum_file, "w", encoding="utf-8") as f:
|
||||||
|
f.write("\n".join(lines) + "\n")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.makedirs(DIST_DIR, exist_ok=True)
|
||||||
|
|
||||||
|
server_src = os.path.join(OUT_DIR, "server")
|
||||||
|
win_src = os.path.join(OUT_DIR, "win_client")
|
||||||
|
linux_src = os.path.join(OUT_DIR, "linux_client")
|
||||||
|
|
||||||
|
print("[*] Packaging Server shippable...")
|
||||||
|
make_tar_gz(server_src, os.path.join(DIST_DIR, "logar-server.tar.gz"))
|
||||||
|
make_zip(server_src, os.path.join(DIST_DIR, "logar-server.zip"))
|
||||||
|
|
||||||
|
print("[*] Packaging Windows Client shippable...")
|
||||||
|
make_zip(win_src, os.path.join(DIST_DIR, "logar-win-client.zip"))
|
||||||
|
|
||||||
|
print("[*] Packaging Linux Client shippable...")
|
||||||
|
make_tar_gz(linux_src, os.path.join(DIST_DIR, "logar-linux-client.tar.gz"))
|
||||||
|
|
||||||
|
print("[*] Generating SHA-256 checksums...")
|
||||||
|
generate_checksums(DIST_DIR)
|
||||||
|
|
||||||
|
print(f"[+] All release artifacts assembled in '{DIST_DIR}/':")
|
||||||
|
for f in os.listdir(DIST_DIR):
|
||||||
|
sz = os.path.getsize(os.path.join(DIST_DIR, f))
|
||||||
|
print(f" - {f} ({sz} bytes)")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user