Prepare release action #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "[ptars] Release" | |
on: | |
release: | |
types: [ published ] | |
branches: [ master ] | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- pyproject.toml | |
- Cargo.toml | |
- .github/workflows/release.yaml | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
PACKAGE_NAME: ptars | |
PYTHON_VERSION: "3.11" | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_RETRY: 10 | |
CARGO_TERM_COLOR: always | |
RUSTUP_MAX_RETRIES: 10 | |
jobs: | |
sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: "Build sdist" | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist | |
- name: "Test sdist" | |
run: | | |
tar -ztvf dist/${{ env.PACKAGE_NAME }}-*.tar.gz | |
pip install dist/${{ env.PACKAGE_NAME }}-*.tar.gz --force-reinstall | |
python -c "import ptars" | |
- name: "Upload sdist" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-sdist | |
path: dist | |
macos-universal: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
architecture: x64 | |
- name: "Build wheels - universal2" | |
uses: PyO3/maturin-action@v1 | |
with: | |
args: --release --locked --target universal2-apple-darwin --out dist | |
- name: "Test wheel - universal2" | |
run: | | |
pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall | |
python -c "import ptars" | |
- name: "Upload wheels" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-aarch64-apple-darwin | |
path: dist | |
- name: "Archive binary" | |
run: | | |
ARCHIVE_FILE=ptars-*-aarch64-apple-darwin.tar.gz | |
tar czvf $ARCHIVE_FILE -C target/aarch64-apple-darwin/release ptars | |
shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 | |
- name: "Upload binary" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-aarch64-apple-darwin | |
path: | | |
*.tar.gz | |
*.sha256 | |
upload-release: | |
name: Upload to PyPI | |
runs-on: ubuntu-latest | |
needs: | |
- macos-universal | |
# If you don't set an input tag, it's a dry run (no uploads). | |
environment: | |
name: release | |
permissions: | |
# For pypi trusted publishing | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: wheels-* | |
path: wheels | |
merge-multiple: true | |
- name: Publish to PyPi | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true | |
packages-dir: wheels | |
verbose: true | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ |