Skip to content

Commit

Permalink
Update for year 2024
Browse files Browse the repository at this point in the history
- Use `pyproject.toml` and Hatchling
- Update CI workflow and actions versions
- Enable attestations for publishing
- Publish releases on Test PyPI and GitHub
- Drop Python 3.6 and 3.7 support due to EOL
- Add Python 3.12 and 3.13.0-rc.1 to the test matrix
  • Loading branch information
ei-grad committed Sep 5, 2024
1 parent 4596f3a commit 4005e52
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 66 deletions.
112 changes: 84 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@ on:
pull_request:

jobs:

build:
name: Build wheel
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install setuptools and wheel
run: pip install setuptools wheel
- name: Run bdist_wheel
run: python setup.py bdist_wheel --universal
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install build
run: pip install build
- name: Build distribution
run: python -m build .
- name: File list
run: tar tf dist/*.tar.gz && unzip -l dist/*.whl
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheel
path: dist/*.whl
name: dist
path: dist/

test:
name: Run tests
needs: build
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.1"]
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download wheel from artifacts
uses: actions/download-artifact@v3
with:
name: wheel
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Install wheel
shell: bash
run: pip install *.whl
run: pip install dist/*.whl
- name: Make it use package from wheel
shell: bash
run: rm flask_shell_ipython.py
Expand All @@ -54,19 +54,75 @@ jobs:
if: runner.os == 'Windows'
shell: bash
run: pytest --collect-only -q | grep ^test_ | while read testname; do pytest -q $testname; done
pypi-publish:
name: Upload release to PyPI

pypi-publish-test:
name: Release on Test PyPI
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
environment: release
environment:
name: Test PyPI
url: "https://test.pypi.org/project/flask-shell-ipython/"
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: "https://test.pypi.org/legacy/"
attestations: true

github-release:
name: Release on GitHub
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: GitHub
url: "https://github.com/ei-grad/flask-shell-ipython/releases/"
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v3
with:
name: wheel
path: dist/
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--generate-notes
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
pypi-publish:
name: Release on PyPI
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: PyPI
url: "https://pypi.org/project/flask-shell-ipython/"
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ ENV/

# Rope project settings
.ropeproject

flask_shell_ipython-*/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The MIT License (MIT)
MIT License

Copyright (c) 2016 Andrew Grigorev

Expand Down
43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[build-system]
requires = ["hatchling==1.25.0"]
build-backend = "hatchling.build"

[project]
name = "flask-shell-ipython"
version = "0.5.2"
description = "Replace default `flask shell` command by similar command running IPython."
readme = "README.md"
readme-content-type = "text/markdown"
requires-python = ">=3.8, <4.0"
license = "MIT"
# expect `license-files` field to break on any new version of hatch, because
# PEP-639 is already changed from this structure as of the time of writing
license-files = { paths = ["LICENSE"] }
authors = [
{ name = "Andrew Grigorev", email = "[email protected]" }
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Framework :: Flask",
"Framework :: IPython",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
]

dependencies = [
"Flask>=1.0",
"click",
"IPython>=5.0.0"
]

[project.urls]
Homepage = "https://github.com/ei-grad/flask-shell-ipython"

[project.entry-points."flask.commands"]
shell = "flask_shell_ipython:shell"

[tool.hatch.build.targets.sdist]
exclude = [
".github",
]
5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

32 changes: 0 additions & 32 deletions setup.py

This file was deleted.

0 comments on commit 4005e52

Please sign in to comment.