forked from AG_QGIS/Plugin_Test_Action
Zweite von claude.ai erstellte Version
This commit is contained in:
@@ -4,8 +4,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
branches:
|
|
||||||
- feature/release # Zum Testen: auch bei Branch-Push auslösen
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
@@ -16,72 +14,147 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: apk add --no-cache zip curl
|
run: apk add --no-cache zip curl
|
||||||
|
|
||||||
- name: Determine channel from tag
|
- name: Determine version and channel
|
||||||
id: channel
|
id: info
|
||||||
run: |
|
run: |
|
||||||
# Bei Branch-Push (kein Tag): dev als Default
|
|
||||||
TAG="${{ github.ref_name }}"
|
TAG="${{ github.ref_name }}"
|
||||||
|
VERSION="${TAG#v}"
|
||||||
|
|
||||||
if [[ "$TAG" =~ -dev ]]; then
|
if [[ "$TAG" =~ -dev ]]; then
|
||||||
echo "channel=dev" >> $GITHUB_OUTPUT
|
CHANNEL="dev"
|
||||||
echo "version=$TAG" >> $GITHUB_OUTPUT
|
|
||||||
elif [[ "$TAG" =~ -beta ]]; then
|
elif [[ "$TAG" =~ -beta ]]; then
|
||||||
echo "channel=beta" >> $GITHUB_OUTPUT
|
CHANNEL="beta"
|
||||||
echo "version=$TAG" >> $GITHUB_OUTPUT
|
|
||||||
elif [[ "$TAG" =~ ^v[0-9] ]]; then
|
|
||||||
echo "channel=stable" >> $GITHUB_OUTPUT
|
|
||||||
echo "version=$TAG" >> $GITHUB_OUTPUT
|
|
||||||
else
|
else
|
||||||
# Branch-Push ohne Tag → dev-Build
|
CHANNEL="stable"
|
||||||
echo "channel=dev" >> $GITHUB_OUTPUT
|
|
||||||
echo "version=dev-$(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
echo "channel=${CHANNEL}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Read plugin.cfg
|
||||||
|
id: cfg
|
||||||
|
run: |
|
||||||
|
CFG=".plugin/plugin.cfg"
|
||||||
|
|
||||||
|
get_value() {
|
||||||
|
grep -i "^$1" "$CFG" | head -1 | cut -d= -f2- | tr -d '\r' | xargs
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "zip_folder=$(get_value zip_folder)" >> $GITHUB_OUTPUT
|
||||||
|
echo "name=$(get_value name)" >> $GITHUB_OUTPUT
|
||||||
|
echo "qgis_min=$(get_value qgisMinimumVersion)" >> $GITHUB_OUTPUT
|
||||||
|
echo "qgis_max=$(get_value qgisMaximumVersion)" >> $GITHUB_OUTPUT
|
||||||
|
echo "description=$(get_value description)" >> $GITHUB_OUTPUT
|
||||||
|
echo "author=$(get_value author)" >> $GITHUB_OUTPUT
|
||||||
|
echo "email=$(get_value email)" >> $GITHUB_OUTPUT
|
||||||
|
echo "homepage=$(get_value homepage)" >> $GITHUB_OUTPUT
|
||||||
|
echo "tracker=$(get_value tracker)" >> $GITHUB_OUTPUT
|
||||||
|
echo "repository=$(get_value repository)" >> $GITHUB_OUTPUT
|
||||||
|
echo "experimental=$(get_value experimental)" >> $GITHUB_OUTPUT
|
||||||
|
echo "deprecated=$(get_value deprecated)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Generate metadata.txt
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.info.outputs.version }}"
|
||||||
|
CHANGELOG=$(cat .plugin/changelog.txt)
|
||||||
|
|
||||||
|
cat > metadata.txt << EOF
|
||||||
|
[general]
|
||||||
|
name=${{ steps.cfg.outputs.name }}
|
||||||
|
version=${VERSION}
|
||||||
|
qgisMinimumVersion=${{ steps.cfg.outputs.qgis_min }}
|
||||||
|
qgisMaximumVersion=${{ steps.cfg.outputs.qgis_max }}
|
||||||
|
description=${{ steps.cfg.outputs.description }}
|
||||||
|
author=${{ steps.cfg.outputs.author }}
|
||||||
|
email=${{ steps.cfg.outputs.email }}
|
||||||
|
homepage=${{ steps.cfg.outputs.homepage }}
|
||||||
|
tracker=${{ steps.cfg.outputs.tracker }}
|
||||||
|
repository=${{ steps.cfg.outputs.repository }}
|
||||||
|
experimental=${{ steps.cfg.outputs.experimental }}
|
||||||
|
deprecated=${{ steps.cfg.outputs.deprecated }}
|
||||||
|
changelog=${VERSION}
|
||||||
|
$(cat .plugin/changelog.txt)
|
||||||
|
EOF
|
||||||
|
|
||||||
- name: Build plugin ZIP
|
- name: Build plugin ZIP
|
||||||
run: |
|
run: |
|
||||||
PLUGIN_NAME="Plugin_Test_Action"
|
REPO_NAME="${{ github.event.repository.name }}"
|
||||||
VERSION="${{ steps.channel.outputs.version }}"
|
ZIP_FOLDER="${{ steps.cfg.outputs.zip_folder }}"
|
||||||
mkdir -p dist
|
VERSION="${{ steps.info.outputs.version }}"
|
||||||
zip -r dist/${PLUGIN_NAME}-${VERSION}.zip \
|
ZIP_NAME="${REPO_NAME}-${VERSION}.zip"
|
||||||
${PLUGIN_NAME}/ \
|
|
||||||
|
# Temporären Ordner mit zip_folder-Namen anlegen
|
||||||
|
mkdir -p dist/${ZIP_FOLDER}
|
||||||
|
|
||||||
|
# Alle Plugin-Dateien hineinkopieren (ohne .gitea, .plugin, dist)
|
||||||
|
rsync -a \
|
||||||
|
--exclude='.gitea' \
|
||||||
|
--exclude='.plugin' \
|
||||||
|
--exclude='.git' \
|
||||||
|
--exclude='dist' \
|
||||||
|
./ dist/${ZIP_FOLDER}/
|
||||||
|
|
||||||
|
# ZIP bauen
|
||||||
|
cd dist
|
||||||
|
zip -r ${ZIP_NAME} ${ZIP_FOLDER}/ \
|
||||||
-x "*.pyc" -x "*/__pycache__/*"
|
-x "*.pyc" -x "*/__pycache__/*"
|
||||||
echo "ZIP_PATH=dist/${PLUGIN_NAME}-${VERSION}.zip" >> $GITHUB_ENV
|
cd ..
|
||||||
echo "PLUGIN_NAME=${PLUGIN_NAME}" >> $GITHUB_ENV
|
|
||||||
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create Gitea Release
|
- name: Create Gitea Release
|
||||||
id: create_release
|
id: create_release
|
||||||
run: |
|
run: |
|
||||||
|
VERSION="${{ steps.info.outputs.version }}"
|
||||||
IS_PRERELEASE=true
|
IS_PRERELEASE=true
|
||||||
[[ "${{ steps.channel.outputs.channel }}" == "stable" ]] && IS_PRERELEASE=false
|
[[ "${{ steps.info.outputs.channel }}" == "stable" ]] && IS_PRERELEASE=false
|
||||||
|
|
||||||
RESPONSE=$(curl -s -X POST \
|
RESPONSE=$(curl -s -X POST \
|
||||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${{ vars.GITEA_URL }}/api/v1/repos/${{ github.repository }}/releases" \
|
"${{ vars.GITEA_URL }}/api/v1/repos/${{ github.repository }}/releases" \
|
||||||
-d "{
|
-d "{
|
||||||
\"tag_name\": \"${VERSION}\",
|
\"tag_name\": \"${{ github.ref_name }}\",
|
||||||
\"name\": \"Release ${VERSION}\",
|
\"name\": \"Release ${VERSION}\",
|
||||||
\"prerelease\": ${IS_PRERELEASE}
|
\"prerelease\": ${IS_PRERELEASE}
|
||||||
}")
|
}")
|
||||||
echo "RELEASE_ID=$(echo $RESPONSE | grep -o '\"id\":[0-9]*' | head -1 | cut -d: -f2)" >> $GITHUB_ENV
|
|
||||||
|
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
|
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Upload ZIP asset
|
- name: Upload ZIP asset
|
||||||
|
id: upload_asset
|
||||||
run: |
|
run: |
|
||||||
curl -s -X POST \
|
RESPONSE=$(curl -s -X POST \
|
||||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
-H "Content-Type: application/zip" \
|
-H "Content-Type: application/zip" \
|
||||||
"${{ vars.GITEA_URL }}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=$(basename ${ZIP_PATH})" \
|
"${{ vars.GITEA_URL }}/api/v1/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.release_id }}/assets?name=${ZIP_NAME}" \
|
||||||
--data-binary @${ZIP_PATH}
|
--data-binary @dist/${ZIP_NAME})
|
||||||
|
|
||||||
- name: Get asset download URL
|
DOWNLOAD_URL=$(echo "$RESPONSE" | grep -o '"browser_download_url":"[^"]*' | cut -d'"' -f4)
|
||||||
|
echo "download_url=${DOWNLOAD_URL}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build XML block
|
||||||
|
id: xmlblock
|
||||||
run: |
|
run: |
|
||||||
ASSETS=$(curl -s \
|
BLOCK=" <pyqgis_plugin name=\"${{ steps.cfg.outputs.name }}\" version=\"${{ steps.info.outputs.version }}\">\n"
|
||||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
BLOCK+=" <description>${{ steps.cfg.outputs.description }}</description>\n"
|
||||||
"${{ vars.GITEA_URL }}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets")
|
BLOCK+=" <qgisMinimumVersion>${{ steps.cfg.outputs.qgis_min }}</qgisMinimumVersion>\n"
|
||||||
DOWNLOAD_URL=$(echo $ASSETS | grep -o '"browser_download_url":"[^"]*' | head -1 | cut -d'"' -f4)
|
BLOCK+=" <qgisMaximumVersion>${{ steps.cfg.outputs.qgis_max }}</qgisMaximumVersion>\n"
|
||||||
echo "DOWNLOAD_URL=${DOWNLOAD_URL}" >> $GITHUB_ENV
|
BLOCK+=" <author>${{ steps.cfg.outputs.author }}</author>\n"
|
||||||
|
BLOCK+=" <email>${{ steps.cfg.outputs.email }}</email>\n"
|
||||||
|
BLOCK+=" <homepage>${{ steps.cfg.outputs.homepage }}</homepage>\n"
|
||||||
|
BLOCK+=" <tracker>${{ steps.cfg.outputs.tracker }}</tracker>\n"
|
||||||
|
BLOCK+=" <repository>${{ steps.cfg.outputs.repository }}</repository>\n"
|
||||||
|
BLOCK+=" <download_url>${{ steps.upload_asset.outputs.download_url }}</download_url>\n"
|
||||||
|
BLOCK+=" <experimental>${{ steps.cfg.outputs.experimental }}</experimental>\n"
|
||||||
|
BLOCK+=" <deprecated>${{ steps.cfg.outputs.deprecated }}</deprecated>\n"
|
||||||
|
BLOCK+=" </pyqgis_plugin>"
|
||||||
|
|
||||||
- name: Trigger Repository update
|
BLOCK_ESCAPED=$(printf '%s' "$BLOCK" | sed 's/"/\\"/g')
|
||||||
|
echo "block=${BLOCK_ESCAPED}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Dispatch to Repository
|
||||||
run: |
|
run: |
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
@@ -90,9 +163,8 @@ jobs:
|
|||||||
-d "{
|
-d "{
|
||||||
\"type\": \"plugin-released\",
|
\"type\": \"plugin-released\",
|
||||||
\"payload\": {
|
\"payload\": {
|
||||||
\"plugin\": \"${PLUGIN_NAME}\",
|
\"plugin\": \"${{ steps.cfg.outputs.name }}\",
|
||||||
\"version\": \"${VERSION}\",
|
\"channel\": \"${{ steps.info.outputs.channel }}\",
|
||||||
\"channel\": \"${{ steps.channel.outputs.channel }}\",
|
\"xml_block\": \"${{ steps.xmlblock.outputs.block }}\"
|
||||||
\"download_url\": \"${DOWNLOAD_URL}\"
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -174,3 +174,4 @@ cython_debug/
|
|||||||
# PyPI configuration file
|
# PyPI configuration file
|
||||||
.pypirc
|
.pypirc
|
||||||
|
|
||||||
|
metadata.txt
|
||||||
5
.plugin/changelog.txt
Normal file
5
.plugin/changelog.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
0.2.0
|
||||||
|
- Feature XY hinzugefügt
|
||||||
|
- Bug Z behoben
|
||||||
|
0.1.0
|
||||||
|
- Initiales Release
|
||||||
14
.plugin/plugin.cfg
Normal file
14
.plugin/plugin.cfg
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[general]
|
||||||
|
zip_folder=mein_plugin_ordner
|
||||||
|
name=LNO Sachsen | Plugin Test Action
|
||||||
|
qgisMinimumVersion=3.0
|
||||||
|
qgisMaximumVersion=3.99
|
||||||
|
description=Test plugin for release pipeline
|
||||||
|
version=26.3.1
|
||||||
|
author=Michael Otto
|
||||||
|
email=michael.otto@landkreis-mittelsachsen.de
|
||||||
|
homepage=https://entwicklung.flurneuordnung-sachsen.de/AG_QGIS/Plugin_Test_Action
|
||||||
|
tracker=https://entwicklung.flurneuordnung-sachsen.de/AG_QGIS/Plugin_Test_Action/issues
|
||||||
|
repository=https://entwicklung.flurneuordnung-sachsen.de/AG_QGIS/Plugin_Test_Action
|
||||||
|
experimental=False
|
||||||
|
deprecated=False
|
||||||
Reference in New Issue
Block a user