refactor: rename workflow to 'Generate Manifest & Tag' and simplify release process
This commit is contained in:
143
.github/workflows/release.yml
vendored
143
.github/workflows/release.yml
vendored
@@ -1,23 +1,17 @@
|
||||
name: Build & Release Plugin
|
||||
name: Generate Manifest & Tag
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_notes:
|
||||
description: 'Optionele release-opmerkingen'
|
||||
required: false
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'groq-ai-product-text.php'
|
||||
- 'includes/**'
|
||||
- 'assets/**'
|
||||
- 'README.md'
|
||||
- 'manifest.json'
|
||||
- '.github/workflows/release.yml'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
tag:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -100,45 +94,7 @@ jobs:
|
||||
- name: Tag bestaat al – workflow afronden
|
||||
if: steps.tagcheck.outputs.exists == 'true'
|
||||
run: |
|
||||
echo "Tag v${{ steps.meta.outputs.version }} bestaat al. Release wordt overgeslagen."
|
||||
|
||||
- name: Build distributie-zip
|
||||
if: steps.tagcheck.outputs.exists == 'false'
|
||||
id: package
|
||||
run: |
|
||||
VERSION="${{ steps.meta.outputs.version }}"
|
||||
SLUG="siti-ai-product-content-generator"
|
||||
BUILD_ROOT="$RUNNER_TEMP/build"
|
||||
DEST_DIR="$BUILD_ROOT/$SLUG"
|
||||
mkdir -p "$DEST_DIR"
|
||||
|
||||
rsync -a ./ "$DEST_DIR" \
|
||||
--exclude '.git/' \
|
||||
--exclude '.github/' \
|
||||
--exclude 'docker/' \
|
||||
--exclude 'docs/' \
|
||||
--exclude 'dist/' \
|
||||
--exclude 'docker-compose.yml' \
|
||||
--exclude 'PLAN.md'
|
||||
|
||||
mkdir -p dist
|
||||
ZIP_PATH="dist/${SLUG}-${VERSION}.zip"
|
||||
(cd "$BUILD_ROOT" && zip -r "$GITHUB_WORKSPACE/$ZIP_PATH" "$SLUG")
|
||||
|
||||
echo "asset_path=$ZIP_PATH" >> "$GITHUB_OUTPUT"
|
||||
echo "asset_name=${SLUG}-${VERSION}.zip" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Stel release-body samen
|
||||
if: steps.tagcheck.outputs.exists == 'false'
|
||||
id: releasebody
|
||||
run: |
|
||||
if [ -n "$RELEASE_NOTES" ]; then
|
||||
echo "text=$RELEASE_NOTES" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "text=Automatische release op basis van versie ${{ steps.meta.outputs.version }}." >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
env:
|
||||
RELEASE_NOTES: ${{ github.event.inputs.release_notes }}
|
||||
echo "Tag v${{ steps.meta.outputs.version }} bestaat al. Tag wordt overgeslagen."
|
||||
|
||||
- name: Maak Gitea tag
|
||||
if: steps.tagcheck.outputs.exists == 'false'
|
||||
@@ -150,89 +106,12 @@ jobs:
|
||||
VERSION="${{ steps.meta.outputs.version }}"
|
||||
TAG="v$VERSION"
|
||||
|
||||
if [ -z "$GITEA_TOKEN" ]; then
|
||||
echo "::error::GITEA_TOKEN ontbreekt. Voeg deze secret toe om tags te kunnen pushen."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SERVER_URL="${GITEA_SERVER_URL:-${GITHUB_SERVER_URL}}"
|
||||
REPO="${GITEA_REPOSITORY:-${GITHUB_REPOSITORY}}"
|
||||
if [ -z "$SERVER_URL" ] || [ -z "$REPO" ]; then
|
||||
echo "::error::Kan Gitea server of repository niet bepalen. Stel GITEA_SERVER_URL en GITEA_REPOSITORY in."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HOST="${SERVER_URL#https://}"
|
||||
HOST="${HOST#http://}"
|
||||
AUTH_URL="https://oauth2:${GITEA_TOKEN}@${HOST}/${REPO}.git"
|
||||
|
||||
git tag -a "$TAG" -m "$TAG"
|
||||
git push "$AUTH_URL" "$TAG"
|
||||
|
||||
- name: Maak Gitea release
|
||||
if: steps.tagcheck.outputs.exists == 'false'
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_SERVER_URL: ${{ vars.GITEA_SERVER_URL }}
|
||||
GITEA_REPOSITORY: ${{ vars.GITEA_REPOSITORY }}
|
||||
run: |
|
||||
VERSION="${{ steps.meta.outputs.version }}"
|
||||
TAG="v$VERSION"
|
||||
ASSET_PATH="${{ steps.package.outputs.asset_path }}"
|
||||
ASSET_NAME="${{ steps.package.outputs.asset_name }}"
|
||||
|
||||
if [ -z "$GITEA_TOKEN" ]; then
|
||||
echo "::error::GITEA_TOKEN ontbreekt. Voeg deze secret toe om releases te kunnen maken."
|
||||
exit 1
|
||||
if [ -n "$GITEA_TOKEN" ] && [ -n "$GITEA_SERVER_URL" ] && [ -n "$GITEA_REPOSITORY" ]; then
|
||||
HOST="${GITEA_SERVER_URL#https://}"
|
||||
HOST="${HOST#http://}"
|
||||
AUTH_URL="https://oauth2:${GITEA_TOKEN}@${HOST}/${GITEA_REPOSITORY}.git"
|
||||
git push "$AUTH_URL" "$TAG"
|
||||
else
|
||||
git push origin "$TAG"
|
||||
fi
|
||||
|
||||
SERVER_URL="${GITEA_SERVER_URL:-${GITHUB_SERVER_URL}}"
|
||||
REPO="${GITEA_REPOSITORY:-${GITHUB_REPOSITORY}}"
|
||||
if [ -z "$SERVER_URL" ] || [ -z "$REPO" ]; then
|
||||
echo "::error::Kan Gitea server of repository niet bepalen. Stel GITEA_SERVER_URL en GITEA_REPOSITORY in."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API_URL="${SERVER_URL%/}/api/v1"
|
||||
BODY="${{ steps.releasebody.outputs.text }}"
|
||||
|
||||
export TAG
|
||||
export BODY
|
||||
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
import os
|
||||
|
||||
payload = {
|
||||
"tag_name": os.environ["TAG"],
|
||||
"name": f"Siti AI Product Teksten {os.environ['TAG']}",
|
||||
"body": os.environ.get("BODY", ""),
|
||||
"target_commitish": os.environ.get("GITHUB_SHA") or os.environ.get("GITEA_SHA", ""),
|
||||
}
|
||||
|
||||
with open("release.json", "w", encoding="utf-8") as handle:
|
||||
json.dump(payload, handle, ensure_ascii=False)
|
||||
PY
|
||||
|
||||
RESPONSE=$(curl -sS -X POST "$API_URL/repos/$REPO/releases" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @release.json)
|
||||
|
||||
RELEASE_ID=$(python3 - <<'PY'
|
||||
import json
|
||||
import sys
|
||||
data = json.loads(sys.stdin.read())
|
||||
print(data.get('id', ''))
|
||||
PY
|
||||
<<< "$RESPONSE")
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "::error::Kon release-ID niet bepalen. Response: $RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -sS -X POST "$API_URL/repos/$REPO/releases/$RELEASE_ID/assets?name=$ASSET_NAME" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--data-binary "@$ASSET_PATH"
|
||||
|
||||
Reference in New Issue
Block a user