|
1 | | -name: Publish Python Package |
| 1 | +name: Create and Publish Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | | - types: [created] |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' # Trigger on version tags |
| 7 | + branches-ignore: |
| 8 | + - '**' # Ignore branch pushes, only trigger on tags |
6 | 9 |
|
7 | 10 | jobs: |
8 | | - deploy: |
| 11 | + publish-pypi: |
| 12 | + environment: |
| 13 | + name: pypi |
9 | 14 | runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + packages: write |
| 18 | + id-token: write |
| 19 | + |
10 | 20 | steps: |
11 | 21 | - uses: actions/checkout@v3 |
12 | | - |
13 | | - - name: Set up Python |
14 | | - uses: actions/setup-python@v4 |
15 | 22 | with: |
16 | | - python-version: '3.x' |
| 23 | + fetch-depth: 0 |
| 24 | + - uses: ./.github/actions/build-elroy |
17 | 25 |
|
18 | | - - name: Install uv |
19 | | - run: | |
20 | | - curl -LsSf https://astral.sh/uv/install.sh | sh |
21 | | - echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
22 | | -
|
23 | | - - name: Build package |
| 26 | + - name: Publish to PyPI |
| 27 | + env: |
| 28 | + TWINE_USERNAME: __token__ |
| 29 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
24 | 30 | run: | |
| 31 | + pip install --user uv |
| 32 | + uv venv |
| 33 | + source .venv/bin/activate |
25 | 34 | uv pip install build |
26 | 35 | python -m build |
| 36 | + uv pip install twine |
| 37 | + twine upload dist/* |
27 | 38 |
|
28 | | - - name: Publish to PyPI |
| 39 | + create-github-release: |
| 40 | + environment: |
| 41 | + name: pypi |
| 42 | + needs: [publish-pypi] |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v3 |
| 46 | + with: |
| 47 | + fetch-depth: 0 |
| 48 | + |
| 49 | + - name: Create GitHub Release |
| 50 | + uses: actions/create-release@v1 |
| 51 | + with: |
| 52 | + tag_name: ${{ github.ref }} |
| 53 | + release_name: Release ${{ github.ref }} |
| 54 | + draft: false |
| 55 | + prerelease: false |
| 56 | + body_path: CHANGELOG.md |
29 | 57 | env: |
30 | | - PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 58 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + update-stable-and-deploy-branch: |
| 60 | + environment: |
| 61 | + name: pypi |
| 62 | + needs: [create-github-release] |
| 63 | + runs-on: ubuntu-latest |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v3 |
| 66 | + with: |
| 67 | + fetch-depth: 0 |
| 68 | + - name: Update stable branch |
31 | 69 | run: | |
32 | | - uv pip install twine |
33 | | - python -m twine upload --repository pypi dist/* -u __token__ -p $PYPI_API_TOKEN |
| 70 | + git config --global user.name 'GitHub Actions' |
| 71 | + git config --global user.email 'actions@github.com' |
| 72 | + git checkout stable || git checkout -b stable |
| 73 | + git reset --hard ${GITHUB_REF} |
| 74 | + git push -f origin stable |
| 75 | + git checkout deploy || git checkout -b deploy |
| 76 | + git reset --hard ${GITHUB_REF} |
| 77 | + git push -f origin deploy |
0 commit comments