refactor(build): changes to the way we do release so it builds as well
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m21s
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m21s
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: Create Gitea Release
|
name: Release and Build Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -18,9 +18,14 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
TAG="${GITHUB_REF_NAME:-${GITHUB_REF##refs/tags/}}"
|
TAG="${GITHUB_REF_NAME:-${GITHUB_REF##refs/tags/}}"
|
||||||
VERSION="${TAG#v}"
|
VERSION="${TAG#v}"
|
||||||
|
IMAGE_REGISTRY="${{ gitea.server_url }}"
|
||||||
|
IMAGE_REGISTRY="${IMAGE_REGISTRY#http://}"
|
||||||
|
IMAGE_REGISTRY="${IMAGE_REGISTRY#https://}"
|
||||||
|
IMAGE_NAME="${IMAGE_REGISTRY}/${{ gitea.repository }}"
|
||||||
|
|
||||||
echo "TAG=$TAG" >> "$GITHUB_ENV"
|
echo "TAG=$TAG" >> "$GITHUB_ENV"
|
||||||
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
||||||
|
echo "IMAGE_NAME=$IMAGE_NAME" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
if [[ "$TAG" == *-* ]]; then
|
if [[ "$TAG" == *-* ]]; then
|
||||||
echo "PRERELEASE=true" >> "$GITHUB_ENV"
|
echo "PRERELEASE=true" >> "$GITHUB_ENV"
|
||||||
@@ -31,7 +36,7 @@ jobs:
|
|||||||
- name: Extract matching CHANGELOG section
|
- name: Extract matching CHANGELOG section
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
python <<'PY'
|
python3 - <<'PY'
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -46,10 +51,6 @@ jobs:
|
|||||||
|
|
||||||
text = changelog_path.read_text(encoding="utf-8")
|
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(
|
pattern = re.compile(
|
||||||
rf"^##\s+\[?{re.escape(version)}\]?(?:\s*-.*)?\n(.*?)(?=^##\s|\Z)",
|
rf"^##\s+\[?{re.escape(version)}\]?(?:\s*-.*)?\n(.*?)(?=^##\s|\Z)",
|
||||||
re.MULTILINE | re.DOTALL,
|
re.MULTILINE | re.DOTALL,
|
||||||
@@ -67,6 +68,42 @@ jobs:
|
|||||||
Path("release_body.md").write_text(body + "\n", encoding="utf-8")
|
Path("release_body.md").write_text(body + "\n", encoding="utf-8")
|
||||||
PY
|
PY
|
||||||
|
|
||||||
|
- name: Log in to Gitea container registry
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
run: |
|
||||||
|
echo "$REGISTRY_TOKEN" | docker login "${IMAGE_NAME%%/*}" -u "$REGISTRY_USERNAME" --password-stdin
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
-t "$IMAGE_NAME:$TAG" \
|
||||||
|
-t "$IMAGE_NAME:latest" \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Push version tag
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker push "$IMAGE_NAME:$TAG"
|
||||||
|
|
||||||
|
- name: Push latest tag
|
||||||
|
if: ${{ !contains(env.TAG, '-') }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker push "$IMAGE_NAME:latest"
|
||||||
|
|
||||||
|
- name: Push prerelease channel tag
|
||||||
|
if: ${{ contains(env.TAG, '-') }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
CHANNEL="${TAG#*-}"
|
||||||
|
CHANNEL="${CHANNEL%%.*}"
|
||||||
|
docker tag "$IMAGE_NAME:$TAG" "$IMAGE_NAME:$CHANNEL"
|
||||||
|
docker push "$IMAGE_NAME:$CHANNEL"
|
||||||
|
|
||||||
- name: Create Gitea release
|
- name: Create Gitea release
|
||||||
env:
|
env:
|
||||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
@@ -74,10 +111,11 @@ jobs:
|
|||||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
python <<'PY'
|
python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
|
||||||
tag = os.environ["TAG"]
|
tag = os.environ["TAG"]
|
||||||
prerelease = os.environ["PRERELEASE"].lower() == "true"
|
prerelease = os.environ["PRERELEASE"].lower() == "true"
|
||||||
@@ -88,6 +126,9 @@ jobs:
|
|||||||
with open("release_body.md", "r", encoding="utf-8") as f:
|
with open("release_body.md", "r", encoding="utf-8") as f:
|
||||||
body = f.read()
|
body = f.read()
|
||||||
|
|
||||||
|
image_name = os.environ["IMAGE_NAME"]
|
||||||
|
body = body.rstrip() + f"\n\n### Container Image\n\n- `{image_name}:{tag}`\n"
|
||||||
|
|
||||||
url = f"{server_url}/api/v1/repos/{repo}/releases"
|
url = f"{server_url}/api/v1/repos/{repo}/releases"
|
||||||
payload = {
|
payload = {
|
||||||
"tag_name": tag,
|
"tag_name": tag,
|
||||||
@@ -116,4 +157,4 @@ jobs:
|
|||||||
details = e.read().decode("utf-8", errors="replace")
|
details = e.read().decode("utf-8", errors="replace")
|
||||||
print(details)
|
print(details)
|
||||||
raise
|
raise
|
||||||
PY
|
PY
|
||||||
@@ -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 v0.0.1-alpha.0 this will be the new version
|
git tag v0.0.1-alpha.0 change this to the same version thats in the pkg.json
|
||||||
|
|
||||||
then push it
|
then push it
|
||||||
|
|
||||||
@@ -110,4 +110,5 @@ Release flow
|
|||||||
6. git commit -m "chore(release): version packages"
|
6. git commit -m "chore(release): version packages"
|
||||||
7. git tag vX.X.X
|
7. git tag vX.X.X
|
||||||
8. git push
|
8. git push
|
||||||
9. git push --tags
|
9. git push --tags
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user