From 60c86229ac99668961d0856feac82009e8715c86 Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 5 Jan 2024 00:32:01 +0100 Subject: [PATCH] cicd: merge test and release jobs Using workflow_run event didn't work out, as it only is triggered on ref `main`, not `tags/v`. --- .github/workflows/{test.yaml => cicd.yaml} | 105 ++++++++++++++++++- .github/workflows/release.yaml | 112 --------------------- 2 files changed, 101 insertions(+), 116 deletions(-) rename .github/workflows/{test.yaml => cicd.yaml} (67%) delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/cicd.yaml similarity index 67% rename from .github/workflows/test.yaml rename to .github/workflows/cicd.yaml index 09f6b9da..b2b2865c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/cicd.yaml @@ -113,8 +113,8 @@ jobs: path-to-lcov: coverage.lcov parallel: true - python-package: - name: Python package + test-python-package: + name: Test Python package build runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -131,8 +131,8 @@ jobs: - name: Test build python package run: hatch build - briefcase-build: - name: Briefcase build + test-briefcase: + name: Test Briefcase build runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -207,3 +207,100 @@ jobs: uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 + + deploy-briefcase: + name: Briefcase build & draft release + needs: + - test + - test-briefcase + - test-python-package + if: | + startsWith(github.ref, 'refs/tags/v') + && github.repository_owner == 'dynobo' + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04, macos-12, windows-2022] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: "pip" + - name: Install hatch + run: pip install hatch + - name: Build package briefcase + shell: bash -l {0} + run: hatch run bundle + - name: Draft release + if: github.repository == 'dynobo/normcap' + uses: ncipollo/release-action@v1 + with: + body: + See [CHANGELOG](https://github.com/dynobo/normcap/blob/main/CHANGELOG) for + details. + artifacts: "*/*.+(dmg|AppImage|msi|zip)" + artifactErrorsFailBuild: false + allowUpdates: true + draft: true + token: ${{ secrets.GITHUB_TOKEN }} + - name: FTP upload windows package + if: matrix.os == 'windows-2022' && github.repository == 'dynobo/normcap' + uses: SamKirkland/FTP-Deploy-Action@v4.3.4 + with: + server: ${{ secrets.WEBGO_FTP_HOST }} + username: ${{ secrets.WEBGO_FTP_USER }} + password: ${{ secrets.WEBGO_FTP_PASS }} + protocol: ftps + local-dir: ./bundle/ + exclude: | + **/platforms/** + **/imgs/** + **/*.py + **/*.wxs + **/*.wxs + **/metainfo + + deploy-pypi: + name: Publish to PyPi + needs: deploy-briefcase + runs-on: ubuntu-22.04 + permissions: + # Used to authenticate to PyPI via OIDC. + # Used to sign the release's artifacts with sigstore-python. + id-token: write + # Used to attach signing artifacts to the published release. + contents: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: "pip" + - name: Install hatch + run: pip install hatch + - name: Build Python package + run: hatch build + - name: Publish to PyPi + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + print-hash: true + - name: Sign published artifacts + uses: sigstore/gh-action-sigstore-python@v2.1.1 + with: + inputs: ./dist/*.tar.gz ./dist/*.whl + release-signing-artifacts: true + + release-documentation: + name: Deploy github pages + needs: deploy-briefcase + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Deploy pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 76730acf..00000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,112 +0,0 @@ -# Infos on current github runners: -# https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners#about-github-hosted-runners - -name: Release - -on: - workflow_run: - workflows: ["Test"] - types: - - completed - -jobs: - debug: - name: Workflow debug info - runs-on: ubuntu-22.04 - steps: - - run: echo "Workflow ${{ github.workflow }} is running on ${{ github.ref }} with ${{ github.event_name }} event" - - run: echo "Repo owner is ${{ github.repository_owner }}" - - run: echo "Event workflow conclusion was ${{ github.event.workflow_run.conclusion }}" - briefcase: - name: Briefcase build & draft release - if: | - startsWith(github.ref, 'refs/tags/v') - && github.repository_owner == 'dynobo' - && github.event.workflow_run.conclusion == 'success' - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-22.04, macos-12, windows-2022] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.10" - cache: "pip" - - name: Install hatch - run: pip install hatch - - name: Build package briefcase - shell: bash -l {0} - run: hatch run bundle - - name: Draft release - if: github.repository == 'dynobo/normcap' - uses: ncipollo/release-action@v1 - with: - body: - See [CHANGELOG](https://github.com/dynobo/normcap/blob/main/CHANGELOG) for - details. - artifacts: "*/*.+(dmg|AppImage|msi|zip)" - artifactErrorsFailBuild: false - allowUpdates: true - draft: true - token: ${{ secrets.GITHUB_TOKEN }} - - name: FTP upload windows package - if: matrix.os == 'windows-2022' && github.repository == 'dynobo/normcap' - uses: SamKirkland/FTP-Deploy-Action@v4.3.4 - with: - server: ${{ secrets.WEBGO_FTP_HOST }} - username: ${{ secrets.WEBGO_FTP_USER }} - password: ${{ secrets.WEBGO_FTP_PASS }} - protocol: ftps - local-dir: ./bundle/ - exclude: | - **/platforms/** - **/imgs/** - **/*.py - **/*.wxs - **/*.wxs - **/metainfo - - pypi: - name: Publish to PyPi - needs: briefcase - runs-on: ubuntu-22.04 - permissions: - # Used to authenticate to PyPI via OIDC. - # Used to sign the release's artifacts with sigstore-python. - id-token: write - # Used to attach signing artifacts to the published release. - contents: write - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.10" - cache: "pip" - - name: Install hatch - run: pip install hatch - - name: Build Python package - run: hatch build - - name: Publish to PyPi - uses: pypa/gh-action-pypi-publish@release/v1 - with: - verbose: true - print-hash: true - - name: Sign published artifacts - uses: sigstore/gh-action-sigstore-python@v2.1.1 - with: - inputs: ./dist/*.tar.gz ./dist/*.whl - release-signing-artifacts: true - - documentation: - name: Deploy github pages - needs: briefcase - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - name: Deploy pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs