Debian Codegraph @

.github/workflows/publish.yaml

raw
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@b4ffde65f46336ab88eb53be808477a3936bae11
13 - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c
14 with:
15 python-version: '3.x'
16 - run: pip install build
17 # Use the commit date instead of the current date during the build.
18 - run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
19 - run: python -m build
20 # Generate hashes used for provenance.
21 - name: generate hash
22 id: hash
23 run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
24 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
25 with:
26 path: ./dist
27 provenance:
28 needs: ['build']
29 permissions:
30 actions: read
31 id-token: write
32 contents: write
33 # Can't pin with hash due to how this workflow works.
34 uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
35 with:
36 base64-subjects: ${{ needs.build.outputs.hash }}
37 create-release:
38 # Upload the sdist, wheels, and provenance to a GitHub release. They remain
39 # available as build artifacts for a while as well.
40 needs: ['provenance']
41 runs-on: ubuntu-latest
42 permissions:
43 contents: write
44 steps:
45 - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
46 - name: create release
47 run: >
48 gh release create --draft --repo ${{ github.repository }}
49 ${{ github.ref_name }}
50 *.intoto.jsonl/* artifact/*
51 env:
52 GH_TOKEN: ${{ github.token }}
53 publish-pypi:
54 needs: ['provenance']
55 # Wait for approval before attempting to upload to PyPI. This allows reviewing the
56 # files in the draft release.
57 environment: 'publish'
58 runs-on: ubuntu-latest
59 permissions:
60 id-token: write
61 steps:
62 - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
63 - uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf
64 with:
65 packages-dir: artifact/