Skip to content

Commit

Permalink
Use trusted publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
tibdex committed Sep 5, 2024
1 parent b8382b9 commit 875cd58
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 130 deletions.
8 changes: 0 additions & 8 deletions .github/actions/build-conda-packages/action.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Build Conda packages
description: Build the Conda packages
outputs:
platform:
description: The platform targeted by the Conda packages.
value: ${{ steps.get-platform.outputs.platform }}
runs:
using: composite
steps:
Expand All @@ -14,7 +10,3 @@ runs:
- run: conda build --no-anaconda-upload --output-folder dist .
# See https://github.com/conda-incubator/setup-miniconda/blame/059455a698430d8b68fa317268fa2e3da3492a98/README.md#L609-L610.
shell: bash -l {0}

- id: get-platform
run: uv run python -c 'from pathlib import Path; print(f"""platform={next(Path("dist").glob("*/jdk4py-*.tar.bz2")).parts[1]}""")' >> "$GITHUB_OUTPUT"
shell: bash
7 changes: 1 addition & 6 deletions .github/actions/build-python-wheel/action.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
name: Build Python wheel
description: Build the Python wheel
outputs:
filename:
description: The name of the built Python wheel.
value: ${{ steps.get-filename.outputs.filename }}
runs:
using: "composite"
steps:
- run: uv build --wheel
shell: bash

