-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df9396b
commit af60ef8
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Publish package to PyPI | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
hash: ${{ steps.hash.outputs.hash }} | ||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | ||
with: | ||
python-version: '3.x' | ||
cache: pip | ||
cache-dependency-path: requirements*/*.txt | ||
- run: pip install -r requirements/build.txt | ||
# Use the commit date instead of the current date during the build. | ||
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV | ||
- run: python -m build | ||
# Generate hashes used for provenance. | ||
- name: generate hash | ||
id: hash | ||
run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT | ||
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
path: ./dist | ||
|
||
provenance: | ||
needs: [build] | ||
permissions: | ||
actions: read | ||
id-token: write | ||
contents: write | ||
# Can't pin with hash due to how this workflow works. | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@41733f74c025cc6d156547121989dd50fbc92364 | ||
with: | ||
base64-subjects: ${{ needs.build.outputs.hash }} | ||
|
||
create-release: | ||
# Upload the sdist, wheels, and provenance to a GitHub release. They remain | ||
# available as build artifacts for a while as well. | ||
needs: [provenance] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 | ||
- name: create release | ||
run: > | ||
gh release create --draft --repo ${{ github.repository }} | ||
${{ github.ref_name }} | ||
*.intoto.jsonl/* artifact/* | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
|
||
publish-pypi: | ||
name: Upload release to PyPI | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/project/NGOHub/${{ github.ref_name }} | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 | ||
- uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
packages-dir: artifact/ | ||
# TEMP: Use test.pypi.org until we figure out this is stable | ||
# - uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0 | ||
# with: | ||
# packages-dir: artifact/ |