diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..64604cf --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,22 @@ +changelog: + exclude: + authors: + - dependabot + - pre-commit-ci + categories: + - title: Bugs fixes 🐛 + labels: + - bug + - title: Features and enhancements 🎉 + labels: + - enhancement + - UI + - title: Tooling 🔧 + labels: + - ci-cd + - title: Documentation 📖 + labels: + - documentation + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 11d3fa8..3cc55bd 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -87,7 +87,7 @@ jobs: name: ${{ env.PROJECT_FOLDER }}-latest path: docs/_build/html/ # run_id: ${{ github.event.workflow_run.id }} - workflow: packager.yml + workflow: package_and_release.yml - name: Setup Pages uses: actions/configure-pages@v5 diff --git a/.github/workflows/package_and_release.yml b/.github/workflows/package_and_release.yml new file mode 100644 index 0000000..a86a74c --- /dev/null +++ b/.github/workflows/package_and_release.yml @@ -0,0 +1,168 @@ +name: "📦 Packaging & 🚀 Release" + +env: + PROJECT_FOLDER: "menu_from_project" + PYTHON_VERSION: 3.9 + +on: + push: + branches: + - master + tags: + - "*" + + pull_request: + branches: + - main + paths: + - .github/workflows/package_and_release.yml + - requirements/packaging.txt + - menu_from_project/**/* + +# Allow one concurrent deployment per branch/pr +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + translation: + name: "💬 i18n compilation" + runs-on: ubuntu-latest + + steps: + - name: Get source code + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: "pip" + + - name: Install system requirements + run: | + sudo apt update + sudo apt install qt5-qmake qttools5-dev-tools + python3 -m pip install -U pyqt5-tools + + - name: Update translations + run: pylupdate5 -noobsolete -verbose ${{ env.PROJECT_FOLDER }}/resources/i18n/plugin_translation.pro + + - name: Compile translations + run: lrelease ${{ env.PROJECT_FOLDER }}/resources/i18n/*.ts + + - uses: actions/upload-artifact@v4 + with: + name: translations-build + path: ${{ env.PROJECT_FOLDER }}/**/*.qm + if-no-files-found: error + + packaging: + name: "📦 Packaging plugin" + runs-on: ubuntu-latest + needs: + - translation + + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + cache: "pip" + cache-dependency-path: "requirements/packaging.txt" + + - name: Install project requirements + run: | + python -m pip install -U pip setuptools wheel + python -m pip install -U -r requirements/packaging.txt + + - name: Download translations + uses: actions/download-artifact@v4 + with: + name: translations-build + path: ${{ env.PROJECT_FOLDER }} + + - name: Amend gitignore to include compiled translations and add it to tracked files + run: | + # include compiled translations + sed -i "s|^*.qm.*| |" .gitignore + + # git add full project + git add ${{ env.PROJECT_FOLDER }}/ + + - name: Package the latest version + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + qgis-plugin-ci package latest \ + --allow-uncommitted-changes \ + --plugin-repo-url $(gh api "repos/$GITHUB_REPOSITORY/pages" --jq '.html_url') + + - name: + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PROJECT_FOLDER }}-latest + path: | + plugins.xml + ${{ env.PROJECT_FOLDER }}.*.zip + if-no-files-found: error + +# -- ONLY TAGS ---------------------------------------------------------------------- + release: + name: "🚀 Release on tag" + runs-on: ubuntu-latest + needs: + - translation + + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: "pip" + cache-dependency-path: "requirements/packaging.txt" + + - name: Install project requirements + run: | + python -m pip install -U pip setuptools wheel + python -m pip install -U -r requirements/packaging.txt + + - name: Download translations + uses: actions/download-artifact@v4 + with: + name: translations-build + path: ${{ env.PROJECT_FOLDER }} + + - name: Amend gitignore to include compiled translations and add it to tracked files + run: | + # include compiled translations + sed -i "s|^*.qm.*| |" .gitignore + + # git add full project + git add ${{ env.PROJECT_FOLDER }}/ + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + fail_on_unmatched_files: true + generate_release_notes: true + + - name: Deploy plugin + run: >- + qgis-plugin-ci + release ${GITHUB_REF/refs\/tags\//} + --allow-uncommitted-changes + --create-plugin-repo + --github-token ${{ secrets.GITHUB_TOKEN }} + --osgeo-username ${{ secrets.OSGEO_USER }} + --osgeo-password ${{ secrets.OSGEO_PASSWORD }} diff --git a/.github/workflows/packager.yml b/.github/workflows/packager.yml deleted file mode 100644 index 09cc318..0000000 --- a/.github/workflows/packager.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Packager 📦 - -env: - PROJECT_FOLDER: "menu_from_project" - PYTHON_VERSION: 3.8 - -on: - push: - branches: [ master ] - -jobs: - packaging: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@master - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '${{ env.PYTHON_VERSION }}' - - - uses: actions/cache@v4.1.2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install project requirements - run: | - python -m pip install -U pip setuptools wheel - python -m pip install -U 'qgis-plugin-ci>=2.2,<2.8' - - - name: Package the latest version - run: | - qgis-plugin-ci package latest - - - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PROJECT_FOLDER }}-latest - path: ${{ env.PROJECT_FOLDER }}.*.zip - if-no-files-found: error diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 9fc07d3..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Release 🚀 - -env: - PROJECT_FOLDER: "menu_from_project" - PYTHON_VERSION: 3.8 - -on: - push: - tags: - - '*' - -jobs: - package: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - # - name: Install Qt lrelease - # run: sudo apt install qt5-default qttools5-dev-tools - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '${{ env.PYTHON_VERSION }}' - - - name: Install project requirements - run: | - python -m pip install -U pip setuptools wheel - python -m pip install -U 'qgis-plugin-ci>=2.2,<2.8' - - - id: get-myversion - run: | - echo "myversion=$(echo ${{ github.ref }} | cut -dv -f2)" >> "$GITHUB_ENV" - # echo "::set-output name=myversion::$myversion" - # echo "name=myversion::$myversion" >> $GITHUB_OUTPUT - - # - run: echo "${{steps.get-myversion.outputs.myversion}}" - - run: echo ${{ env.myversion }} - - - name: Package the version - run: | - qgis-plugin-ci package ${{ env.myversion }} - - - name : Get current changelog for ${{ github.ref }} - run: qgis-plugin-ci changelog ${{ env.myversion }} >> release.md - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - body_path: release.md - - - name: upload plugin artifact - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ env.PROJECT_FOLDER }}.${{ env.myversion }}.zip - asset_name: ${{ env.PROJECT_FOLDER }}-${{ env.myversion }}.zip - asset_content_type: application/zip - - # plante.. pb de version de qgis-plugin-ci ? - #- name: Deploy plugin to QGIS official repository and as release asset - # run: >- - # qgis-plugin-ci - # release v${{ env.myversion }} - # --github-token ${{ secrets.GITHUB_TOKEN }} - # --osgeo-username ${{ secrets.OSGEO_USER }} - # --osgeo-password ${{ secrets.OSGEO_PASSWORD }} diff --git a/menu_from_project/LICENSE b/LICENSE similarity index 100% rename from menu_from_project/LICENSE rename to LICENSE diff --git a/menu_from_project/plugin_translation.pro b/menu_from_project/i18n/plugin_translation.pro similarity index 100% rename from menu_from_project/plugin_translation.pro rename to menu_from_project/i18n/plugin_translation.pro