From fbb0b1688aecee624288ddbc628d372618d90b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kucmus?= Date: Tue, 21 Nov 2023 17:41:41 +0100 Subject: [PATCH] add publish and docs pipelines --- .github/workflows/docs.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 18 ++++++++++++++++++ .github/workflows/test.yml | 34 ++++++++++++++++++---------------- 3 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..b33c1a6 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,31 @@ +name: docs + +on: + push: + branches: + - main + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Configure Git Credentials + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v3 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + - run: pip install hatch + - run: hatch docs:deploy diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8e3a0e5 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,18 @@ +name: release + +on: + release: + types: + - published + +jobs: + pypi-publish: + name: upload release to PyPI + runs-on: ubuntu-latest + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 825c5ba..b84fb9d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + # os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] python-version: ['3.10', '3.11', '3.12'] steps: @@ -42,17 +43,17 @@ jobs: - name: Coverage run: hatch run test-cov - - - name: Disambiguate coverage filename - run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}" + env: + COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} + CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} - name: Upload coverage data uses: actions/upload-artifact@v3 with: name: coverage-data - path: .coverage.* + path: coverage - coverage: + coverage-combine: name: Report coverage runs-on: ubuntu-latest needs: @@ -75,18 +76,19 @@ jobs: - name: Combine coverage data run: hatch run cov-report - + # https://github.com/marketplace/actions/alls-green#why - check: # This job does nothing and is only used for the branch protection + check: # This job does nothing and is only used for the branch protection if: always() - needs: - - coverage - + - coverage-combine runs-on: ubuntu-latest - steps: - - name: Decide whether the needed jobs succeeded or failed - uses: re-actors/alls-green@release/v1 - with: - jobs: ${{ toJSON(needs) }} + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }}