Template
Product repository template
Layout, proplan.toml, README/CHANGELOG, placeholder product image, .gitignore, KiBot/release/docgen workflows and TEMPLATE.md. Source of truth: contrib/product-template in B4L/proplan (cargo test --test product_template checks it as Gitea 1.27 creates a repository from it).
This commit is contained in:
commit
421b4202cc
24 files changed
+573
No files matched your search
@@ -0,0 +1,57 @@
|
||||
name: Release outputs
|
||||
|
||||
# On a tag v* (a prototype stage): the KiBot outputs of every board, zipped per
|
||||
# board, attached to the tag's release (created when missing). The job token
|
||||
# must be allowed to write releases. Adapted from LVSolarBuck; runs for the
|
||||
# first time at the first tag.
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: kicad10_auto
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: KiBot outputs per board
|
||||
run: |
|
||||
mkdir -p dist
|
||||
for pro in $(find hardware -mindepth 2 -maxdepth 2 -name '*.kicad_pro' | sort); do
|
||||
dir=$(dirname "$pro"); board=$(basename "$dir")
|
||||
(cd "$dir" && kibot -c "$GITHUB_WORKSPACE/kibot.yaml" -d "$GITHUB_WORKSPACE/out/$board") \
|
||||
|| echo "::warning::KiBot reported problems for $board"
|
||||
python3 -c 'import shutil, sys; shutil.make_archive(sys.argv[1], "zip", sys.argv[2])' \
|
||||
"dist/$board-${GITHUB_REF_NAME}" "out/$board"
|
||||
done
|
||||
ls -la dist
|
||||
|
||||
- name: Attach to the release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
python3 - <<'EOF'
|
||||
import json, os, pathlib, urllib.error, urllib.request, uuid
|
||||
api = f"{os.environ['GITHUB_SERVER_URL']}/api/v1/repos/{os.environ['GITHUB_REPOSITORY']}"
|
||||
tag = os.environ["GITHUB_REF_NAME"]
|
||||
auth = {"Authorization": f"token {os.environ['TOKEN']}"}
|
||||
|
||||
def call(method, url, body=None, ctype="application/json"):
|
||||
req = urllib.request.Request(url, data=body, method=method, headers={**auth, "Content-Type": ctype})
|
||||
with urllib.request.urlopen(req) as r:
|
||||
return json.load(r)
|
||||
|
||||
try:
|
||||
rel = call("GET", f"{api}/releases/tags/{tag}")
|
||||
except urllib.error.HTTPError as e:
|
||||
if e.code != 404:
|
||||
raise
|
||||
rel = call("POST", f"{api}/releases", json.dumps({"tag_name": tag, "name": tag}).encode())
|
||||
for f in sorted(pathlib.Path("dist").glob("*.zip")):
|
||||
b = uuid.uuid4().hex
|
||||
head = (f"--{b}\r\nContent-Disposition: form-data; name=\"attachment\"; filename=\"{f.name}\"\r\n"
|
||||
"Content-Type: application/zip\r\n\r\n").encode()
|
||||
body = head + f.read_bytes() + f"\r\n--{b}--\r\n".encode()
|
||||
call("POST", f"{api}/releases/{rel['id']}/assets?name={f.name}", body, f"multipart/form-data; boundary={b}")
|
||||
print("attached", f.name)
|
||||
EOF
|
||||
Reference in new issue
Block a user