112 lines
3.7 KiB
YAML
112 lines
3.7 KiB
YAML
name: Update Plugin (Empfang)
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
payload:
|
|
description: 'Base64-kodierter JSON-Payload'
|
|
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: |
|
|
git clone https://entwicklung.flurneuordnung-sachsen.de/AG_QGIS/Repository.git repo
|
|
cd repo
|
|
git checkout feature/release
|
|
|
|
- name: Payload dekodieren
|
|
id: payload
|
|
run: |
|
|
DECODED=$(echo "${{ github.event.inputs.payload }}" | base64 -d)
|
|
|
|
echo "plugin=$(echo "$DECODED" | jq -r '.plugin')" >> $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 "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 }}"
|
|
PLUGIN="${{ steps.payload.outputs.plugin }}"
|
|
|
|
# Entfernt den kompletten Plugin-Block
|
|
sed -i "/<plugin name=\"${PLUGIN//\//\\/}\"/,/<\/plugin>/d" "$FILE"
|
|
|
|
- name: Template anwenden und neue XML erzeugen
|
|
run: |
|
|
cd repo
|
|
|
|
FILE="${{ steps.xmlfile.outputs.file }}"
|
|
TEMPLATE="templates/plugin.template"
|
|
|
|
# Template laden
|
|
ENTRY=$(cat "$TEMPLATE")
|
|
|
|
# Variablen ersetzen
|
|
ENTRY="${ENTRY//\{\{PLUGIN\}\}/${{ steps.payload.outputs.plugin }}}"
|
|
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//\{\{URL\}\}/${{ steps.payload.outputs.url }}}"
|
|
ENTRY="${ENTRY//\{\{CHANGELOG\}\}/${{ steps.payload.outputs.changelog }}}"
|
|
|
|
# Neue Datei erzeugen
|
|
{
|
|
# Alles vor </plugins>
|
|
sed '/<\/plugins>/q' "$FILE"
|
|
|
|
# Neuen Eintrag einfügen
|
|
printf "%s\n" "$ENTRY"
|
|
|
|
# </plugins> wieder anhängen
|
|
echo "</plugins>"
|
|
} > new.xml
|
|
|
|
mv new.xml "$FILE"
|
|
|
|
- name: Commit & Push
|
|
run: |
|
|
cd repo
|
|
git config user.name "Release Bot"
|
|
git config user.email "release-bot@noreply.localhost"
|
|
|
|
git add .
|
|
git commit -m "Update ${{ steps.payload.outputs.plugin }} ${{ steps.payload.outputs.version }} (${{ steps.payload.outputs.channel }})"
|
|
git push
|