|
| 1 | +name: main |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - '*' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 # Ensures version gets set correctly |
| 20 | + |
| 21 | + - name: Set up Python |
| 22 | + uses: actions/setup-python@v5 |
| 23 | + with: |
| 24 | + python-version: "3.x" |
| 25 | + |
| 26 | + - name: Install Hatch |
| 27 | + run: | |
| 28 | + python -m pip install --upgrade pip |
| 29 | + pip install hatch hatchling hatch-vcs |
| 30 | +
|
| 31 | + - name: Build package |
| 32 | + run: hatch build |
| 33 | + |
| 34 | + - name: Store the distribution packages |
| 35 | + uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: bitwarden-menu |
| 38 | + path: dist/ |
| 39 | + |
| 40 | + publish-to-pypi: |
| 41 | + name: Publish to PyPI |
| 42 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 43 | + needs: |
| 44 | + - build |
| 45 | + runs-on: ubuntu-latest |
| 46 | + environment: |
| 47 | + name: pypi |
| 48 | + url: https://pypi.org/p/bitwarden-menu # Replace <package-name> with your PyPI project name |
| 49 | + permissions: |
| 50 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Download all the dists |
| 54 | + uses: actions/download-artifact@v4 |
| 55 | + with: |
| 56 | + name: bitwarden-menu |
| 57 | + path: dist/ |
| 58 | + - name: Publish to PyPI |
| 59 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 60 | + |
| 61 | + github-release: |
| 62 | + name: >- |
| 63 | + Sign the with Sigstore and upload to GitHub Release |
| 64 | + needs: |
| 65 | + - publish-to-pypi |
| 66 | + runs-on: ubuntu-latest |
| 67 | + |
| 68 | + permissions: |
| 69 | + contents: write # IMPORTANT: mandatory for making GitHub Releases |
| 70 | + id-token: write # IMPORTANT: mandatory for sigstore |
| 71 | + |
| 72 | + steps: |
| 73 | + - name: Download all the dists |
| 74 | + uses: actions/download-artifact@v4 |
| 75 | + with: |
| 76 | + name: bitwarden-menu |
| 77 | + path: dist/ |
| 78 | + - name: Sign the dists with Sigstore |
| 79 | + uses: sigstore/gh-action-sigstore-python@v3.0.0 |
| 80 | + with: |
| 81 | + inputs: >- |
| 82 | + ./dist/*.tar.gz |
| 83 | + ./dist/*.whl |
| 84 | + - name: Create GitHub Release |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ github.token }} |
| 87 | + run: >- |
| 88 | + gh release create |
| 89 | + '${{ github.ref_name }}' |
| 90 | + --repo '${{ github.repository }}' |
| 91 | + --notes "" |
| 92 | + - name: Upload artifact signatures to GitHub Release |
| 93 | + env: |
| 94 | + GITHUB_TOKEN: ${{ github.token }} |
| 95 | + # Upload to GitHub Release using the `gh` CLI. |
| 96 | + # `dist/` contains the built packages, and the |
| 97 | + # sigstore-produced signatures and certificates. |
| 98 | + run: >- |
| 99 | + gh release upload |
| 100 | + '${{ github.ref_name }}' dist/** |
| 101 | + --repo '${{ github.repository }}' |
| 102 | +
|
| 103 | + publish-to-testpypi: |
| 104 | + name: Publish to TestPyPI |
| 105 | + needs: |
| 106 | + - build |
| 107 | + runs-on: ubuntu-latest |
| 108 | + |
| 109 | + environment: |
| 110 | + name: testpypi |
| 111 | + url: https://test.pypi.org/p/bitwarden-menu |
| 112 | + |
| 113 | + permissions: |
| 114 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 115 | + |
| 116 | + steps: |
| 117 | + - name: Download all the dists |
| 118 | + uses: actions/download-artifact@v4 |
| 119 | + with: |
| 120 | + name: bitwarden-menu |
| 121 | + path: dist/ |
| 122 | + - name: Publish to TestPyPI |
| 123 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 124 | + with: |
| 125 | + repository-url: https://test.pypi.org/legacy/ |
0 commit comments