refactor(build): changes to auto release when we cahnge version
Some checks failed
Build and Push LST Docker Image / docker (push) Has been cancelled
Some checks failed
Build and Push LST Docker Image / docker (push) Has been cancelled
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"mode": "pre",
|
"mode": "pre",
|
||||||
"tag": "alpha",
|
"tag": "alpha",
|
||||||
"initialVersions": {
|
"initialVersions": {
|
||||||
"lst_v3": "1.0.1"
|
"lst_v3": "0.0.1"
|
||||||
},
|
},
|
||||||
"changesets": [
|
"changesets": [
|
||||||
"neat-years-unite",
|
"neat-years-unite",
|
||||||
|
|||||||
119
.gitea/workflows/release.yml
Normal file
119
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
name: Create Gitea Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Prepare release metadata
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
TAG="${GITHUB_REF_NAME:-${GITHUB_REF##refs/tags/}}"
|
||||||
|
VERSION="${TAG#v}"
|
||||||
|
|
||||||
|
echo "TAG=$TAG" >> "$GITHUB_ENV"
|
||||||
|
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
if [[ "$TAG" == *-* ]]; then
|
||||||
|
echo "PRERELEASE=true" >> "$GITHUB_ENV"
|
||||||
|
else
|
||||||
|
echo "PRERELEASE=false" >> "$GITHUB_ENV"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Extract matching CHANGELOG section
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python <<'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")
|
||||||
|
|
||||||
|
# Matches headings like:
|
||||||
|
# ## 1.2.3
|
||||||
|
# ## 1.2.3-alpha.0
|
||||||
|
# ## [1.2.3]
|
||||||
|
pattern = re.compile(
|
||||||
|
rf"^##\s+\[?{re.escape(version)}\]?(?:\s*-.*)?\n(.*?)(?=^##\s|\Z)",
|
||||||
|
re.MULTILINE | re.DOTALL,
|
||||||
|
)
|
||||||
|
|
||||||
|
match = pattern.search(text)
|
||||||
|
if match:
|
||||||
|
body = match.group(1).strip()
|
||||||
|
else:
|
||||||
|
body = text.strip()
|
||||||
|
|
||||||
|
if not body:
|
||||||
|
body = f"Release {version}"
|
||||||
|
|
||||||
|
Path("release_body.md").write_text(body + "\n", encoding="utf-8")
|
||||||
|
PY
|
||||||
|
|
||||||
|
- name: Create Gitea release
|
||||||
|
env:
|
||||||
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||||
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python <<'PY'
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
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"]
|
||||||
|
|
||||||
|
with open("release_body.md", "r", encoding="utf-8") as f:
|
||||||
|
body = f.read()
|
||||||
|
|
||||||
|
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
|
||||||
@@ -14,7 +14,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- LOG_LEVEL=info
|
- LOG_LEVEL=info
|
||||||
- EXTERNAL_URL=192.168.8.222:3600
|
- EXTERNAL_URL=http://192.168.8.222:3600
|
||||||
- DATABASE_HOST=host.docker.internal # if running on the same docker then do this
|
- DATABASE_HOST=host.docker.internal # if running on the same docker then do this
|
||||||
- DATABASE_PORT=5433
|
- DATABASE_PORT=5433
|
||||||
- DATABASE_USER=${DATABASE_USER}
|
- DATABASE_USER=${DATABASE_USER}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ stage the change log file
|
|||||||
|
|
||||||
git commit -m "chore(release): version packages"
|
git commit -m "chore(release): version packages"
|
||||||
|
|
||||||
git tag v1.0.1 this will be the new version
|
git tag v0.0.1-alpha.0 this will be the new version
|
||||||
|
|
||||||
then push it
|
then push it
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user