From cd37a0b9fb564c168e470690c07526828ad56eec Mon Sep 17 00:00:00 2001 From: Samweli Date: Wed, 26 Feb 2025 00:49:30 +0300 Subject: [PATCH] added workflow for handling pull requests packages --- .github/workflows/pr_package.yml | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/pr_package.yml diff --git a/.github/workflows/pr_package.yml b/.github/workflows/pr_package.yml new file mode 100644 index 0000000..2fb91f0 --- /dev/null +++ b/.github/workflows/pr_package.yml @@ -0,0 +1,85 @@ +name: Plugin zip package + +on: + pull_request: + types: + - edited + - opened + - reopened + - synchronize + branches: + - develop + +jobs: + create-package: + runs-on: ubuntu-22.04 + container: + image: qgis/qgis:release-3_34 + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Fix Python command + run: apt-get install python-is-python3 + + - name: Install python + uses: actions/setup-python@v4 + + - name: Install plugin dependencies + run: | + pip install -r requirements_dev.txt + + - name: Get unique identifier + id: get-identifier + run: | + echo "PACKAGE_ID=$(python -c "import uuid; print(str(uuid.uuid4())[:4])")" >> $GITHUB_ENV + + - name: Set Git configuration + run: | + git config --global --add safe.directory /__w/qgis-plugin-template/qgis-plugin-template + + - name: Build zipfile + run: | + + python admin.py build --output-directory ${{ format( + './qgis-plugin-template_{0}_{1}/qgis_plugin_template/', + github.event.pull_request.head.ref, + env.PACKAGE_ID) }} + + echo "ZIP_PATH=$GITHUB_WORKSPACE/${{ format('qgis-plugin-template_{0}_{1}', github.event.pull_request.head.ref, env.PACKAGE_ID) }}" >> $GITHUB_ENV + echo "ZIP_NAME=${{ format('qgis-plugin-template_{0}_{1}', github.event.pull_request.head.ref, env.PACKAGE_ID) }}" >> $GITHUB_ENV + + + - name: Uploading plugin build + id: artifact-upload-step + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ZIP_NAME }} + path: ${{ env.ZIP_PATH }} + + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: find-comment + with: + issue-number: ${{ github.event.number }} + comment-author: 'github-actions[bot]' + + - name: Update Comment + env: + HEAD_SHA: "${{ github.event.head_sha }}" + ARTIFACT_URL: ${{ steps.artifact-upload-step.outputs.artifact-url }} + + uses: peter-evans/create-or-update-comment@v3 + with: + token: ${{ github.token }} + issue-number: ${{ github.event.number }} + comment-id: ${{ steps.find-comment.outputs.comment-id }} + edit-mode: replace + body: |- + ![badge] + + Plugin zip package for the changes in this PR has been successfully built!. + + Download the plugin zip file here ${{ env.ARTIFACT_URL }} + + [badge]: https://img.shields.io/badge/package_build-success-green