Skip to content

Merge pull request #8 from uptick/fix/pypi-publish-workflow #33

Merge pull request #8 from uptick/fix/pypi-publish-workflow

Merge pull request #8 from uptick/fix/pypi-publish-workflow #33

Workflow file for this run

name: Publish Release
on:
workflow_dispatch:
push:
release:
types:
- released
- prereleased
permissions:
contents: write
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # ratchet:actions/checkout@v3
- uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # ratchet:actions/setup-python@v4
with:
python-version: "3.12"
- uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # ratchet:actions/setup-python@v4
with:
python-version: "3.13"
- name: Build wheels
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # ratchet:PyO3/maturin-action@v1
with:
working-directory: ./vrp-cli
target: ${{ matrix.target }}
sccache: "true"
args: --release --out dist -m Cargo.toml -i 3.12 -i 3.13
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # ratchet:actions/upload-artifact@v4
with:
name: wheels-${{ matrix.target }}
path: ./vrp-cli/dist
macos:
runs-on: macos-latest
strategy:
matrix:
target: [aarch64]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # ratchet:actions/checkout@v3
- uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # ratchet:actions/setup-python@v4
with:
python-version: "3.12"
architecture: "arm64"
- uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # ratchet:actions/setup-python@v4
with:
python-version: "3.13"
architecture: "arm64"
- name: Build wheels
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # ratchet:PyO3/maturin-action@v1
with:
working-directory: ./vrp-cli
target: ${{ matrix.target }}
args: --release --out dist -m Cargo.toml -i 3.12 -i 3.13
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # ratchet:actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.target }}
path: ./vrp-cli/dist
pypi-publish:
name: Publish artifacts to Uptick's Pypi repo
if: startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write
contents: write
needs: [linux, macos]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # ratchet:actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Install uv
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # ratchet:astral-sh/setup-uv@v7
with:
version: "0.5.0"
- name: Setup and Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # ratchet:aws-actions/configure-aws-credentials@v5
with:
role-to-assume: arn:aws:iam::610829907584:role/default-github-actions-ci-role
role-session-name: vrp-pypi-publish
aws-region: us-east-1
- name: Build and Publish Package to S3Pypi
shell: bash
run: |
uvx [email protected] upload dist/* --bucket s3pypi-610829907584-us-east-1
gh-publish:
name: Publish artifacts to GH
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
needs: [linux, macos]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # ratchet:actions/download-artifact@v4
with:
path: .
merge-multiple: true
- name: Upload to GitHub
id: create-release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # ratchet:softprops/action-gh-release@v2
with:
files: ./*
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # ratchet:actions/checkout@v3
with:
ref: gh-pages
- name: Generate PyPi index page
id: generate_index
shell: python
env:
ASSETS: ${{ steps.create-release.outputs.assets }}
run: |
import json
import os
# Load the assets data from the previous step
assets = json.loads(os.environ['ASSETS'])
# Define the header for the index.md file
index_content = "# vrp-cli\n\n"
# Iterate over the assets and format them into markdown links
for asset in assets:
name = asset['name']
url = asset['browser_download_url']
python_version = name.split('-')[2].split('cp3')[1]
index_content += f'<a href="{url}" data-requires-python="==3.{python_version}">{name}</a><br />\n'
# Write the content to the index.md file
with open('docs/vrp-cli/index.md', 'w') as f:
f.write(index_content)
- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add docs/vrp-cli/index.md
git commit -m 'docs: update PyPi index page'
git push