Skip to content

Commit

Permalink
New gh-action to publish on pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
dalito committed Aug 22, 2023
1 parent 8b98d55 commit dfd70db
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 18 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Publish Python Package
# Publishes to
# - PyPI on releases created in GitHub UI
# - TestPyPI on tags v1.2.3 or v1.2.3.something

on:
push:
tags:
# GitHub glob matching is limited [1]. So we can't define a pattern matching
# pep 440 version definition [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
- 'v[0-9]+.[0-9]+.[0-9]+.?*'
release:
types: [published]

jobs:
build:
name: Build Python 🐍 distributions 📦 for publishing
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install hatch
run: pipx install hatch

- name: Build source and wheel archives
run: hatch build

- name: Store built distribution
uses: actions/upload-artifact@v3
with:
name: distribution-files
path: dist/

pypi-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi-release
url: https://pypi.org/p/voc4cat
permissions:
id-token: write # this permission is mandatory for trusted publishing
steps:
- name: Download built distribution
uses: actions/download-artifact@v3
with:
name: distribution-files

# pinned version 1.8.10 [2]
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e
with:
repository-url: https://test.pypi.org/legacy/

- name: Publish distribution 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e

# [1] https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
# [2] https://github.com/pypa/gh-action-pypi-publish/
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log

## Release 0.7.1 (2023-08-22)

First release to upload to PyPI.

There were no functional changes since 0.7.0.

## Release 0.7.0 (2023-08-16)

New features:
Expand Down
23 changes: 5 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[build-system]
#requires = ["setuptools", "setuptools_scm[toml]>=6.2"]
#build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

Expand All @@ -22,7 +20,7 @@ license = {file = "LICENSE"}
readme = "README.md"
requires-python = ">=3.8"

keywords = ["packaging", "dependency", "infer", "pyproject.toml"]
keywords = ["SKOS", "vocabulary", "spreadsheet", "xlsx", "linked data", "rdf"]

classifiers = [
"Development Status :: 4 - Beta",
Expand Down Expand Up @@ -79,32 +77,21 @@ dev = [
voc4cat = "voc4cat.cli:run_cli_app"
merge_vocab = "voc4cat.merge_vocab:main_cli"

#[tool.setuptools.packages.find]
#where = ["src"]
#
#[tool.setuptools_scm]
## presence of section activates version-number generation
#write_to = "src/voc4cat/_version.py"

#[tool.setuptools.dynamic]
#version = {attr = "voc4cat._version.version"}
#readme = {file = ["README.md"]}

[tool.hatch.metadata]
# Hatch disallows direct references for dependencies by default.
# We need to enable them to allow installing NFDI4Cat's vocexcel from github.
allow-direct-references = true

# Build targets for hatch are defined as sections within tool.hatch.build.targets:
[tool.hatch.build.targets.sdist]
exclude = [
"/docs",
include = [
"/src",
"/templates",
]

[tool.hatch.build.targets.wheel]
packages = ["src/voc4cat"]

# integrates setuptools_scm into hatch, https://github.com/ofek/hatch-vcs
# integrates git-tag-based versions into hatch, https://github.com/ofek/hatch-vcs
[tool.hatch.version]
source = "vcs"

Expand Down

0 comments on commit dfd70db

Please sign in to comment.