From b5740726e3b1e148b273f13f9936d5583530e281 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Thu, 31 Oct 2024 17:14:42 +0000 Subject: [PATCH 1/5] CI: Split out poetry setup into composite action --- .github/actions/setup/action.yml | 22 ++++++++++++++++++++++ .github/workflows/ci.yml | 7 +------ 2 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 .github/actions/setup/action.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..494310d --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,22 @@ +name: Set up +description: Set up Python environment and install dependencies +inputs: + python-version: + description: The Python version to use + required: true + +runs: + using: composite + steps: + - name: Install Poetry + shell: bash + run: pipx install poetry + + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + cache: poetry + + - name: Install dependencies + shell: bash + run: poetry install diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c97ca6d..811cb7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,13 +19,8 @@ jobs: python-version: ['3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v4 - - name: Install poetry - run: pipx install poetry - - uses: actions/setup-python@v5 + - uses: ./.github/actions/setup with: python-version: ${{ matrix.python-version }} - cache: poetry - - name: Install dependencies - run: poetry install - name: Run tests run: poetry run pytest From c9dc3e7c8ddfa21b56011ae049909de95fb16240 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Thu, 31 Oct 2024 17:21:33 +0000 Subject: [PATCH 2/5] CI: Add workflow to publish on PyPI Closes #33. --- .github/workflows/release.yml | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..02df5af --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Release + +on: + release: + types: [published] + +jobs: + test: + uses: ./.github/workflows/ci.yml + + # If tests are successful, we build the wheel and push it to the release + build-wheel: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + with: + python-version: '3.13' + + - name: Build package + run: poetry build + + # Upload files as test artifact (to be retrieved later) + - uses: actions/upload-artifact@v4 + with: + path: dist/* + + # Publish files as release artifacts + - uses: softprops/action-gh-release@v2 + with: + files: dist/* + + # If all goes well, publish to PyPI + publish-pypi: + needs: build-wheel + name: Publish to PyPI + runs-on: ubuntu-latest + permissions: + id-token: write + + steps: + - name: Download wheel and sdist artifacts + uses: actions/download-artifact@v4 + with: + name: artifact + path: dist + + - name: Display structure of downloaded files + run: ls -R dist + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 From c0af4fd894c876e9d58da492f21289fc533e8dc0 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Fri, 1 Nov 2024 16:47:46 +0000 Subject: [PATCH 3/5] Add check that package version matches tag --- .github/workflows/release.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02df5af..0255954 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,14 @@ jobs: with: python-version: '3.13' + - name: Check package version matches tag + run: | + pkgver=$(python -c "import autocorpus; print(autocorpus.__version__, end='')") + + # NB: tag name must be prefixed by "v" (the default for GitHub Releases) + test v$pkgver = ${{ github.ref_name }} + + - name: Build package run: poetry build From 10c7d877024b42a4d0d8800870906de88b5230e7 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Fri, 1 Nov 2024 16:51:01 +0000 Subject: [PATCH 4/5] Whitespace --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0255954..5bc5f40 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,6 @@ jobs: # NB: tag name must be prefixed by "v" (the default for GitHub Releases) test v$pkgver = ${{ github.ref_name }} - - name: Build package run: poetry build From 54d730a963fdc2829a3e55b8e3454f95f9374c79 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Fri, 1 Nov 2024 16:51:24 +0000 Subject: [PATCH 5/5] Fix typo in pyproject.toml --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 269a544..c0e6fe3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,8 @@ keywords = [ "natural language processing", "text mining", "biomedical literature", - "semantics, health data", + "semantics", + "health data" ] classifiers = ["Intended Audience :: Science/Research"]