Skip to content

Commit 8ea067d

Browse files
committed
updates
1 parent 0c6eb88 commit 8ea067d

3 files changed

Lines changed: 81 additions & 115 deletions

File tree

.github/artifactory-oidc/action.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
name: Test and Deploy to PyPI
1+
name: Twilio Public release-pypi
22

33
on:
4-
release:
5-
types: [published]
6-
workflow_dispatch:
4+
push:
5+
tags:
6+
- 'v*'
77

88
env:
99
ARTIFACTORY_URL: ${{ vars.ARTIFACTORY_URL }}
1010

1111
jobs:
12+
lockfile-hygiene:
13+
runs-on: ubuntu-x64
14+
steps:
15+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
16+
- uses: twilio/sdk-actions/uv-lockfile-hygiene@23b656b843d2a3461cf38e4fd466c07a822d5fc0 # v1
17+
with:
18+
clean-room: 'false'
19+
1220
test:
1321
name: Test - Python ${{ matrix.python-version }}
14-
runs-on: ${{ github.repository_owner == 'twilio-internal' && 'ubuntu-x64' || 'ubuntu-latest' }}
22+
needs: [lockfile-hygiene]
23+
runs-on: ubuntu-x64
24+
if: github.repository_owner == 'twilio'
1525
timeout-minutes: 20
1626
permissions:
1727
contents: read
@@ -21,12 +31,14 @@ jobs:
2131
matrix:
2232
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2333
steps:
24-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
34+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
2535
with:
2636
fetch-depth: 0
2737

28-
- name: Authenticate with Artifactory
29-
uses: ./.github/actions/artifactory-oidc
38+
- name: Artifactory OIDC Auth
39+
uses: twilio/sdk-actions/artifactory-oidc@23b656b843d2a3461cf38e4fd466c07a822d5fc0 # v1
40+
with:
41+
ecosystem: python
3042

3143
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
3244
with:
@@ -43,17 +55,25 @@ jobs:
4355
deploy:
4456
name: Publish to PyPI
4557
needs: [test]
46-
runs-on: ${{ github.repository_owner == 'twilio-internal' && 'ubuntu-x64' || 'ubuntu-latest' }}
58+
runs-on: ubuntu-x64
59+
if: success() && github.ref_type == 'tag' && github.repository_owner == 'twilio'
4760
environment: production
4861
permissions:
49-
contents: read
62+
contents: write # required for creating GitHub Release
5063
id-token: write
5164
attestations: write
5265
steps:
53-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
66+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5467

55-
- name: Authenticate with Artifactory
56-
uses: ./.github/actions/artifactory-oidc
68+
- name: Create GitHub Release
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: gh release create "${{ github.ref_name }}" --generate-notes
72+
73+
- name: Artifactory OIDC Auth
74+
uses: twilio/sdk-actions/artifactory-oidc@23b656b843d2a3461cf38e4fd466c07a822d5fc0 # v1
75+
with:
76+
ecosystem: python
5777

5878
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
5979
with:
@@ -62,12 +82,17 @@ jobs:
6282
- name: Install setuptools
6383
run: pip install setuptools
6484

65-
- name: Validate tag matches package version
85+
- name: Validate tag format and version match
6686
run: |
6787
TAG="${GITHUB_REF#refs/tags/}"
68-
# Strip leading 'v' if present
88+
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
89+
echo "::error::Release tag must be in the form v1.2.3 (got '$TAG')"
90+
exit 1
91+
fi
6992
VERSION="${TAG#v}"
7093
PKG_VERSION=$(python setup.py --version)
94+
echo "Package version: $PKG_VERSION"
95+
echo "PKG_VERSION=$PKG_VERSION" >> "$GITHUB_ENV"
7196
if [ "$VERSION" != "$PKG_VERSION" ]; then
7297
echo "::error::Tag $TAG does not match setup.py version $PKG_VERSION"
7398
exit 1
@@ -85,3 +110,7 @@ jobs:
85110
86111
- name: Publish to PyPI
87112
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1
113+
114+
- name: Summary
115+
run: |
116+
echo "Published version $PKG_VERSION to PyPI"

.github/workflows/test-release.yml

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,49 @@
1-
name: Test and Release
1+
name: Pre-release Check (Dry Run)
2+
23
on:
34
workflow_dispatch:
45
inputs:
56
python-version:
67
description: "Python version to test with (or 'all' for full matrix)"
78
required: false
89
default: "3.12"
10+
schedule:
11+
- cron: '30 3 * * 1' # Monday 9AM IST
912

