Repository navigation
98 lines (85 loc) · 3.76 KB
/
Copy pathrelease.yml
File metadata and controls
98 lines (85 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Verify SDK & Publish Release
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
concurrency:
group: release-${{ github.repository }}
cancel-in-progress: false
permissions:
contents: write
jobs:
verify-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify Python SDK scripts & JSON schemas
run: |
python3 -m py_compile examples/*.py
python3 -c 'import glob, json; [json.load(open(f)) for f in glob.glob("n8n/*.json") + glob.glob("samples/*.json") + glob.glob("notebooks/*.ipynb")]'
- name: Build starter-kit release bundle (unitbytes-reddit-scraper-api-starter-kit.zip)
run: |
zip -r "unitbytes-reddit-scraper-api-starter-kit.zip" README.md requirements.txt LICENSE SECURITY.md examples/ notebooks/ n8n/ samples/
- name: Sync clean v1.0.0 & v1.1.0 GitHub Releases
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_FULL: ${{ github.repository }}
TITLE_CLEAN: "🤖 Reddit Scraper API Suite: Subreddits, Search, Posts & Nested Comments (`$1 / 1K`)"
ZIP_NAME: "unitbytes-reddit-scraper-api-starter-kit.zip"
run: |
python3 - << 'PYEOF'
import json, os, subprocess, urllib.request
token = os.environ["GH_TOKEN"]
repo = os.environ["REPO_FULL"]
title_clean = os.environ["TITLE_CLEAN"]
zip_name = os.environ["ZIP_NAME"]
notes_v110 = open(".github/RELEASE_NOTES.md", "r", encoding="utf-8").read()
notes_v100 = notes_v110.replace("v1.1.0 Release Notes", "v1.0.0 Release Notes", 1)
def gh_api(method, path, payload=None):
url = f"https://api.github.com{path}"
headers = {
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {token}",
"X-GitHub-Api-Version": "2022-11-28",
"User-Agent": "unitbytes-release-bot",
}
data = None
if payload is not None:
data = json.dumps(payload).encode("utf-8")
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, headers=headers, method=method)
with urllib.request.urlopen(req, timeout=30) as r:
b = r.read().decode("utf-8")
return json.loads(b) if b else {}
rels = gh_api("GET", f"/repos/{repo}/releases")
by_tag = {r["tag_name"]: r for r in rels}
if "v1.0.0" in by_tag:
r100 = by_tag["v1.0.0"]
gh_api("PATCH", f"/repos/{repo}/releases/{r100['id']}", {
"name": f"UnitBytes {title_clean} — v1.0.0 Release",
"body": notes_v100,
})
rel_name_110 = f"UnitBytes {title_clean} — v1.1.0 (Colab, MCP, RapidAPI/Zyla & 9-Node n8n Suite)"
if "v1.1.0" in by_tag:
r110 = by_tag["v1.1.0"]
gh_api("PATCH", f"/repos/{repo}/releases/{r110['id']}", {
"name": rel_name_110,
"body": notes_v110,
"draft": False,
"prerelease": False,
"make_latest": "true",
})
else:
gh_api("POST", f"/repos/{repo}/releases", {
"tag_name": "v1.1.0",
"target_commitish": "main",
"name": rel_name_110,
"body": notes_v110,
"draft": False,
"prerelease": False,
"make_latest": "true",
})
subprocess.run(["gh", "release", "upload", "v1.1.0", zip_name, "--clobber", "--repo", repo], check=True)
PYEOF