|
| 1 | +name: Deploy to PyPi |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'v*' |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + name: Build Wheels and Package 🛠️ |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout Code |
| 12 | + uses: actions/checkout@v4 |
| 13 | + - name: Set up Python 3.12 |
| 14 | + uses: actions/setup-python@v5 |
| 15 | + with: |
| 16 | + python-version: "3.x" |
| 17 | + - name: Install UV |
| 18 | + run: python -m pip install uv |
| 19 | + - name: Build Module |
| 20 | + run: uv build |
| 21 | + - name: Store the distribution packages |
| 22 | + uses: actions/upload-artifact@v4 |
| 23 | + with: |
| 24 | + retention-days: 1 |
| 25 | + if-no-files-found: error |
| 26 | + name: python-package-distributions |
| 27 | + path: dist/ |
| 28 | + publish_test: |
| 29 | + name: Publish to TestPyPi 🧪 |
| 30 | + needs: |
| 31 | + - build |
| 32 | + runs-on: ubuntu-latest |
| 33 | + environment: |
| 34 | + name: test_pypi |
| 35 | + url: https://test.pypi.org/p/simvue-cli |
| 36 | + permissions: |
| 37 | + id-token: write |
| 38 | + steps: |
| 39 | + - name: Download all the dists |
| 40 | + uses: actions/download-artifact@v4 |
| 41 | + with: |
| 42 | + name: python-package-distributions |
| 43 | + path: dist/ |
| 44 | + - name: Publish to TestPyPi |
| 45 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 46 | + with: |
| 47 | + repository-url: https://test.pypi.org/legacy/ |
| 48 | + publish: |
| 49 | + name: Publish to PyPi 🐍📦 |
| 50 | + needs: |
| 51 | + - publish_test |
| 52 | + if: "!contains(github.ref, 'rc') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')" |
| 53 | + runs-on: ubuntu-latest |
| 54 | + environment: |
| 55 | + name: pypi |
| 56 | + url: https://pypi.org/p/simvue-cli |
| 57 | + permissions: |
| 58 | + id-token: write |
| 59 | + steps: |
| 60 | + - name: Download all the dists |
| 61 | + uses: actions/download-artifact@v4 |
| 62 | + with: |
| 63 | + name: python-package-distributions |
| 64 | + path: dist/ |
| 65 | + - name: Publish to PyPi |
| 66 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 67 | + github-release: |
| 68 | + name: Create Signed GitHub Release 🔏 |
| 69 | + needs: |
| 70 | + - publish |
| 71 | + runs-on: ubuntu-latest |
| 72 | + permissions: |
| 73 | + contents: write |
| 74 | + id-token: write |
| 75 | + steps: |
| 76 | + - name: Download all the dists |
| 77 | + uses: actions/download-artifact@v4 |
| 78 | + with: |
| 79 | + name: python-package-distributions |
| 80 | + path: dist/ |
| 81 | + - name: Sign the dists with Sigstore |
| 82 | + |
| 83 | + with: |
| 84 | + inputs: >- |
| 85 | + ./dist/*.tar.gz |
| 86 | + ./dist/*.whl |
| 87 | + - name: Create GitHub Release |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ github.token }} |
| 90 | + run: >- |
| 91 | + LATESTCHANGES=$(awk ' |
| 92 | + BEGIN { header_found = 0 } |
| 93 | + /^## / { |
| 94 | + if (header_found == 0) { |
| 95 | + header = $0 |
| 96 | + header_found = 1 |
| 97 | + next |
| 98 | + } else { |
| 99 | + exit |
| 100 | + } |
| 101 | + } |
| 102 | + header_found == 1 && /^\* / { print } |
| 103 | + ' CHANGELOG.md) |
| 104 | + gh release create |
| 105 | + '${{ github.ref_name }}' |
| 106 | + --notes "$LATESTCHANGES" |
| 107 | + --title 'Simvue CLI ${{ github.ref_name }}' |
| 108 | + --repo '${{ github.repository }}' |
| 109 | + - name: Upload artifact signatures to GitHub Release |
| 110 | + env: |
| 111 | + GITHUB_TOKEN: ${{ github.token }} |
| 112 | + run: >- |
| 113 | + gh release upload |
| 114 | + '${{ github.ref_name }}' dist/** |
| 115 | + --repo '${{ github.repository }}' |
0 commit comments