Build and Package QGIS Plugin #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Package QGIS Plugin | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # Run on any tag that starts with 'v' (e.g., v1.0.0) | |
| workflow_dispatch: | |
| inputs: | |
| test_version: | |
| description: 'Test version number (e.g., 1.2.3)' | |
| required: true | |
| default: '0.0.0-test' | |
| create_release: | |
| description: 'Create a release? (true/false)' | |
| required: true | |
| default: 'false' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.13' | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Extract version from tag (for tag-based runs) | |
| if: github.event_name == 'push' | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| - name: Set version from input (for manual runs) | |
| if: github.event_name == 'workflow_dispatch' | |
| run: echo "VERSION=${{ github.event.inputs.test_version }}" >> $GITHUB_ENV | |
| - name: Configure metadata from template | |
| run: | | |
| # Run script with version from tag | |
| ./scripts/generate_metadata.sh ${{ env.VERSION }} | |
| cat metadata.txt | |
| - name: Build plugin package | |
| run: | | |
| yes | pbt clean | |
| pbt zip | |
| - name: Rename plugin package | |
| run: | | |
| cd zip_build | |
| mv move move-${{ env.VERSION }} | |
| zip -r move-${{ env.VERSION }}.zip move-${{ env.VERSION }} | |
| - name: Upload plugin package to release | |
| if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: zip_build/move-${{ env.VERSION }}.zip | |
| tag_name: ${{ github.event_name == 'push' && github.ref || format('test-v{0}', github.event.inputs.test_version) }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload built plugin as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: move-${{ env.VERSION }} | |
| path: zip_build/move-${{ env.VERSION }} |