diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 7145972..383c1a9 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -4,8 +4,6 @@ on: push: tags: - 'v*' - branches: - - feature/release # Zum Testen: auch bei Branch-Push auslösen jobs: release: @@ -16,72 +14,147 @@ jobs: - name: Install dependencies run: apk add --no-cache zip curl - - name: Determine channel from tag - id: channel + - name: Determine version and channel + id: info run: | - # Bei Branch-Push (kein Tag): dev als Default TAG="${{ github.ref_name }}" + VERSION="${TAG#v}" + if [[ "$TAG" =~ -dev ]]; then - echo "channel=dev" >> $GITHUB_OUTPUT - echo "version=$TAG" >> $GITHUB_OUTPUT + CHANNEL="dev" elif [[ "$TAG" =~ -beta ]]; then - echo "channel=beta" >> $GITHUB_OUTPUT - echo "version=$TAG" >> $GITHUB_OUTPUT - elif [[ "$TAG" =~ ^v[0-9] ]]; then - echo "channel=stable" >> $GITHUB_OUTPUT - echo "version=$TAG" >> $GITHUB_OUTPUT + CHANNEL="beta" else - # Branch-Push ohne Tag → dev-Build - echo "channel=dev" >> $GITHUB_OUTPUT - echo "version=dev-$(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT + CHANNEL="stable" 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 run: | - PLUGIN_NAME="Plugin_Test_Action" - VERSION="${{ steps.channel.outputs.version }}" - mkdir -p dist - zip -r dist/${PLUGIN_NAME}-${VERSION}.zip \ - ${PLUGIN_NAME}/ \ + REPO_NAME="${{ github.event.repository.name }}" + ZIP_FOLDER="${{ steps.cfg.outputs.zip_folder }}" + VERSION="${{ steps.info.outputs.version }}" + ZIP_NAME="${REPO_NAME}-${VERSION}.zip" + + # 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__/*" - echo "ZIP_PATH=dist/${PLUGIN_NAME}-${VERSION}.zip" >> $GITHUB_ENV - echo "PLUGIN_NAME=${PLUGIN_NAME}" >> $GITHUB_ENV - echo "VERSION=${VERSION}" >> $GITHUB_ENV + cd .. + + echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV - name: Create Gitea Release id: create_release run: | + VERSION="${{ steps.info.outputs.version }}" IS_PRERELEASE=true - [[ "${{ steps.channel.outputs.channel }}" == "stable" ]] && IS_PRERELEASE=false + [[ "${{ steps.info.outputs.channel }}" == "stable" ]] && IS_PRERELEASE=false RESPONSE=$(curl -s -X POST \ -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ -H "Content-Type: application/json" \ "${{ vars.GITEA_URL }}/api/v1/repos/${{ github.repository }}/releases" \ -d "{ - \"tag_name\": \"${VERSION}\", + \"tag_name\": \"${{ github.ref_name }}\", \"name\": \"Release ${VERSION}\", \"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 + id: upload_asset run: | - curl -s -X POST \ + RESPONSE=$(curl -s -X POST \ -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ -H "Content-Type: application/zip" \ - "${{ vars.GITEA_URL }}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=$(basename ${ZIP_PATH})" \ - --data-binary @${ZIP_PATH} + "${{ vars.GITEA_URL }}/api/v1/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.release_id }}/assets?name=${ZIP_NAME}" \ + --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: | - ASSETS=$(curl -s \ - -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ - "${{ vars.GITEA_URL }}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets") - DOWNLOAD_URL=$(echo $ASSETS | grep -o '"browser_download_url":"[^"]*' | head -1 | cut -d'"' -f4) - echo "DOWNLOAD_URL=${DOWNLOAD_URL}" >> $GITHUB_ENV + BLOCK=" \n" + BLOCK+=" ${{ steps.cfg.outputs.description }}\n" + BLOCK+=" ${{ steps.cfg.outputs.qgis_min }}\n" + BLOCK+=" ${{ steps.cfg.outputs.qgis_max }}\n" + BLOCK+=" ${{ steps.cfg.outputs.author }}\n" + BLOCK+=" ${{ steps.cfg.outputs.email }}\n" + BLOCK+=" ${{ steps.cfg.outputs.homepage }}\n" + BLOCK+=" ${{ steps.cfg.outputs.tracker }}\n" + BLOCK+=" ${{ steps.cfg.outputs.repository }}\n" + BLOCK+=" ${{ steps.upload_asset.outputs.download_url }}\n" + BLOCK+=" ${{ steps.cfg.outputs.experimental }}\n" + BLOCK+=" ${{ steps.cfg.outputs.deprecated }}\n" + BLOCK+=" " - - name: Trigger Repository update + BLOCK_ESCAPED=$(printf '%s' "$BLOCK" | sed 's/"/\\"/g') + echo "block=${BLOCK_ESCAPED}" >> $GITHUB_OUTPUT + + - name: Dispatch to Repository run: | curl -s -X POST \ -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ @@ -90,9 +163,8 @@ jobs: -d "{ \"type\": \"plugin-released\", \"payload\": { - \"plugin\": \"${PLUGIN_NAME}\", - \"version\": \"${VERSION}\", - \"channel\": \"${{ steps.channel.outputs.channel }}\", - \"download_url\": \"${DOWNLOAD_URL}\" + \"plugin\": \"${{ steps.cfg.outputs.name }}\", + \"channel\": \"${{ steps.info.outputs.channel }}\", + \"xml_block\": \"${{ steps.xmlblock.outputs.block }}\" } }" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 36b13f1..1e87eb9 100644 --- a/.gitignore +++ b/.gitignore @@ -174,3 +174,4 @@ cython_debug/ # PyPI configuration file .pypirc +metadata.txt \ No newline at end of file diff --git a/.plugin/changelog.txt b/.plugin/changelog.txt new file mode 100644 index 0000000..efe02ee --- /dev/null +++ b/.plugin/changelog.txt @@ -0,0 +1,5 @@ +0.2.0 + - Feature XY hinzugefügt + - Bug Z behoben +0.1.0 + - Initiales Release \ No newline at end of file diff --git a/.plugin/plugin.cfg b/.plugin/plugin.cfg new file mode 100644 index 0000000..6bd305f --- /dev/null +++ b/.plugin/plugin.cfg @@ -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 \ No newline at end of file