-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from fangchenli/update-build
BLD: update CI and build, remove poetry, test on py 310, 311, 312
- Loading branch information
Showing
5 changed files
with
142 additions
and
151 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 |
---|---|---|
|
@@ -7,130 +7,119 @@ on: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
build-release: | ||
name: build-release | ||
build: | ||
name: build | ||
runs-on: macos-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8, 3.9] | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- name: Create artifacts directory | ||
shell: bash | ||
run: mkdir artifacts | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
shell: bash | ||
run: pip install poetry | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build wheel | ||
if: matrix.python-version != 3.9 | ||
shell: bash | ||
run: poetry build --format "wheel" | ||
- name: Build wheel and sdist | ||
if: matrix.python-version == 3.9 | ||
shell: bash | ||
run: poetry build | ||
|
||
- name: Resolve wheel name | ||
id: resolve_wheel | ||
shell: bash | ||
run: | | ||
wheel_path="$(echo dist/pasteboard-*.whl)" | ||
echo "::set-output name=path::$wheel_path" | ||
echo "wheel path: $wheel_path" | ||
wheel_name="${wheel_path##*/}" | ||
echo "::set-output name=name::$wheel_name" | ||
echo "wheel name: $wheel_name" | ||
- name: Upload wheel to artifacts | ||
uses: actions/upload-artifact@v2 | ||
- 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: artifacts | ||
path: ${{ steps.resolve_wheel.outputs.path }} | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: Publish Python 🐍 distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/project/pasteboard/ | ||
permissions: | ||
id-token: write | ||
|
||
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 | ||
|
||
- name: Resolve tar.gz name | ||
id: resolve_targz | ||
if: matrix.python-version == 3.9 | ||
shell: bash | ||
run: | | ||
targz_path="$(echo dist/pasteboard-*.tar.gz)" | ||
echo "::set-output name=path::$targz_path" | ||
echo "tar.gz path: $targz_path" | ||
targz_name="${targz_path##*/}" | ||
echo "::set-output name=name::$targz_name" | ||
echo "tar.gz name: $targz_name" | ||
- name: Upload tar.gz to artifacts | ||
if: matrix.python-version == 3.9 | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: artifacts | ||
path: ${{ steps.resolve_targz.outputs.path }} | ||
|
||
publish-release: | ||
name: publish-release | ||
needs: ['build-release'] | ||
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: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v1 | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
python-version: 3.9 | ||
- name: Install dependencies | ||
run: pip install poetry | ||
- name: Get release download URL | ||
uses: actions/download-artifact@v2 | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/[email protected] | ||
with: | ||
name: artifacts | ||
path: artifacts | ||
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 }}' | ||
--notes "" | ||
- 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 }}' | ||
publish-to-testpypi: | ||
name: Publish Python 🐍 distribution 📦 to TestPyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
|
||
- name: Create dist directory | ||
shell: bash | ||
run: mkdir dist | ||
- name: Copy wheels | ||
shell: bash | ||
run: cp artifacts/*.whl dist/ | ||
- name: Copy tar.gz | ||
shell: bash | ||
run: cp artifacts/*.tar.gz dist/ | ||
- name: List all artifacts | ||
shell: bash | ||
run: ls -l dist/ | ||
environment: | ||
name: testpypi | ||
url: https://pypi.org/project/pasteboard/ | ||
|
||
- name: Get the branch and tag | ||
id: info | ||
shell: bash | ||
run: | | ||
branch="${GITHUB_REF#refs/heads/}" | ||
echo "$branch" | ||
if [[ "$branch" == "workflow_release" ]]; then | ||
echo "::set-output name=version::TEST-0.0.0" | ||
echo "::set-output name=dry_run::--dry-run" | ||
else | ||
echo "::set-output name=version::${GITHUB_REF#refs/tags/}" | ||
echo "::set-output name=dry_run::" | ||
fi | ||
echo "::set-output name=date::$(env TZ=':America/Los_Angeles' date +'%Y-%m-%d')" | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
- name: Create release | ||
shell: bash | ||
run: | | ||
set -x | ||
hub release create \ | ||
--draft \ | ||
--message "${{ steps.info.outputs.version }} (${{ steps.info.outputs.date }})" \ | ||
$(find ./dist -type f -printf "-a %p ") \ | ||
"${{ steps.info.outputs.version }}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish | ||
run: | | ||
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}" | ||
poetry publish ${{ steps.info.outputs.dry_run }} | ||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ |
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,11 +1,16 @@ | ||
[tool.poetry] | ||
[build-system] | ||
requires = ["setuptools>=61.0.0", "setuptools-scm>=8.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "pasteboard" | ||
version = "0.3.3" | ||
description = "Pasteboard - Python interface for reading from NSPasteboard (macOS clipboard)" | ||
authors = ["Toby Fleming <[email protected]>"] | ||
license = "MPL-2.0" | ||
authors = [ | ||
{name = "Toby Fleming", email = "[email protected]"} | ||
] | ||
license = {file = "LICENSE"} | ||
readme = "README.md" | ||
homepage = "https://github.com/tobywf/pasteboard" | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Environment :: MacOS X :: Cocoa", | ||
|
@@ -14,30 +19,24 @@ classifiers = [ | |
"Operating System :: MacOS :: MacOS X", | ||
"Programming Language :: Objective C", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Topic :: Desktop Environment", | ||
"Topic :: Software Development :: Libraries", | ||
] | ||
keywords = ["macOS", "clipboard", "pasteboard"] | ||
build = "build.py" | ||
requires-python = ">= 3.8" | ||
|
||
[tool.poetry.dependencies] | ||
python = ">=3.6,<4.0" | ||
|
||
[tool.poetry.dev-dependencies] | ||
black = "^20.8b1" | ||
pytest = "^6.2.0" | ||
hypothesis = "^6.0.0" | ||
mypy = "^0.800" | ||
# This version is the last to support Python 3.6... | ||
ipython = "7.16.1" | ||
# ...and jedi is not properly pinned | ||
jedi = "0.17.2" | ||
[project.optional-dependencies] | ||
dev = [ | ||
"pytest", | ||
"hypothesis", | ||
"black", | ||
"mypy", | ||
"ipython", | ||
"jedi", | ||
"pre-commit", | ||
] | ||
|
||
[build-system] | ||
requires = ["poetry_core>=1.0.0", "setuptools"] | ||
build-backend = "poetry.core.masonry.api" | ||
[tool.setuptools_scm] |
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,20 @@ | ||
from setuptools import setup, Extension | ||
|
||
pasteboard = Extension( | ||
"pasteboard._native", | ||
["src/pasteboard/pasteboard.m"], | ||
extra_compile_args=[ | ||
"-mmacosx-version-min=10.13", | ||
"-Wall", | ||
"-Wextra", | ||
"-Wpedantic", | ||
"-Werror", | ||
], | ||
extra_link_args=["-framework", "AppKit"], | ||
language="objective-c", | ||
) | ||
|
||
setup( | ||
ext_modules=[pasteboard], | ||
zip_safe=False, | ||
) |