1013
env:
1114
ARTIFACTORY_URL: ${{ vars.ARTIFACTORY_URL }}
1215

1316
jobs:
17+
lockfile-hygiene:
18+
runs-on: ubuntu-x64
19+
steps:
20+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
21+
- uses: twilio/sdk-actions/uv-lockfile-hygiene@23b656b843d2a3461cf38e4fd466c07a822d5fc0 # v1
22+
with:
23+
clean-room: 'false'
24+
1425
test:
1526
name: Test - Python ${{ matrix.python-version }}
16-
runs-on: ${{ 'ubuntu-x64' }}
17-
# github.repository_owner == 'twilio' && 'ubuntu-latest' ||
27+
needs: [lockfile-hygiene]
28+
runs-on: ubuntu-x64
29+
if: github.repository_owner == 'twilio'
1830
timeout-minutes: 20
1931
permissions:
2032
contents: read
2133
id-token: write
2234
strategy:
2335
fail-fast: false
2436
matrix:
25-
python-version: ${{ github.event.inputs.python-version == 'all' && fromJson('["3.8","3.9","3.10","3.11","3.12","3.13"]') || fromJson(format('["{0}"]', github.event.inputs.python-version)) }}
37+
python-version: ${{ github.event.inputs.python-version == 'all' && fromJson('["3.8","3.9","3.10","3.11","3.12","3.13"]') || fromJson(format('["{0}"]', github.event.inputs.python-version || '3.12')) }}
2638
steps:
27-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
39+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
2840
with:
2941
fetch-depth: 0
3042

31-
- name: Authenticate with Artifactory
32-
uses: ./.github/artifactory-oidc
43+
- name: Artifactory OIDC Auth
44+
uses: twilio/sdk-actions/artifactory-oidc@23b656b843d2a3461cf38e4fd466c07a822d5fc0 # v1
45+
with:
46+
ecosystem: python
3347

3448
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
3549
with:
@@ -43,21 +57,21 @@ jobs:
4357
- name: Run tests
4458
run: make test-with-coverage
4559

46-
deploy:
47-
name: Build and Publish to PyPI
60+
deploy-dry-run:
61+
name: Pre-release validation - No Publish
4862
needs: [test]
49-
runs-on: ${{ 'ubuntu-x64' }}
50-
#runs-on: ${{ github.repository_owner == 'twilio' && 'ubuntu-latest' || 'ubuntu-x64' }}
51-
environment: production
63+
runs-on: ubuntu-x64
64+
if: github.repository_owner == 'twilio'
5265
permissions:
5366
contents: read
5467
id-token: write
55-
attestations: write
5668
steps:
57-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
69+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5870

59-
- name: Authenticate with Artifactory
60-
uses: ./.github/artifactory-oidc
71+
- name: Artifactory OIDC Auth
72+
uses: twilio/sdk-actions/artifactory-oidc@23b656b843d2a3461cf38e4fd466c07a822d5fc0 # v1
73+
with:
74+
ecosystem: python
6175

6276
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
6377
with:
@@ -66,18 +80,14 @@ jobs:
6680
- name: Install setuptools
6781
run: pip install setuptools
6882

69-
- name: Validate tag matches package version
83+
- name: Validate version format
7084
run: |
7185
PKG_VERSION=$(python setup.py --version)
7286
echo "Package version: $PKG_VERSION"
7387
echo "PKG_VERSION=$PKG_VERSION" >> "$GITHUB_ENV"
74-
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
75-
TAG="${GITHUB_REF#refs/tags/}"
76-
VERSION="${TAG#v}"
77-
if [ "$VERSION" != "$PKG_VERSION" ]; then
78-
echo "::error::Tag $TAG does not match setup.py version $PKG_VERSION"
79-
exit 1
80-
fi
88+
if [[ ! "$PKG_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
89+
echo "::error::setup.py version must follow semver (got '$PKG_VERSION')"
90+
exit 1
8191
fi
8292
8393
- name: Build package
@@ -97,11 +107,8 @@ jobs:
97107
echo ""
98108
echo "Package version: $PKG_VERSION"
99109
100-
- name: Publish to PyPI
101-
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1
102-
103-
- name: Summary
110+
- name: Dry run summary
104111
run: |
105-
echo "--- RELEASE COMPLETE ---"
106-
echo "Published version $PKG_VERSION to PyPI"
112+
echo "--- DRY RUN COMPLETE ---"
113+
echo "All pre-release steps passed for version $PKG_VERSION"
107114

0 commit comments

Comments
 (0)