Skip to content

Commit

Permalink
Merge pull request #12 from Cosmian/fix-ci
Browse files Browse the repository at this point in the history
Fix PyPi release with GH Actions
  • Loading branch information
grydz authored Apr 3, 2024
2 parents 1c90603 + 9a024e0 commit 4c3a173
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 37 deletions.
45 changes: 25 additions & 20 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,40 @@ name: CI

on: [push]

env:
PYTHON_SRC: "src"

permissions:
contents: read
id-token: write

jobs:
python:
uses: ./.github/workflows/python.yml
with:
os: ${{ matrix.os }}
target: ${{ matrix.target }}
python-version: ${{ matrix.python-version }}
name: Python CI (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
uses: ./.github/workflows/python.yml
name: Python CI (${{ matrix.os }})
with:
os: ${{ matrix.os }}
target: [x86_64]
python-version: ['3.8', '3.9', '3.10', '3.11']

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: python
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing *
uses: ./.github/workflows/pypi_release.yml
with:
os: ${{ matrix.os }}
target: ${{ matrix.target }}
python-version: ${{ matrix.python-version }}
name: Release (${{ matrix.os }})
if: startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
target: [x86_64]
python-version: ['3.8', '3.9', '3.10', '3.11']
permissions:
contents: read
id-token: write
32 changes: 32 additions & 0 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release CI

on:
workflow_call:
inputs:
os:
required: true
type: string
target:
required: true
type: string
python-version:
required: true
type: string

jobs:
release:
name: Python ${{ inputs.python-version }} (${{ inputs.target }})
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/intel-sgx-ra

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ inputs.os }}-${{ inputs.python-version }}-${{ inputs.target }}-wheels
path: dist

- name: Publish packages to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
41 changes: 25 additions & 16 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ on:
os:
required: true
type: string
target:
required: true
type: string
python-version:
required: true
type: string
outputs:
package-version:
description: "Version of the Python package"
value: ${{ jobs.build.outputs.package-version }}

env:
PYTHON_SRC: "src"
Expand All @@ -14,38 +24,31 @@ permissions:
contents: read

jobs:
python:
build:
name: Python ${{ inputs.python-version }} (${{ inputs.target }})
runs-on: ${{ inputs.os }}
strategy:
matrix:
target: [x86_64]
python-version: ['3.8', '3.9', '3.10', '3.11']
name: Python ${{ matrix.python-version }} (${{ matrix.target }})
outputs:
package-version: ${{ steps.metadata.outputs.PACKAGE_VERSION }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ inputs.python-version }}
cache: 'pip' # caching pip dependencies

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
target: ${{ inputs.target }}
manylinux: manylinux2014
container: quay.io/pypa/manylinux2014_x86_64
args: --release --out dist -i ${{ matrix.python-version }}
args: --release --out dist -i ${{ inputs.python-version }}
sccache: 'true'

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.os }}-${{ matrix.python-version }}-${{ matrix.target }}-wheels
path: dist

- name: Install dependencies
run: |
if [ -f tests/requirements.txt ]; then python -m pip install -r tests/requirements.txt; fi
Expand Down Expand Up @@ -84,3 +87,9 @@ jobs:
- name: Test with pytest
run: |
python -m pytest
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.os }}-${{ inputs.python-version }}-${{ inputs.target }}-wheels
path: dist
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "intel-sgx-ra"
version = "2.3.0"
version = "2.2.0"
description = "Intel SGX Remote Attestation verification library"
authors = [
{name = "Cosmian Tech", email = "[email protected]"},
Expand Down

0 comments on commit 4c3a173

Please sign in to comment.