|
| 1 | +--- |
| 2 | + |
| 3 | +name: Publish |
| 4 | + |
| 5 | +on: push # yamllint disable-line rule:truthy |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + name: Build distribution package |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + persist-credentials: false |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: "3.x" |
| 20 | + - name: Install pypa/build |
| 21 | + run: python -m pip install --user build |
| 22 | + - name: Build a binary wheel and a source tarball |
| 23 | + run: python -m build |
| 24 | + - name: Store the distribution packages |
| 25 | + uses: actions/upload-artifact@v4 |
| 26 | + with: |
| 27 | + name: python-package-distributions |
| 28 | + path: dist/ |
| 29 | + |
| 30 | + publish-to-testpypi: |
| 31 | + name: Publish distribution package to TestPyPI |
| 32 | + needs: build |
| 33 | + runs-on: ubuntu-latest |
| 34 | + environment: |
| 35 | + name: testpypi |
| 36 | + url: https://test.pypi.org/p/yamllint |
| 37 | + permissions: |
| 38 | + id-token: write |
| 39 | + steps: |
| 40 | + - name: Download all the dists |
| 41 | + uses: actions/download-artifact@v4 |
| 42 | + with: |
| 43 | + name: python-package-distributions |
| 44 | + path: dist/ |
| 45 | + - name: Publish distribution package |
| 46 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 47 | + with: |
| 48 | + repository-url: https://test.pypi.org/legacy/ |
| 49 | + |
| 50 | + publish-to-pypi: |
| 51 | + name: Publish distribution package to PyPI |
| 52 | + if: startsWith(github.ref, 'refs/tags/') # only for tags |
| 53 | + needs: build |
| 54 | + runs-on: ubuntu-latest |
| 55 | + environment: |
| 56 | + name: pypi |
| 57 | + url: https://pypi.org/p/yamllint |
| 58 | + permissions: |
| 59 | + id-token: write |
| 60 | + steps: |
| 61 | + - name: Download all the dists |
| 62 | + uses: actions/download-artifact@v4 |
| 63 | + with: |
| 64 | + name: python-package-distributions |
| 65 | + path: dist/ |
| 66 | + - name: Publish distribution package |
| 67 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 68 | + |
| 69 | + github-release: |
| 70 | + name: Sign and upload GitHub Release |
| 71 | + needs: publish-to-pypi |
| 72 | + runs-on: ubuntu-latest |
| 73 | + permissions: |
| 74 | + contents: write |
| 75 | + id-token: write |
| 76 | + steps: |
| 77 | + - name: Download all the dists |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + name: python-package-distributions |
| 81 | + path: dist/ |
| 82 | + - name: Sign the dists with Sigstore |
| 83 | + |
| 84 | + with: |
| 85 | + inputs: dist/yamllint-*.tar.gz dist/yamllint-*.whl |
| 86 | + - name: Create GitHub Release |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: ${{ github.token }} |
| 89 | + run: |
| 90 | + gh release create |
| 91 | + "$GITHUB_REF_NAME" |
| 92 | + --repo "$GITHUB_REPOSITORY" |
| 93 | + --notes "" |
| 94 | + - name: Upload artifact signatures to GitHub Release |
| 95 | + env: |
| 96 | + GITHUB_TOKEN: ${{ github.token }} |
| 97 | + run: |
| 98 | + gh release upload |
| 99 | + "$GITHUB_REF_NAME" |
| 100 | + dist/** |
| 101 | + --repo "$GITHUB_REPOSITORY" |
0 commit comments