Skip to content

Support SLIM v0.7.x (#101) #47

Support SLIM v0.7.x (#101)

Support SLIM v0.7.x (#101) #47

Workflow file for this run

# Copyright AGNTCY Contributors (https://github.com/agntcy)
# SPDX-License-Identifier: Apache-2.0
---
name: sdk-release-python
on:
push:
tags:
- "v*" # Only trigger on tag push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
validate-release-tag:
name: Validate tag against main and pyproject version
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch main
run: git fetch --quiet origin main
- name: Validate tag ancestry and version
env:
TAG_NAME: ${{ github.ref_name }}
COMMIT_SHA: ${{ github.sha }}
run: |
if [[ "${GITHUB_REF_TYPE}" != "tag" ]]; then
echo "Not a tag push; exiting."
exit 1
fi
if [[ ! "${TAG_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev\.[0-9]+)?$ ]]; then
echo "Tag ${TAG_NAME} does not match vX.Y.Z pattern or vX.Y.Z-dev.a pattern."
exit 1
fi
if ! git merge-base --is-ancestor "${COMMIT_SHA}" origin/main; then
echo "Tag commit ${COMMIT_SHA} is not reachable from origin/main."
exit 1
fi
FILE_VERSION=$(grep -E '^version *= *"' pyproject.toml | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
if [[ -z "${FILE_VERSION}" ]]; then
echo "Failed to extract version from pyproject.toml."
exit 1
fi
TAG_VERSION="${TAG_NAME#v}"
echo "pyproject.toml version: ${FILE_VERSION}"
echo "Tag version: ${TAG_VERSION}"
if [[ "${FILE_VERSION}" != "${TAG_VERSION}" ]]; then
echo "Mismatch: tag v${TAG_VERSION} != pyproject.toml version ${FILE_VERSION}"
exit 1
fi
echo "Validation passed."
build-sdk-wheel:
name: SDK Python wheel
needs: validate-release-tag
if: needs.validate-release-tag.result == 'success'
uses: ./.github/workflows/reusable-python-build-wheel.yaml
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs:
- build-sdk-wheel
if: needs.build-sdk-wheel.result == 'success'
environment: pypi
permissions:
id-token: write
contents: read
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: ./dist
- name: Show files
run: ls -l ./dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: ./dist