-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Publish to PyPi workflow Made the version dynamic using setuptools_scm and publish to PyPi using a github action and "trusted publishers" * Fix lint and format * Remove _version.py from tracking * exclude _version.py from pyright and flake8 * removed testpypi from workflow * Changed script to run on release creation * Add dependency caching
- Loading branch information
Showing
6 changed files
with
109 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Publish Python 🐍 distribution 📦 to PyPI | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: >- | ||
Publish Python 🐍 distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/sqlelf | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
github-release: | ||
name: >- | ||
Sign the Python 🐍 distribution 📦 with Sigstore | ||
and upload them to GitHub Release | ||
needs: | ||
- publish-to-pypi | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ github.ref_name }}' dist/** | ||
--repo '${{ github.repository }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ temp/ | |
nosetests.xml | ||
coverage.xml | ||
htmlcov | ||
sqlelf/_version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
[build-system] | ||
requires = ["setuptools", "setuptools-scm"] | ||
requires = ["setuptools", "setuptools-scm[toml]", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "sqlelf" | ||
version = "0.0.1" | ||
# Using the dynamic version | ||
# version = "0.0.1" | ||
dynamic = ["version"] | ||
authors = [{ name = "Farid Zakaria", email = "[email protected]" }] | ||
readme = "README.md" | ||
description = "Explore ELF objects through the power of SQL" | ||
|
@@ -41,6 +43,9 @@ dev = [ | |
"mypy >= 1.0.0", | ||
] | ||
|
||
[tool.setuptools_scm] | ||
write_to = "sqlelf/_version.py" | ||
|
||
[tool.setuptools] | ||
packages = ["sqlelf"] | ||
|
||
|
@@ -55,12 +60,12 @@ profile = "black" | |
addopts = "" | ||
|
||
[tool.pyright] | ||
include = ["sqlelf", "tests"] | ||
exclude = ["**/__pycache__"] | ||
exclude = ["**/__pycache__", "sqlelf/_version.py"] | ||
|
||
reportMissingImports = true | ||
reportMissingTypeStubs = true | ||
useLibraryCodeForTypes = true | ||
|
||
pythonVersion = "3.10" | ||
pythonPlatform = "Linux" | ||
include = ["sqlelf", "tests"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[flake8] | ||
extend-ignore = E203 | ||
max-line-length = 88 | ||
max-line-length = 88 | ||
exclude = | ||
_version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
from importlib.metadata import PackageNotFoundError, version | ||
|
||
import apsw.bestpractice | ||
|
||
# forward sqlite logs to logging module | ||
apsw.bestpractice.apply(apsw.bestpractice.recommended) | ||
|
||
try: | ||
__version__ = version("sqlelf") | ||
except PackageNotFoundError: | ||
# If the package is not installed, don't add __version__ | ||
pass |