|
| 1 | +name: "📦 Packaging & 🚀 Release" |
| 2 | + |
| 3 | +env: |
| 4 | + PROJECT_FOLDER: "profile_manager" |
| 5 | + PYTHON_VERSION: 3.9 |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + tags: |
| 12 | + - "*" |
| 13 | + |
| 14 | + pull_request: |
| 15 | + branches: |
| 16 | + - main |
| 17 | + paths: |
| 18 | + - .github/workflows/packager.yml |
| 19 | + - requirements/packaging.txt |
| 20 | + - profile_manager/**/* |
| 21 | + |
| 22 | +# Allow one concurrent deployment per branch/pr |
| 23 | +concurrency: |
| 24 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + translation: |
| 29 | + name: "💬 i18n compilation" |
| 30 | + runs-on: ubuntu-latest |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Get source code |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Setup Python |
| 37 | + uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: ${{ env.PYTHON_VERSION }} |
| 40 | + cache: "pip" |
| 41 | + |
| 42 | + - name: Install system requirements |
| 43 | + run: | |
| 44 | + sudo apt update |
| 45 | + sudo apt install qt5-qmake qttools5-dev-tools |
| 46 | + python3 -m pip install -U pyqt5-tools |
| 47 | +
|
| 48 | + - name: Update translations |
| 49 | + run: pylupdate5 -noobsolete -verbose ${{ env.PROJECT_FOLDER }}/resources/i18n/plugin_translation.pro |
| 50 | + |
| 51 | + - name: Compile translations |
| 52 | + run: lrelease ${{ env.PROJECT_FOLDER }}/resources/i18n/*.ts |
| 53 | + |
| 54 | + - uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: translations-build |
| 57 | + path: ${{ env.PROJECT_FOLDER }}/**/*.qm |
| 58 | + if-no-files-found: error |
| 59 | + |
| 60 | + # -- NO TAGS ---------------------------------------------------------------------- |
| 61 | + packaging: |
| 62 | + name: "📦 Packaging plugin" |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: |
| 65 | + - translation |
| 66 | + |
| 67 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Checkout |
| 71 | + uses: actions/checkout@v4 |
| 72 | + |
| 73 | + - name: Setup Python |
| 74 | + uses: actions/setup-python@v5 |
| 75 | + with: |
| 76 | + python-version: ${{ env.PYTHON_VERSION }} |
| 77 | + cache: "pip" |
| 78 | + cache-dependency-path: "requirements/packaging.txt" |
| 79 | + |
| 80 | + - name: Install project requirements |
| 81 | + run: | |
| 82 | + python -m pip install -U pip setuptools wheel |
| 83 | + python -m pip install -U -r requirements/packaging.txt |
| 84 | +
|
| 85 | + - name: Download translations |
| 86 | + uses: actions/download-artifact@v4 |
| 87 | + with: |
| 88 | + name: translations-build |
| 89 | + path: ${{ env.PROJECT_FOLDER }} |
| 90 | + |
| 91 | + - name: List files |
| 92 | + run: tree ${{ env.PROJECT_FOLDER }} |
| 93 | + |
| 94 | + - name: Amend gitignore to include compiled translations and add it to tracked files |
| 95 | + run: | |
| 96 | + # include compiled translations |
| 97 | + sed -i "s|^*.qm.*| |" .gitignore |
| 98 | +
|
| 99 | + # include LICENSE file since it's mandatory |
| 100 | + cp LICENSE ${{ env.PROJECT_FOLDER }}/ |
| 101 | + sed -i "s|^${{ env.PROJECT_FOLDER }}/LICENSE| |" .gitignore |
| 102 | +
|
| 103 | + # git add full project |
| 104 | + git add ${{ env.PROJECT_FOLDER }}/ |
| 105 | +
|
| 106 | + - name: Package the latest version |
| 107 | + env: |
| 108 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 109 | + run: | |
| 110 | + qgis-plugin-ci package latest \ |
| 111 | + --allow-uncommitted-changes \ |
| 112 | + --plugin-repo-url $(gh api "repos/$GITHUB_REPOSITORY/pages" --jq '.html_url') |
| 113 | +
|
| 114 | + - uses: actions/upload-artifact@v4 |
| 115 | + with: |
| 116 | + name: ${{ env.PROJECT_FOLDER }}-latest |
| 117 | + path: | |
| 118 | + plugins.xml |
| 119 | + ${{ env.PROJECT_FOLDER }}.*.zip |
| 120 | + if-no-files-found: error |
| 121 | + |
| 122 | + # -- ONLY TAGS ---------------------------------------------------------------------- |
| 123 | + release: |
| 124 | + name: "🚀 Release on tag" |
| 125 | + runs-on: ubuntu-latest |
| 126 | + needs: |
| 127 | + - translation |
| 128 | + |
| 129 | + if: startsWith(github.ref, 'refs/tags/') |
| 130 | + |
| 131 | + steps: |
| 132 | + - name: Get tag name as version |
| 133 | + id: get_version |
| 134 | + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} |
| 135 | + |
| 136 | + - name: Checkout |
| 137 | + uses: actions/checkout@v4 |
| 138 | + |
| 139 | + - name: Setup Python |
| 140 | + uses: actions/setup-python@v5 |
| 141 | + with: |
| 142 | + python-version: ${{ env.PYTHON_VERSION }} |
| 143 | + cache: "pip" |
| 144 | + cache-dependency-path: "requirements/packaging.txt" |
| 145 | + |
| 146 | + - name: Install project requirements |
| 147 | + run: | |
| 148 | + python -m pip install -U pip setuptools wheel |
| 149 | + python -m pip install -U -r requirements/packaging.txt |
| 150 | +
|
| 151 | + - name: Download translations |
| 152 | + uses: actions/download-artifact@v4 |
| 153 | + with: |
| 154 | + name: translations-build |
| 155 | + path: ${{ env.PROJECT_FOLDER }} |
| 156 | + |
| 157 | + - name: Amend gitignore to include compiled translations and add it to tracked files |
| 158 | + run: | |
| 159 | + # include compiled translations |
| 160 | + sed -i "s|^*.qm.*| |" .gitignore |
| 161 | +
|
| 162 | + # include LICENSE file since it's mandatory |
| 163 | + cp LICENSE ${{ env.PROJECT_FOLDER }}/ |
| 164 | + sed -i "s|^${{ env.PROJECT_FOLDER }}/LICENSE| |" .gitignore |
| 165 | +
|
| 166 | + # git add full project |
| 167 | + git add ${{ env.PROJECT_FOLDER }}/ |
| 168 | +
|
| 169 | + - name: Create GitHub Release |
| 170 | + uses: softprops/action-gh-release@v2 |
| 171 | + with: |
| 172 | + fail_on_unmatched_files: true |
| 173 | + generate_release_notes: true |
| 174 | + |
| 175 | + - name: Deploy plugin |
| 176 | + run: >- |
| 177 | + qgis-plugin-ci |
| 178 | + release ${GITHUB_REF/refs\/tags\//} |
| 179 | + --allow-uncommitted-changes |
| 180 | + --create-plugin-repo |
| 181 | + --github-token ${{ secrets.GITHUB_TOKEN }} |
| 182 | + --osgeo-username ${{ secrets.OSGEO_USER }} |
| 183 | + --osgeo-password ${{ secrets.OSGEO_PASSWORD }} |
0 commit comments