From e86f3182d8b31a239bad483a009a18ccb0efb441 Mon Sep 17 00:00:00 2001 From: Tom de Geus Date: Mon, 23 Oct 2023 21:03:27 +0200 Subject: [PATCH] CI: various updates --- .github/workflows/ci.yml | 28 +++++++++++++----- .github/workflows/pre-commit.yml | 5 ++-- .github/workflows/pythonpublish.yml | 46 +++++++++++++++++++---------- 3 files changed, 54 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9cc6d3..1fa5e82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: jobs: - default-shell: + standard: strategy: fail-fast: false @@ -17,25 +17,37 @@ jobs: defaults: run: - shell: bash -l {0} + shell: bash -e -l {0} - name: ${{ matrix.runs-on }} • x64 ${{ matrix.args }} + name: ${{ matrix.runs-on }} runs-on: ${{ matrix.runs-on }} steps: - - name: Basic GitHub action setup + - name: Clone this library uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Set conda environment - uses: mamba-org/provision-with-micromamba@main + - name: Create conda environment + uses: mamba-org/setup-micromamba@main with: environment-file: environment.yaml environment-name: myenv - cache-env: true + init-shell: bash + cache-downloads: true + + - name: Export version of this library + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "SETUPTOOLS_SCM_PRETEND_VERSION=$LATEST_TAG" >> $GITHUB_ENV - name: Install library - run: python -m pip install . + run: python -m pip install . -v --no-build-isolation --no-deps - name: Run tests run: python -m unittest discover tests -v + + - name: Build docs + working-directory: docs + run: make html diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index a3e22ca..5d6336e 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,6 +1,7 @@ name: pre-commit on: + workflow_dispatch: pull_request: push: branches: [main] @@ -10,5 +11,5 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.3 + - uses: actions/setup-python@v4 + - uses: pre-commit/action@main diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 413e835..78cb1b3 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -1,26 +1,42 @@ name: Upload Python Package on: + workflow_dispatch: release: types: [created] jobs: - deploy: + + pypi-publish: + + name: Upload release to PyPI + runs-on: ubuntu-latest + + environment: + name: pypi + url: https://pypi.org/p/enstat + + permissions: + id-token: write + steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v2 + - name: Checkout + uses: actions/checkout@v3 with: - python-version: 3.x - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + fetch-depth: 0 + + - name: Set latest release tag run: | - python setup.py sdist bdist_wheel - twine upload dist/* + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + echo "SETUPTOOLS_SCM_PRETEND_VERSION=$LATEST_TAG" >> $GITHUB_ENV + + - name: Install deps + run: python -m pip install -U setuptools build wheel + + - name: Build + run: python -m build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1