From c9a4d13ab4e808ef02250898a79c07b2acf76f61 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 15 Jun 2023 20:38:44 -0300 Subject: [PATCH] Improve CI * Create package only once * Split deploy in two steps * Uploaded packages also to GitHub releases --- .github/workflows/deploy.yml | 22 +++++++++++++++------ .github/workflows/test.yml | 37 +++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e7204f6..6d97011 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,12 +10,8 @@ on: jobs: - deploy: + package: runs-on: ubuntu-latest - environment: deploy - permissions: - id-token: write # For PyPI trusted publishers. - contents: write # For tag and release notes. env: SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }} @@ -25,6 +21,17 @@ jobs: - name: Build and Check Package uses: hynek/build-and-inspect-python-package@v1.5 + deploy: + needs: package + runs-on: ubuntu-latest + environment: deploy + permissions: + id-token: write # For PyPI trusted publishers. + contents: write # For tag and release notes. + + steps: + - uses: actions/checkout@v3 + - name: Download Package uses: actions/download-artifact@v3 with: @@ -36,7 +43,9 @@ jobs: - name: Push tag run: | - git tag v${{ github.event.inputs.version }} ${{ github.sha }} + git config user.name "pytest bot" + git config user.email "pytestbot@gmail.com" + git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }} git push origin v${{ github.event.inputs.version }} - name: Set up Python @@ -54,3 +63,4 @@ jobs: uses: softprops/action-gh-release@v1 with: body_path: scripts/latest-release-notes.md + files: dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa33bb5..fdea6f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,13 @@ name: test -on: [push, pull_request] +on: + push: + branches: + - main + - "test-me-*" + + pull_request: + concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -8,8 +15,17 @@ concurrency: jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build and Check Package + uses: hynek/build-and-inspect-python-package@v1.5 + test: + needs: [package] + runs-on: ${{ matrix.os }} strategy: @@ -31,21 +47,24 @@ jobs: steps: - uses: actions/checkout@v3 + + - name: Download Package + uses: actions/download-artifact@v3 + with: + name: Packages + path: dist + - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} + - name: Install tox run: | python -m pip install --upgrade pip pip install tox + - name: Test + shell: bash run: | - tox -e ${{ matrix.tox_env }} - - check-package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v1.5 + tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`