-
Notifications
You must be signed in to change notification settings - Fork 10
ci: Update setup for publishing #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gpeacock/py_publish
Are you sure you want to change the base?
Changes from all commits
f1a4ce7
1cfd2c8
96cb110
093e82a
8571bd4
c5882fe
55ecdaf
abdb81a
4d45fee
654a089
59f35c2
c8fa0e5
c94a985
28e6bab
b04ae8f
c43d2a0
a83ec20
b9f1b04
839ce33
1c97a07
5061646
0466c4a
311e45d
14ba1d7
0650e15
664f63f
6026f23
8b16c19
0fb4f45
350f626
6ae6e38
13b9b1d
0ac8397
d2bd726
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,15 +359,13 @@ jobs: | |
|
||
release: | ||
name: Release | ||
|
||
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true' | ||
|
||
runs-on: ubuntu-latest | ||
environment: Publish | ||
environment: pypipublish | ||
needs: [linux, windows, macos_x86, macos_aarch64, sdist] | ||
permissions: | ||
# IMPORTANT: this permission is mandatory for Trusted Publishing | ||
id-token: write | ||
contents: read | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added one more permission so we're sure the token can be used, and the contents we're dealing with, read |
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
|
@@ -377,10 +375,12 @@ jobs: | |
merge-multiple: true | ||
- name: List contents of dist directory | ||
run: ls -la dist/ | ||
- name: Publish to PyPi | ||
- name: Publish to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages_dir: dist | ||
username: __token__ | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
packages-dir: dist | ||
# verbose: true | ||
# print-hash: true | ||
# Uncomment below for test runs, otherwise fails on existing packages being reuploaded | ||
skip-existing: true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Upload Test for Pypi. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Came in when I merged in latest main, did not make changes here in that PR. |
||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
linux: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
target: [aarch64] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
cache: "pip" | ||
- run: pip install -r requirements.txt | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
if: ${{ matrix.target == 'aarch64' }} | ||
- name: Build wheels | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
maturin-version: "1.2.0" | ||
args: --release --out dist --find-interpreter | ||
sccache: "true" | ||
manylinux: ${{ matrix.target == 'aarch64' && 'manylinux_2_28' || 'auto' }} | ||
before-script-linux: | | ||
pip install uniffi-bindgen==0.24.1 | ||
|
||
# ISSUE: https://github.com/sfackler/rust-openssl/issues/2036#issuecomment-1724324145 | ||
# If we're running on rhel centos, install needed packages. | ||
if command -v yum &> /dev/null; then | ||
yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic | ||
|
||
# If we're running on i686 we need to symlink libatomic | ||
# in order to build openssl with -latomic flag. | ||
if [[ ! -d "/usr/lib64" ]]; then | ||
ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so | ||
fi | ||
else | ||
# If we're running on debian-based system. | ||
apt update -y && apt-get install -y libssl-dev openssl pkg-config | ||
fi | ||
- name: Upload wheels | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels-${{ matrix.target }} | ||
path: dist | ||
|
||
sdist: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build sdist | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
command: sdist | ||
args: --out dist | ||
- name: Upload sdist | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels | ||
path: dist | ||
|
||
pypi-publish: | ||
name: upload release to PyPI | ||
runs-on: ubuntu-latest | ||
needs: [linux, sdist] | ||
|
||
# Specifying a GitHub environment is optional, but strongly encouraged | ||
environment: testpublish | ||
permissions: | ||
# IMPORTANT: this permission is mandatory for Trusted Publishing | ||
id-token: write | ||
steps: | ||
# retrieve your distributions here | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download aarch64 wheels artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: wheels-aarch64 | ||
|
||
- name: Download sdist artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: sdist | ||
|
||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,8 @@ build-python: | |
|
||
test: | ||
python3 ./tests/test_unit_tests.py | ||
python3 ./tests/test_api.py | ||
python3 ./tests/test_api.py | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Came in with latest main too |
||
publish: release | ||
python3 -m pip install twine | ||
python3 -m twine upload dist/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ requires = ["maturin>=1.7.4,<2.0","uniffi_bindgen>=0.28,<0.30"] | |
build-backend = "maturin" | ||
|
||
[project] | ||
name = "c2pa" | ||
name = "c2pa-python" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That name needs to match what is in PyPI for Trusted publishing. |
||
dependencies = ["cffi"] | ||
requires-python = ">=3.7" | ||
description = "Python bindings for the C2PA Content Authenticity Initiative (CAI) library" | ||
|
@@ -27,4 +27,7 @@ urls = {homepage = "https://contentauthenticity.org", repository = "https://gith | |
[project.optional-dependencies] | ||
test = [ | ||
"pytest < 5.0.0" | ||
] | ||
] | ||
|
||
[tool.maturin] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we had to update the name above for trusted publishing, now we need this to "fix" the package name. |
||
module-name = "c2pa" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment needs to match what is set in trusted publishing on PyPI (and it's case-sensitive). Unfortunately, it can do only lower case environments, so the env in github needs to be all lowercase too.