Skip to content
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

Python: Publish to TestPyPi #15

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ name: Multi-platform Python/C++ build/test
on:
push:
branches: [ "main" ]
paths-ignore:
- '.gitignore'
- '.github/workflows/publish-pypi.yml'
- '.github/workflows/publish-reports-github-pages.yml'
- '**.md'
- '*.sh'
pull_request:
branches: [ "main" ]
paths-ignore:
- '.gitignore'
- '.github/workflows/publish-pypi.yml'
- '.github/workflows/publish-reports-github-pages.yml'
- '**.md'
- '*.sh'

concurrency:
group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }}
Expand Down Expand Up @@ -227,3 +239,8 @@ jobs:
retention-days: 1
if-no-files-found: error

call-publish-pypi:
name: "Trigger workflow to publish distribution 📦s to PyPI/TestPyPI"
needs: build_and_test
uses: ./.github/workflows/publish-pypi.yml

78 changes: 78 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: "Publish distribution 📦s to PyPI/TestPyPI"

on:
workflow_call:
release:
types: [published]

concurrency:
group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
publish-test-pypi:
name: "Publish distribution 📦s to TestPyPI"
runs-on: ubuntu-latest

permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
# NOTE: For now, we don't have any native C++ code deployed as part of the python distribution,
# so all platforms create the same wheels/source archives.
# Therefore it's sufficient to use the ubuntu download artifact:
# python-dist-ubuntu-latest_py3.13
- name: "Download and merge Python dist artifacts"
uses: actions/download-artifact@v4
with:
# # for multi architectures:
#--------------------------------------#---------------------------
pattern: python-dist-ubuntu-latest* # pattern: python-dist-*
merge-multiple: true
path: dist # destination

- name: "List dist directory"
run: find dist

- uses: pypa/gh-action-pypi-publish@release/v1
# continue-on-error: true # might fail if we don't bump the version
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
attestations: false

publish-production-pypi:
name: "Publish distribution 📦s to PyPI"
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
# NOTE: For now, we don't have any native C++ code deployed as part of the python distribution,
# so all platforms create the same wheels/source archives.
# Therefore it's sufficient to use the ubuntu download artifact:
# python-dist-ubuntu-latest_py3.13
- name: "Download and merge Python dist artifacts"
uses: actions/download-artifact@v4
with:
# # for multi architectures:
#--------------------------------------#---------------------------
pattern: python-dist-ubuntu-latest* # pattern: python-dist-*
merge-multiple: true
path: dist # destination

- name: "List dist directory"
run: find dist

- uses: pypa/gh-action-pypi-publish@release/v1
# continue-on-error: true # might fail if we don't bump the version
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository-url: https://pypi.org/legacy/
attestations: false


36 changes: 36 additions & 0 deletions install_test_pypi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#! /bin/bash
##
## --------------------------------------------------------------------------------
## SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl
## Johannes Kepler University, Institute for Integrated Circuits.
##
## This file is part of KPEX
## (see https://github.com/martinjankoehler/klayout-pex).
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
## SPDX-License-Identifier: GPL-3.0-or-later
## --------------------------------------------------------------------------------
##

DIR=$(dirname -- $(realpath ${BASH_SOURCE}))

set -x
set -e

pip3 install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
klayout-pex


2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "kpex"
name = "klayout-pex"
version = "0.1.0"
description = "Parasitic Extraction Tool for KLayout"
authors = ["Martin Köhler <[email protected]>"]
Expand Down
Loading