|
| 1 | +name: Publish asgardeo-ai to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'asgardeo-ai-v*' # e.g. asgardeo-ai-v1.2.3 |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version_type: |
| 10 | + description: 'Version bump type (only used for manual dispatch)' |
| 11 | + required: true |
| 12 | + type: choice |
| 13 | + default: patch |
| 14 | + options: [patch, minor, major] |
| 15 | + asgardeo_version: |
| 16 | + description: 'Optional: set asgardeo version (e.g. ^1.2.3) if converting from path dep' |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + |
| 20 | +jobs: |
| 21 | + publish-asgardeo-ai: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v4 |
| 28 | + with: |
| 29 | + python-version: '3.10' |
| 30 | + |
| 31 | + - name: Install Poetry |
| 32 | + uses: snok/install-poetry@v1 |
| 33 | + with: |
| 34 | + version: latest |
| 35 | + virtualenvs-create: true |
| 36 | + virtualenvs-in-project: true |
| 37 | + |
| 38 | + - name: Bump version (manual dispatch only) |
| 39 | + if: github.event_name == 'workflow_dispatch' |
| 40 | + working-directory: ./packages/asgardeo-ai |
| 41 | + id: bump |
| 42 | + run: | |
| 43 | + echo "Bumping version: ${{ github.event.inputs.version_type }}" |
| 44 | + poetry version ${{ github.event.inputs.version_type }} |
| 45 | + NEW_VERSION=$(poetry version -s) |
| 46 | + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 47 | + echo "New asgardeo-ai version: $NEW_VERSION" |
| 48 | +
|
| 49 | + - name: Ensure asgardeo dependency uses PyPI, not path |
| 50 | + working-directory: ./packages/asgardeo-ai |
| 51 | + run: | |
| 52 | + if grep -q 'asgardeo = { path' pyproject.toml; then |
| 53 | + echo 'Path dependency detected.' |
| 54 | + if [ -n "${{ github.event.inputs.asgardeo_version }}" ]; then |
| 55 | + TARGET="${{ github.event.inputs.asgardeo_version }}" |
| 56 | + echo "Converting to version spec: $TARGET" |
| 57 | + sed -i "s|asgardeo = { path = \"..\/asgardeo\", develop = true }|asgardeo = \"$TARGET\"|" pyproject.toml |
| 58 | + else |
| 59 | + echo 'ERROR: Provide asgardeo_version input to replace path dependency.' >&2 |
| 60 | + exit 1 |
| 61 | + fi |
| 62 | + else |
| 63 | + echo 'asgardeo already uses a version spec.' |
| 64 | + fi |
| 65 | + echo 'Current asgardeo dependency line:' |
| 66 | + grep '^asgardeo\s*=' pyproject.toml || true |
| 67 | +
|
| 68 | + - name: Validate tag vs pyproject version (tag builds) |
| 69 | + if: startsWith(github.ref, 'refs/tags/asgardeo-ai-v') |
| 70 | + working-directory: ./packages/asgardeo-ai |
| 71 | + run: | |
| 72 | + TAG_VERSION="${GITHUB_REF_NAME#asgardeo-ai-v}" |
| 73 | + FILE_VERSION=$(poetry version -s) |
| 74 | + if [ "$TAG_VERSION" != "$FILE_VERSION" ]; then |
| 75 | + echo "Tag version ($TAG_VERSION) does not match pyproject.toml version ($FILE_VERSION)." >&2 |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | + echo "Tag and pyproject versions match: $TAG_VERSION" |
| 79 | +
|
| 80 | + - name: Install dependencies & build wheel |
| 81 | + working-directory: ./packages/asgardeo-ai |
| 82 | + run: | |
| 83 | + poetry install |
| 84 | + poetry build |
| 85 | +
|
| 86 | + - name: Publish to PyPI |
| 87 | + working-directory: ./packages/asgardeo-ai |
| 88 | + env: |
| 89 | + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} |
| 90 | + run: | |
| 91 | + echo "Publishing asgardeo-ai to PyPI" |
| 92 | + poetry publish |
| 93 | + echo "Published asgardeo-ai" |
| 94 | +
|
| 95 | + - name: Summary |
| 96 | + working-directory: ./packages/asgardeo-ai |
| 97 | + run: | |
| 98 | + VERSION=$(poetry version -s) |
| 99 | + echo "asgardeo-ai version published: $VERSION" |
0 commit comments