|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: 'Version to release (e.g., 0.1.0)' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-and-publish: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + id-token: write |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python 3.13.7 |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: "3.13.7" |
| 28 | + |
| 29 | + - name: Cache pip dependencies |
| 30 | + uses: actions/cache@v4 |
| 31 | + with: |
| 32 | + path: ~/.cache/pip |
| 33 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} |
| 34 | + restore-keys: | |
| 35 | + ${{ runner.os }}-pip- |
| 36 | +
|
| 37 | + - name: Install dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip |
| 40 | + pip install build twine |
| 41 | +
|
| 42 | + - name: Build package |
| 43 | + run: | |
| 44 | + python -m build |
| 45 | +
|
| 46 | + - name: Check package |
| 47 | + run: | |
| 48 | + twine check dist/* |
| 49 | +
|
| 50 | + - name: Upload to PyPI |
| 51 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 52 | + with: |
| 53 | + user: ${{ secrets.PYPI_USERNAME }} |
| 54 | + password: ${{ secrets.PYPI_PASSWORD }} |
| 55 | + |
| 56 | + - name: Create GitHub Release |
| 57 | + if: github.event_name == 'release' |
| 58 | + uses: actions/create-release@v1 |
| 59 | + env: |
| 60 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + with: |
| 62 | + tag_name: ${{ github.event.release.tag_name }} |
| 63 | + release_name: ${{ github.event.release.name }} |
| 64 | + body: ${{ github.event.release.body }} |
| 65 | + draft: false |
| 66 | + prerelease: false |
| 67 | + |
| 68 | + test-release: |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: build-and-publish |
| 71 | + if: github.event_name == 'workflow_dispatch' |
| 72 | + |
| 73 | + steps: |
| 74 | + - name: Checkout code |
| 75 | + uses: actions/checkout@v4 |
| 76 | + |
| 77 | + - name: Set up Python 3.13.7 |
| 78 | + uses: actions/setup-python@v5 |
| 79 | + with: |
| 80 | + python-version: "3.13.7" |
| 81 | + |
| 82 | + - name: Install released package |
| 83 | + run: | |
| 84 | + python -m pip install --upgrade pip |
| 85 | + pip install sqlmodel-encrypted-fields==${{ github.event.inputs.version }} |
| 86 | +
|
| 87 | + - name: Test installed package |
| 88 | + run: | |
| 89 | + python -c "import sqlmodel_encrypted_fields; print('Package installed successfully')" |
| 90 | + python -c "from sqlmodel_encrypted_fields import EncryptedString; print('Fields imported successfully')" |
0 commit comments