From 6ecce9c692c3c6751208577acb90c0b29363c6ae Mon Sep 17 00:00:00 2001 From: Axel Haustant Date: Fri, 28 Jun 2024 16:56:56 +0200 Subject: [PATCH] feat(pdm): attach builded library to the workflow and the PR if any --- pdm/test/README.md | 1 + pdm/test/action.yml | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/pdm/test/README.md b/pdm/test/README.md index 9536d6c0..15117f93 100644 --- a/pdm/test/README.md +++ b/pdm/test/README.md @@ -16,6 +16,7 @@ jobs: | Input | Description | Default | Required | |-------|-------------|---------|----------| +| `kind` | Kind of project to release (`lib`/`app`) | `app` | `true` | | `python-version` | Python version to run the tests with | `3.11` | `true` | | `pypi-token` | A Token to Ledger private PyPI with read permissions | `""` | `true` | | `github-token` | A Github token with proper permissions | `${{ github.token }}` | `false` | diff --git a/pdm/test/action.yml b/pdm/test/action.yml index 47670320..63c3389b 100644 --- a/pdm/test/action.yml +++ b/pdm/test/action.yml @@ -2,6 +2,9 @@ name: Test description: Execute test using `pdm` scripts inputs: + kind: + description: Kind of project to release (lib/app) + default: app python-version: description: Python version to run the tests with required: true @@ -134,3 +137,35 @@ runs: curl -X POST -H "Content-Type:text/xml" -d @reports/coverage.xml "${REPORT_URL}&coverageType=cobertura" echo "📊 Coverage report uploaded to Backstage: <${REPORT_URL}>" >> $GITHUB_STEP_SUMMARY shell: bash + + - name: Build the library + if: inputs.kind == 'lib' + run: pdm build + env: + FORCE_COLOR: 'true' + shell: bash + + - name: Attached built library (wheel & sdist) as a workflow artifact + id: upload-lib + if: inputs.kind == 'lib' + uses: actions/upload-artifact@v4 + with: + name: library + path: | + dist/*.whl + dist/*.tar.gz + retention-days: 7 + if-no-files-found: error + + - name: Add built library link to the summary + if: inputs.kind == 'lib' + run: echo "[📦 Built library (wheel & sdist)](${{ steps.upload-lib.outputs.artifact-url }})" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: Add built library link to the pull-request + if: inputs.kind == 'lib' && steps.meta.outputs.is_pr + continue-on-error: true + uses: thollander/actions-comment-pull-request@v2 + with: + message: "[📦 Built library (wheel & sdist)](${{ steps.upload-lib.outputs.artifact-url }})" + comment_tag: library