Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dewmal committed Aug 13, 2024
1 parent 7205e3c commit 2baa84f
Show file tree
Hide file tree
Showing 2 changed files with 263 additions and 104 deletions.
211 changes: 107 additions & 104 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This file is autogenerated by maturin v1.5.1
# To update, run
#
# maturin generate-ci github
#
name: CI

on:
Expand All @@ -10,141 +15,139 @@ on:
- '*'
pull_request:
workflow_dispatch:
inputs:
sha:
description: Commit SHA
type: string
dry-run:
description: Dry run
type: boolean
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
PYTHON_VERSION: '3.8'
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10

permissions:
contents: read

jobs:
create-sdist:
runs-on: ubuntu-latest
linux:
if: "startsWith(github.ref, 'refs/tags/')"
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
package: [ceylon]
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
- runner: ubuntu-latest
target: s390x
- runner: ubuntu-latest
target: ppc64le
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
ref: ${{ inputs.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
python-version: '3.10'
- name: Install Libs
run: |
pip install uniffi-bindgen maturin
- name: Create source distribution
run: |
cd bindings/ceylon
maturin sdist --out ../../dist
- name: Upload sdist
pip install uniffi-bindgen
pip install maturin
- name: Change Directory
run: cd bindings/ceylon
- name: Build
run: maturin build --release --out dist --find-interpreter -m bindings/ceylon/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: sdist-${{ matrix.package }}
path: dist/*.tar.gz

build-wheels:
runs-on: ${{ matrix.os }}
name: wheels-linux-${{ matrix.platform.target }}
path: dist
windows:
if: "startsWith(github.ref, 'refs/tags/')"
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
target: [x86_64, x86, aarch64]
exclude:
- os: windows-latest
target: aarch64
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
ref: ${{ inputs.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: pip install uniffi-bindgen
python-version: '3.10'
architecture: ${{ matrix.platform.target }}
- name: Change Directory
run: cd bindings/ceylon
- name: Install Libs
run: |
pip install uniffi-bindgen
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -m bindings/ceylon/Cargo.toml
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.target }}
path: dist/*.whl

publish-to-pypi:
needs: [create-sdist, build-wheels]
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/') && !inputs.dry-run"
permissions:
id-token: write
steps:
- name: Download sdists and wheels
uses: actions/download-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
# sdist:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Change Directory
# run: cd bindings/ceylon
# - name: Build sdist
# uses: PyO3/maturin-action@v1
# with:
# command: sdist
# args: --out dist -m bindings/ceylon/Cargo.toml
# - name: Upload sdist
# uses: actions/upload-artifact@v4
# with:
# name: wheels-sdist
# path: dist

publish-to-github:
needs: publish-to-pypi
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/') && !inputs.dry-run"
macos:
runs-on: ${{ matrix.platform.runner }}
if: "startsWith(github.ref, 'refs/tags/')"
strategy:
matrix:
platform:
- runner: macos-latest
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
ref: ${{ inputs.sha }}
- name: Download sdist
uses: actions/download-artifact@v4
with:
name: sdist-ceylon
path: dist
- name: Get version from Cargo.toml
id: version
working-directory: bindings/ceylon
python-version: '3.10'
- name: Change Directory
run: cd bindings/ceylon
- name: Install Libs
run: |
VERSION=$(grep -m 1 -oP 'version = "\K[^"]+' Cargo.toml)
echo "version=$VERSION" >> $GITHUB_OUTPUT
if [[ "$VERSION" == *"-"* ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Create GitHub release
id: github-release
uses: release-drafter/release-drafter@v6
pip install uniffi-bindgen
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
name: Ceylon ${{ steps.version.outputs.version }}
tag: v${{ steps.version.outputs.version }}
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.is_prerelease }}
commitish: ${{ inputs.sha || github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload sdist to GitHub release
run: gh release upload ${{ steps.github-release.outputs.tag_name }} dist/*.tar.gz --clobber
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -m bindings/ceylon/Cargo.toml
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ linux, windows, macos ]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*.whl
Loading

0 comments on commit 2baa84f

Please sign in to comment.