jdrouet/mrml

View on GitHub
.github/workflows/mrml-python-release.yml

Summary

Maintainability
Test Coverage
name: mrml-python release

on:
  workflow_call:
    inputs:
      release_tag:
        description: "Release tag to use"
        required: true
        type: string
  workflow_dispatch:
    inputs:
      release_tag:
        description: "Release tag to use"
        required: true
        type: string

permissions:
  contents: read

jobs:
  linux:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          - platform: x86_64
            manylinux: "auto"
          - platform: x86
            manylinux: "auto"
          - platform: aarch64
            manylinux: "2_28"
          - platform: armv7
            manylinux: "auto"
          - platform: s390x
            manylinux: "auto"
          - platform: ppc64le
            manylinux: "auto"
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.10"
      - name: build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target.platform }}
          args: --release --out dist --find-interpreter
          sccache: "true"
          manylinux: ${{ matrix.target.manylinux }}
          working-directory: packages/mrml-python
      - name: upload wheels
        uses: actions/upload-artifact@v4
        with:
          name: wheels
          path: packages/mrml-python/dist

  windows:
    runs-on: windows-latest
    strategy:
      matrix:
        target: [x64, x86]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.10"
          architecture: ${{ matrix.target }}
      - name: build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --find-interpreter
          sccache: "true"
          working-directory: packages/mrml-python
      - name: upload wheels
        uses: actions/upload-artifact@v4
        with:
          name: wheels
          path: packages/mrml-python/dist

  macos:
    runs-on: macos-latest
    strategy:
      matrix:
        target: [x86_64, aarch64]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.10"
      - name: build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --find-interpreter
          sccache: "true"
          working-directory: packages/mrml-python
      - name: upload wheels
        uses: actions/upload-artifact@v4
        with:
          name: wheels
          path: packages/mrml-python/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
          working-directory: packages/mrml-python
      - name: Upload sdist
        uses: actions/upload-artifact@v4
        with:
          name: wheels
          path: packages/mrml-python/dist

  release:
    name: Release
    runs-on: ubuntu-latest
    needs: [linux, windows, macos, sdist]
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: wheels
          path: packages/mrml-python/dist
      - name: publish to PyPI
        uses: PyO3/maturin-action@v1
        env:
          MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
        with:
          command: upload
          args: --non-interactive --skip-existing dist/*
          working-directory: packages/mrml-python

  notify:
    runs-on: ubuntu-latest
    needs: [release]
    steps:
      - name: notify mastodon
        uses: cbrgm/mastodon-github-action@v2
        with:
          message: |
            👋 Hey! I just released a new version of mrml-python! 🐍
            https://github.com/jdrouet/mrml/releases/tag/${{ inputs.release_tag }} and https://pypi.org/project/mrml/
          visibility: "public"
        env:
          MASTODON_URL: ${{ secrets.MASTODON_URL }}
          MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
        continue-on-error: true