Initial commit
This commit is contained in:
159
.gitea/workflows/update.yml
Normal file
159
.gitea/workflows/update.yml
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
name: Update Plugin (Empfang)
|
||||||
|
run-name: "Release | ${{ inputs.name }} → ${{ inputs.tag }}"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
payload:
|
||||||
|
description: 'Base64-kodierter JSON-Payload'
|
||||||
|
required: true
|
||||||
|
name:
|
||||||
|
description: 'Plugin Name'
|
||||||
|
required: true
|
||||||
|
tag:
|
||||||
|
description: 'Release Tag'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-plugin:
|
||||||
|
runs-on: alpine-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Abhängigkeiten installieren
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
apk add --no-cache bash jq git
|
||||||
|
|
||||||
|
- name: Repository klonen
|
||||||
|
run: |
|
||||||
|
REPO_URL="https://${RELEASE_TOKEN}:x-oauth-basic@${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}.git"
|
||||||
|
|
||||||
|
git clone "$REPO_URL" repo
|
||||||
|
cd repo
|
||||||
|
#git checkout feature/release
|
||||||
|
env:
|
||||||
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
|
||||||
|
- name: Payload dekodieren
|
||||||
|
id: payload
|
||||||
|
run: |
|
||||||
|
DECODED=$(echo "${{ github.event.inputs.payload }}" | base64 -d)
|
||||||
|
|
||||||
|
echo "name=$(echo "$DECODED" | jq -r '.name')" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=$(echo "$DECODED" | jq -r '.version')" >> $GITHUB_OUTPUT
|
||||||
|
echo "channel=$(echo "$DECODED" | jq -r '.channel')" >> $GITHUB_OUTPUT
|
||||||
|
echo "description=$(echo "$DECODED" | jq -r '.description')" >> $GITHUB_OUTPUT
|
||||||
|
echo "author=$(echo "$DECODED" | jq -r '.author')" >> $GITHUB_OUTPUT
|
||||||
|
echo "email=$(echo "$DECODED" | jq -r '.email')" >> $GITHUB_OUTPUT
|
||||||
|
echo "qgis_min=$(echo "$DECODED" | jq -r '.qgis_min')" >> $GITHUB_OUTPUT
|
||||||
|
echo "qgis_max=$(echo "$DECODED" | jq -r '.qgis_max')" >> $GITHUB_OUTPUT
|
||||||
|
echo "homepage=$(echo "$DECODED" | jq -r '.homepage')" >> $GITHUB_OUTPUT
|
||||||
|
echo "tracker=$(echo "$DECODED" | jq -r '.tracker')" >> $GITHUB_OUTPUT
|
||||||
|
echo "repository=$(echo "$DECODED" | jq -r '.repository')" >> $GITHUB_OUTPUT
|
||||||
|
echo "experimental=$(echo "$DECODED" | jq -r '.experimental')" >> $GITHUB_OUTPUT
|
||||||
|
echo "deprecated=$(echo "$DECODED" | jq -r '.deprecated')" >> $GITHUB_OUTPUT
|
||||||
|
echo "qt6=$(echo "$DECODED" | jq -r '.qt6')" >> $GITHUB_OUTPUT
|
||||||
|
echo "id=$(echo "$DECODED" | jq -r '.id')" >> $GITHUB_OUTPUT
|
||||||
|
echo "url=$(echo "$DECODED" | jq -r '.url')" >> $GITHUB_OUTPUT
|
||||||
|
echo "changelog=$(echo "$DECODED" | jq -r '.changelog')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
|
||||||
|
- name: XML-Datei bestimmen
|
||||||
|
id: xmlfile
|
||||||
|
run: |
|
||||||
|
case "${{ steps.payload.outputs.channel }}" in
|
||||||
|
stable) FILE="plugins.xml" ;;
|
||||||
|
testing) FILE="plugins-testing.xml" ;;
|
||||||
|
unstable) FILE="plugins-unstable.xml" ;;
|
||||||
|
esac
|
||||||
|
echo "file=$FILE" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: XML-Datei initialisieren
|
||||||
|
run: |
|
||||||
|
cd repo
|
||||||
|
FILE="${{ steps.xmlfile.outputs.file }}"
|
||||||
|
if [ ! -s "$FILE" ]; then
|
||||||
|
echo "<plugins></plugins>" > "$FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Alten Plugin-Eintrag entfernen
|
||||||
|
run: |
|
||||||
|
cd repo
|
||||||
|
FILE="${{ steps.xmlfile.outputs.file }}"
|
||||||
|
ID="${{ steps.payload.outputs.id }}"
|
||||||
|
|
||||||
|
# Entfernt den kompletten Plugin-Block
|
||||||
|
sed -i "/<pyqgis_plugin[^>]*plugin_id=\"${ID//\//\\/}\"/,/<\/pyqgis_plugin>/d" "$FILE"
|
||||||
|
|
||||||
|
- name: Template anwenden und neue XML erzeugen
|
||||||
|
run: |
|
||||||
|
cd repo
|
||||||
|
|
||||||
|
FILE="${{ steps.xmlfile.outputs.file }}"
|
||||||
|
|
||||||
|
git fetch origin hidden/templates
|
||||||
|
git checkout origin/hidden/templates -- plugin.template
|
||||||
|
|
||||||
|
TEMPLATE="plugin.template"
|
||||||
|
|
||||||
|
# Template laden
|
||||||
|
ENTRY=$(cat "$TEMPLATE")
|
||||||
|
|
||||||
|
# Variablen ersetzen – vollständig synchron zu metadata.txt & Payload
|
||||||
|
ENTRY="${ENTRY//\{\{NAME\}\}/${{ steps.payload.outputs.name }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{VERSION\}\}/${{ steps.payload.outputs.version }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{DESCRIPTION\}\}/${{ steps.payload.outputs.description }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{AUTHOR\}\}/${{ steps.payload.outputs.author }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{EMAIL\}\}/${{ steps.payload.outputs.email }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{QGIS_MIN\}\}/${{ steps.payload.outputs.qgis_min }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{QGIS_MAX\}\}/${{ steps.payload.outputs.qgis_max }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{HOMEPAGE\}\}/${{ steps.payload.outputs.homepage }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{TRACKER\}\}/${{ steps.payload.outputs.tracker }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{REPOSITORY\}\}/${{ steps.payload.outputs.repository }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{EXPERIMENTAL\}\}/${{ steps.payload.outputs.experimental }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{DEPRECATED\}\}/${{ steps.payload.outputs.deprecated }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{QT6\}\}/${{ steps.payload.outputs.qt6 }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{ID\}\}/${{ steps.payload.outputs.id }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{URL\}\}/${{ steps.payload.outputs.url }}}"
|
||||||
|
ENTRY="${ENTRY//\{\{CHANGELOG\}\}/${{ steps.payload.outputs.changelog }}}"
|
||||||
|
|
||||||
|
# Neue Datei erzeugen
|
||||||
|
{
|
||||||
|
# Alles vor </plugins>
|
||||||
|
sed '/<\/plugins>/d' "$FILE"
|
||||||
|
|
||||||
|
# Neuen Eintrag einfügen
|
||||||
|
printf "%s\n" "$ENTRY"
|
||||||
|
|
||||||
|
# </plugins> wieder anhängen
|
||||||
|
echo "</plugins>"
|
||||||
|
} > new.xml
|
||||||
|
|
||||||
|
mv new.xml "$FILE"
|
||||||
|
rm $TEMPLATE
|
||||||
|
|
||||||
|
- name: Commit & Push
|
||||||
|
run: |
|
||||||
|
cd repo
|
||||||
|
|
||||||
|
git config user.name "Release Bot"
|
||||||
|
git config user.email "release-bot@noreply.localhost"
|
||||||
|
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commit nur, wenn Änderungen vorhanden sind
|
||||||
|
if ! git diff --cached --quiet; then
|
||||||
|
git commit -m "${{ inputs.name }} → ${{ steps.payload.outputs.version }}"
|
||||||
|
else
|
||||||
|
echo "Keine Änderungen – kein Commit notwendig."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Token in die URL einbauen
|
||||||
|
git remote set-url origin "https://${{ secrets.RELEASE_TOKEN }}:@${{ vars.RELEASE_URL }}/AG_QGIS/Repository.git"
|
||||||
|
|
||||||
|
git push origin main
|
||||||
|
|
||||||
Reference in New Issue
Block a user