|
| 1 | +name: Publish |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - '*' |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + outputs: |
| 10 | + hash: ${{ steps.hash.outputs.hash }} |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 13 | + - uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 |
| 14 | + with: |
| 15 | + python-version: '3.x' |
| 16 | + cache: pip |
| 17 | + - run: pip install -e . |
| 18 | + # Use the commit date instead of the current date during the build. |
| 19 | + - run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV |
| 20 | + - run: python -m build |
| 21 | + # Generate hashes used for provenance. |
| 22 | + - name: generate hash |
| 23 | + id: hash |
| 24 | + run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT |
| 25 | + - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 |
| 26 | + with: |
| 27 | + path: ./dist |
| 28 | + provenance: |
| 29 | + needs: [build] |
| 30 | + permissions: |
| 31 | + actions: read |
| 32 | + id-token: write |
| 33 | + contents: write |
| 34 | + # Can't pin with hash due to how this workflow works. |
| 35 | + uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] |
| 36 | + with: |
| 37 | + base64-subjects: ${{ needs.build.outputs.hash }} |
| 38 | + create-release: |
| 39 | + # Upload the sdist, wheels, and provenance to a GitHub release. They remain |
| 40 | + # available as build artifacts for a while as well. |
| 41 | + needs: [provenance] |
| 42 | + runs-on: ubuntu-latest |
| 43 | + permissions: |
| 44 | + contents: write |
| 45 | + steps: |
| 46 | + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 47 | + - name: create release |
| 48 | + run: > |
| 49 | + gh release create --draft --repo ${{ github.repository }} |
| 50 | + ${{ github.ref_name }} |
| 51 | + *.intoto.jsonl/* artifact/* |
| 52 | + env: |
| 53 | + GH_TOKEN: ${{ github.token }} |
| 54 | + publish-pypi: |
| 55 | + needs: [provenance] |
| 56 | + # Wait for approval before attempting to upload to PyPI. This allows reviewing the |
| 57 | + # files in the draft release. |
| 58 | + environment: |
| 59 | + name: publish |
| 60 | + url: https://pypi.org/project/wtforms/${{ github.ref_name }} |
| 61 | + runs-on: ubuntu-latest |
| 62 | + permissions: |
| 63 | + id-token: write |
| 64 | + steps: |
| 65 | + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 66 | + - uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0 |
| 67 | + with: |
| 68 | + repository-url: https://test.pypi.org/legacy/ |
| 69 | + packages-dir: artifact/ |
| 70 | + - uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0 |
| 71 | + with: |
| 72 | + packages-dir: artifact/ |
0 commit comments