Skip to content

Fix tag validation regex in deploy.yml (#954) #19

Fix tag validation regex in deploy.yml (#954)

Fix tag validation regex in deploy.yml (#954) #19

Workflow file for this run

name: Twilio Public release-pypi
on:
push:
tags:
- '*'
env:
ARTIFACTORY_URL: ${{ vars.ARTIFACTORY_URL }}
jobs:
lockfile-hygiene:
runs-on: ubuntu-x64
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: twilio/sdk-actions/uv-lockfile-hygiene@23b656b843d2a3461cf38e4fd466c07a822d5fc0 # v1
with:
clean-room: 'false'
test:
name: Test - Python ${{ matrix.python-version }}
needs: [lockfile-hygiene]
runs-on: ubuntu-x64
if: github.repository_owner == 'twilio'
timeout-minutes: 20
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Artifactory OIDC Auth
uses: twilio/sdk-actions/artifactory-oidc@23b656b843d2a3461cf38e4fd466c07a822d5fc0 # v1
with:
ecosystem: python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install virtualenv --upgrade
make install test-install
make prettier
- name: Run tests
run: make test-with-coverage
deploy:
name: Publish to PyPI
needs: [test]
runs-on: ubuntu-x64
if: success() && github.ref_type == 'tag' && github.repository_owner == 'twilio'
environment: production
permissions:
contents: write # required for creating GitHub Release
id-token: write
attestations: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Artifactory OIDC Auth
uses: twilio/sdk-actions/artifactory-oidc@23b656b843d2a3461cf38e4fd466c07a822d5fc0 # v1
with:
ecosystem: python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
- name: Install setuptools
run: pip install setuptools
- name: Validate tag format and version match
run: |
TAG="${GITHUB_REF#refs/tags/}"
if [[ ! "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::error::Release tag must be in the form 1.2.3 (got '$TAG')"
exit 1
fi
VERSION="${TAG#}"
PKG_VERSION=$(python setup.py --version)
echo "Package version: $PKG_VERSION"
echo "PKG_VERSION=$PKG_VERSION" >> "$GITHUB_ENV"
if [ "$VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag $TAG does not match setup.py version $PKG_VERSION"
exit 1
fi
- name: Get tagged version
run: echo "GITHUB_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Create GitHub Release
uses: sendgrid/dx-automator/actions/release@08b601b726671445abc798ed59881766ec8fefc6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build package
run: |
pip install build
python -m build
- name: Verify package
run: |
pip install twine
twine check dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1
- name: Summary
run: |
echo "Published version $PKG_VERSION to PyPI"