- id: get-filename
run: uv run python -c 'from pathlib import Path; print(f"""filename={next(Path("dist").glob("jdk4py-*.whl")).parts[1]}""")' >> "$GITHUB_OUTPUT"
- run: uv run twine check dist/*
shell: bash
88 changes: 55 additions & 33 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
name: Deploy Conda and PyPI packages
on:
push:
branches:
- main
name: Deploy Conda packages and Python wheels
on: [push]
# push:
# branches:
# - main

jobs:
deploy:
build:
name: Build on ${{ matrix.runner }}
runs-on: ${{ matrix.runner }}
environment: deployment
strategy:
matrix:
runner:
- macos-13 # x64
# - macos-13 # x64
- macos-14 # arm64
- ubuntu-24.04
- ubuntu-24.04-arm64 # GitHub-hosted larger runner in the ActiveViam organization.
- windows-2022
name: Deploy on ${{ matrix.runner }}
# - windows-2022
steps:
- uses: actions/checkout@v4

Expand All @@ -27,26 +26,49 @@ jobs:
- id: build-python-wheel
uses: ./.github/actions/build-python-wheel

- id: build-conda-packages
uses: ./.github/actions/build-conda-packages

- name: Upload Conda packages
env:
JDK4PY_CONDA_CHANNEL_TOKEN: ${{ secrets.CONDA_CHANNEL_TOKEN }}
JDK4PY_CONDA_CHANNEL_URL: ${{ vars.CONDA_CHANNEL_URL }}
JDK4PY_CONDA_CHANNEL_USERNAME: ${{ vars.CONDA_CHANNEL_USERNAME }}
JDK4PY_CONDA_PLATFORM: ${{ steps.build-conda-packages.outputs.platform }}
run: |
ls dist/$JDK4PY_CONDA_PLATFORM/jdk4py-*.tar.bz2 | \
while read filepath; do
echo Uploading ${filepath}
curl --fail --user "$JDK4PY_CONDA_CHANNEL_USERNAME":"$JDK4PY_CONDA_CHANNEL_TOKEN" --upload-file ${filepath} "$JDK4PY_CONDA_CHANNEL_URL/$JDK4PY_CONDA_PLATFORM/"
done
shell: bash

- name: Upload Python wheel
env:
JDK4PY_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
JDK4PY_WHEEL_FILENAME: ${{ steps.build-python-wheel.outputs.filename }}
run: uv run twine upload dist/"$JDK4PY_WHEEL_FILENAME" --username __token__ --password "$JDK4PY_PYPI_TOKEN"
shell: bash
- uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: jdk4py-${{ matrix.runner }}-python-wheel
path: dist/

# - id: build-conda-packages
# uses: ./.github/actions/build-conda-packages

# - uses: actions/upload-artifact@v4
# with:
# if-no-files-found: error
# name: jdk4py-${{ steps.build-conda-packages.outputs.platform }}-conda-packages
# path: dist/${{ steps.build-conda-packages.outputs.platform }}/jdk4py-*.tar.bz2

publish:
environment: deployment
name: Publish Conda packages and Python wheels
needs: build
runs-on: ubuntu-24.04
permissions:
# Required for trusted publishing.
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist/

- run: ls -R dist/
# - name: Publish Conda packages
# env:
# JDK4PY_CONDA_CHANNEL_TOKEN: ${{ secrets.CONDA_CHANNEL_TOKEN }}
# JDK4PY_CONDA_CHANNEL_URL: ${{ vars.CONDA_CHANNEL_URL }}
# JDK4PY_CONDA_CHANNEL_USERNAME: ${{ vars.CONDA_CHANNEL_USERNAME }}
# JDK4PY_CONDA_PLATFORM: ${{ steps.build-conda-packages.outputs.platform }}
# run: |
# ls dist/$JDK4PY_CONDA_PLATFORM/jdk4py-*.tar.bz2 | \
# while read filepath; do
# echo Uploading ${filepath}
# curl --fail --user "$JDK4PY_CONDA_CHANNEL_USERNAME":"$JDK4PY_CONDA_CHANNEL_TOKEN" --upload-file ${filepath} "$JDK4PY_CONDA_CHANNEL_URL/$JDK4PY_CONDA_PLATFORM/"
# done
# shell: bash

# - name: Publish Python wheels
# uses: pypa/gh-action-pypi-publish@release/v1
82 changes: 0 additions & 82 deletions .github/workflows/test.yaml

This file was deleted.

82 changes: 82 additions & 0 deletions .github/workflows/test.yaml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Test
on:
pull_request:
types: [opened, synchronize]

jobs:
test:
name: Test on ${{ matrix.runner }} with Python ${{ matrix.python }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner:
- macos-13 # x64
- macos-14 # arm64
- ubuntu-24.04
- ubuntu-24.04-arm64 # GitHub-hosted larger runner in the ActiveViam organization.
- windows-2022
python:
- "3.12"
include:
- runner: ubuntu-24.04
python: "3.11"
- runner: ubuntu-24.04
python: "3.10"
fail-fast: false
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/build-java-runtime

- id: build-python-wheel
uses: ./.github/actions/build-python-wheel

# No need to test each platform and Python version.
- if: ${{ matrix.runner == 'ubuntu-24.04' && matrix.python == '3.12' }}
run: uv run ruff format --check .

# No need to test each platform and Python version.
- if: ${{ matrix.runner == 'ubuntu-24.04' && matrix.python == '3.12' }}
run: uv run ruff check .

# No need to test each platform and Python version.
- if: ${{ matrix.runner == 'ubuntu-24.04' && matrix.python == '3.12' }}
run: uv run mypy

- run: uv run pytest

# The Python wheels are not tied to a specific Python version.
- if: ${{ matrix.python == '3.12' }}
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ${{ steps.build-python-wheel.outputs.filename }}
path: dist/${{ steps.build-python-wheel.outputs.filename }}

conda-package:
name: Test Conda packaging on ${{ matrix.runner }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner:
- macos-13 # x64
- macos-14 # arm64
- ubuntu-24.04
- ubuntu-24.04-arm64 # GitHub-hosted larger runner in the ActiveViam organization.
- windows-2022
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/build-java-runtime
with:
# No need to test each Python version.
python-version: "3.12"

- id: build-conda-packages
uses: ./.github/actions/build-conda-packages

- uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: jdk4py-${{ steps.build-conda-packages.outputs.platform }}-conda-packages
path: dist/${{ steps.build-conda-packages.outputs.platform }}/jdk4py-*.tar.bz2
2 changes: 1 addition & 1 deletion conda.recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
python:
- "3.10"
- "3.11"
- "3.12"
#- "3.12"

0 comments on commit 875cd58

Please sign in to comment.