From f0e2756d9ca3d8408f6c360b941eb4cec04a879c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernst=20W=C3=BCrger?= Date: Tue, 2 Jul 2024 09:47:49 +0200 Subject: [PATCH] ci: Update ci (#115) --- .github/workflows/build-test-publish.yml | 95 ++++++++++++++++-------- 1 file changed, 65 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 8be70cde..ed784c04 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -4,10 +4,11 @@ name: Build on: + pull_request: push: - branches: ["*"] - pull_request: [master] + branches: [main] tags: ["v*.*.*"] + workflow_dispatch: jobs: test: @@ -17,17 +18,22 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python_version: ["3.10", "3.11", "3.12"] + python_version: + - "3.10" + - "3.11" + - "3.12" include: - os: windows-latest python_version: "3.11" env: PYTHONUTF8: 1 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{matrix.python_version}} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: + cache: pip + cache-dependency-path: pyproject.toml python-version: ${{matrix.python_version}} - uses: actions/setup-node@v4 with: @@ -41,40 +47,69 @@ jobs: ${{runner.os}}-pip- ${{runner.os}}- - name: Upgrade Pip - run: |- - python -m pip install -U pip + run: python -m pip install -U pip - name: Install test dependencies - run: |- - python -m pip install '.[test]' + run: python -m pip install '.[test]' - name: Run unit tests - run: |- - python -m pytest --cov-report=term --cov=capellambse_context_diagrams --rootdir=. + run: python -m pytest --cov-report=term --cov=capellambse_context_diagrams --rootdir=. - publish: - name: Publish artifacts + build: + name: Build wheel runs-on: ubuntu-latest - needs: test steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: "3.11" + cache: pip + cache-dependency-path: pyproject.toml + python-version: "3.12" - name: Install dependencies - run: |- - python -m pip install -U pip - python -m pip install build twine + run: python -m pip install -U pip build twine - name: Build packages - run: |- - python -m build + run: python -m build - name: Verify packages - run: |- - python -m twine check dist/* + run: python -m twine check dist/* - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + if-no-files-found: error + + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + cache: pip + cache-dependency-path: pyproject.toml + python-version: "3.12" + - name: Upgrade pip + run: python -m pip install -U pip + - name: Install pre-commit + run: python -m pip install pre-commit + - name: Run Pre-Commit + run: pre-commit run --all-files + + pypi: + name: Publish to PyPI + runs-on: ubuntu-latest + needs: [build, test] + if: startsWith(github.ref, 'refs/tags/v') + environment: + name: pypi + url: https://pypi.org/project/capella-polarion + permissions: + id-token: write + steps: + - name: Download built wheel + uses: actions/download-artifact@v4 with: - name: Artifacts - path: "dist/*" - - name: Publish to PyPI (release only) - if: startsWith(github.ref, 'refs/tags/v') - run: python -m twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }} --non-interactive dist/* + name: python-package-distributions + path: dist/ + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1