fix(release): typo that caused errors
This commit is contained in:
@@ -33,41 +33,6 @@ jobs:
|
|||||||
echo "PRERELEASE=false" >> "$GITHUB_ENV"
|
echo "PRERELEASE=false" >> "$GITHUB_ENV"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Extract matching CHANGELOG section
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
python3 - <<'PY'
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
version = os.environ["VERSION"]
|
|
||||||
changelog_path = Path("CHANGELOG.md")
|
|
||||||
|
|
||||||
if not changelog_path.exists():
|
|
||||||
body = f"# {version}\n\nNo CHANGELOG.md found."
|
|
||||||
Path("release_body.md").write_text(body, encoding="utf-8")
|
|
||||||
raise SystemExit(0)
|
|
||||||
|
|
||||||
text = changelog_path.read_text(encoding="utf-8")
|
|
||||||
|
|
||||||
pattern = re.compile(
|
|
||||||
rf"^##\s+\[?{re.escape(version)}\]?[^\n]*\n(.*?)(?=^##\s+\[?[0-9]|\Z)",
|
|
||||||
re.MULTILINE | re.DOTALL,
|
|
||||||
)
|
|
||||||
|
|
||||||
match = pattern.search(text)
|
|
||||||
if match:
|
|
||||||
body = match.group(1).strip()
|
|
||||||
else:
|
|
||||||
body = f"Release {version}"
|
|
||||||
|
|
||||||
if not body:
|
|
||||||
body = f"Release {version}"
|
|
||||||
|
|
||||||
Path("release_body.md").write_text(body + "\n", encoding="utf-8")
|
|
||||||
PY
|
|
||||||
|
|
||||||
- name: Log in to Gitea container registry
|
- name: Log in to Gitea container registry
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
@@ -138,3 +103,55 @@ jobs:
|
|||||||
Path("release_body.md").write_text(body + "\n", encoding="utf-8")
|
Path("release_body.md").write_text(body + "\n", encoding="utf-8")
|
||||||
print(body)
|
print(body)
|
||||||
PY
|
PY
|
||||||
|
|
||||||
|
- name: Create Gitea release
|
||||||
|
env:
|
||||||
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||||
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
tag = os.environ["TAG"]
|
||||||
|
prerelease = os.environ["PRERELEASE"].lower() == "true"
|
||||||
|
server_url = os.environ["GITEA_SERVER_URL"].rstrip("/")
|
||||||
|
repo = os.environ["GITEA_REPOSITORY"]
|
||||||
|
token = os.environ["RELEASE_TOKEN"]
|
||||||
|
|
||||||
|
body = Path("release_body.md").read_text(encoding="utf-8").strip()
|
||||||
|
|
||||||
|
url = f"{server_url}/api/v1/repos/{repo}/releases"
|
||||||
|
payload = {
|
||||||
|
"tag_name": tag,
|
||||||
|
"name": tag,
|
||||||
|
"body": body,
|
||||||
|
"draft": False,
|
||||||
|
"prerelease": prerelease,
|
||||||
|
}
|
||||||
|
|
||||||
|
data = json.dumps(payload).encode("utf-8")
|
||||||
|
req = urllib.request.Request(
|
||||||
|
url,
|
||||||
|
data=data,
|
||||||
|
method="POST",
|
||||||
|
headers={
|
||||||
|
"Authorization": f"token {token}",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Accept": "application/json",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(req) as resp:
|
||||||
|
print(resp.read().decode("utf-8"))
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
details = e.read().decode("utf-8", errors="replace")
|
||||||
|
print(details)
|
||||||
|
raise
|
||||||
|
PY
|
||||||
Reference in New Issue
Block a user