Skip to content

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

Open
wants to merge 34 commits into
base: gpeacock/py_publish
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f1a4ce7
chore: update cp2a-rs
Apr 9, 2025
1cfd2c8
Revert "chore: update cp2a-rs"
Apr 9, 2025
96cb110
chore: update to c2pa_rs 0.49.2
gpeacock Apr 9, 2025
093e82a
Merge pull request #97 from contentauth/gpeacock/c2pa_rs_49_2
dyro Apr 9, 2025
8571bd4
chore: use a non-project specific token
gpeacock Apr 11, 2025
c5882fe
fix: c2pa_rs update for dynamic gathered assertions.
gpeacock Apr 16, 2025
55ecdaf
Merge pull request #99 from contentauth/gpeacock/dynamic_gathered
gpeacock Apr 16, 2025
abdb81a
chore: add test upload workflow
gpeacock Apr 25, 2025
4d45fee
chore: update name of test wheel
gpeacock Apr 25, 2025
654a089
chore: rename and update upload-test
gpeacock Apr 25, 2025
59f35c2
chore: another test update
gpeacock Apr 26, 2025
c8fa0e5
chore: limit test-publish to arm only
gpeacock Apr 26, 2025
c94a985
chore: fix dependencies
gpeacock Apr 26, 2025
28e6bab
ci: Change setup
tmathern May 7, 2025
b04ae8f
fix: change settings
tmathern May 7, 2025
c43d2a0
fix: Make things verbose
tmathern May 7, 2025
a83ec20
fix: Debug release
tmathern May 7, 2025
b9f1b04
fix: Deprecation
tmathern May 7, 2025
839ce33
fix: Rename env
tmathern May 7, 2025
1c97a07
fix: Clean up
tmathern May 7, 2025
5061646
fix: Logs
tmathern May 7, 2025
0466c4a
fix: Different name
tmathern May 7, 2025
311e45d
fix: Fix logs
tmathern May 7, 2025
14ba1d7
fix: Fix logs 2
tmathern May 7, 2025
0650e15
fix: Fix logs 2
tmathern May 7, 2025
664f63f
fix: Fix namings
tmathern May 7, 2025
6026f23
fix: Fix namings 2
tmathern May 7, 2025
8b16c19
fix: Skip existing
tmathern May 7, 2025
0fb4f45
fix: Version bump
tmathern May 7, 2025
350f626
ci: Merge commit & version bump
tmathern May 7, 2025
6ae6e38
fix: Revert version number change
tmathern May 7, 2025
13b9b1d
fix: Naming
tmathern May 7, 2025
0ac8397
fix: Remove debug code
tmathern May 7, 2025
d2bd726
fix: skip existing set back to true
tmathern May 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator Author

@tmathern tmathern May 7, 2025

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.

needs: [linux, windows, macos_x86, macos_aarch64, sdist]
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
contents: read
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
Expand All @@ -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

98 changes: 98 additions & 0 deletions .github/workflows/upload-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Upload Test for Pypi.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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/
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["lib", "cdylib"]
normal = ["openssl-src"]

[dependencies]
c2pa = { version = "0.48.1", features = ["file_io", "pdf", "fetch_remote_manifests"]}
c2pa = { version = "0.49.3", features = ["file_io", "pdf", "fetch_remote_manifests"]}
thiserror = "1.0.49"
uniffi = "0.28.2"
openssl-src = "=300.3.1" # Required for openssl-sys
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ build-python:

test:
python3 ./tests/test_unit_tests.py
python3 ./tests/test_api.py
python3 ./tests/test_api.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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/*
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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"
Expand All @@ -27,4 +27,7 @@ urls = {homepage = "https://contentauthenticity.org", repository = "https://gith
[project.optional-dependencies]
test = [
"pytest < 5.0.0"
]
]

[tool.maturin]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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"
Loading