Skip to content

Commit 0b4b611

Browse files
committedJan 20, 2023
build, provenance, publish workflow
1 parent 99b34f7 commit 0b4b611

File tree

5 files changed

+106
-9
lines changed

5 files changed

+106
-9
lines changed
 

‎.github/workflows/lock.yaml

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
# This does not automatically close "stale" issues. Instead, it locks closed issues after 2 weeks of no activity.
2-
# If there's a new issue related to an old one, we've found it's much easier to work on as a new issue.
3-
41
name: 'Lock threads'
2+
# Lock closed issues that have not received any further activity for
3+
# two weeks. This does not close open issues, only humans may do that.
4+
# We find that it is easier to respond to new issues with fresh examples
5+
# rather than continuing discussions on old issues.
56

67
on:
78
schedule:
89
- cron: '0 0 * * *'
910

11+
permissions:
12+
issues: write
13+
pull-requests: write
14+
15+
concurrency:
16+
group: lock
17+
1018
jobs:
1119
lock:
1220
runs-on: ubuntu-latest
1321
steps:
14-
- uses: dessant/lock-threads@v3
22+
- uses: dessant/lock-threads@c1b35aecc5cdb1a34539d14196df55838bb2f836
1523
with:
16-
github-token: ${{ github.token }}
1724
issue-inactive-days: 14
1825
pr-inactive-days: 14

‎.github/workflows/publish.yaml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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@ac593985615ec2ede58e132d2e21d2b1cbd6127c
13+
- uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912
14+
with:
15+
python-version: '3.x'
16+
cache: 'pip'
17+
cache-dependency-path: 'requirements/*.txt'
18+
- run: pip install -r requirements/build.txt
19+
# Use the commit date instead of the current date during the build.
20+
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
21+
- run: python -m build
22+
# Generate hashes used for provenance.
23+
- name: generate hash
24+
id: hash
25+
run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
26+
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
27+
with:
28+
path: ./dist
29+
provenance:
30+
needs: ['build']
31+
permissions:
32+
actions: read
33+
id-token: write
34+
contents: write
35+
# Can't pin with hash due to how this workflow works.
36+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0
37+
with:
38+
base64-subjects: ${{ needs.build.outputs.hash }}
39+
create-release:
40+
# Upload the sdist, wheels, and provenance to a GitHub release. They remain
41+
# available as build artifacts for a while as well.
42+
needs: ['provenance']
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
46+
steps:
47+
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
48+
- name: create release
49+
run: >
50+
gh release create --draft --repo ${{ github.repository }}
51+
${{ github.ref_name }}
52+
*.intoto.jsonl/* artifact/*
53+
env:
54+
GH_TOKEN: ${{ github.token }}
55+
publish-pypi:
56+
needs: ['provenance']
57+
# Wait for approval before attempting to upload to PyPI. This allows reviewing the
58+
# files in the draft release.
59+
environment: 'publish'
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
63+
# Try uploading to Test PyPI first, in case something fails.
64+
- uses: pypa/gh-action-pypi-publish@c7f29f7adef1a245bd91520e94867e5c6eedddcc
65+
with:
66+
password: ${{ secrets.TEST_PYPI_TOKEN }}
67+
repository_url: https://test.pypi.org/legacy/
68+
packages_dir: artifact/
69+
- uses: pypa/gh-action-pypi-publish@c7f29f7adef1a245bd91520e94867e5c6eedddcc
70+
with:
71+
password: ${{ secrets.PYPI_TOKEN }}
72+
packages_dir: artifact/

‎.github/workflows/tests.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535
- {name: 'PyPy', python: 'pypy-3.9', os: ubuntu-latest, tox: pypy39}
3636
- {name: 'Pallets Minimum Versions', python: '3.11', os: ubuntu-latest, tox: py311-min}
3737
- {name: 'Pallets Development Versions', python: '3.7', os: ubuntu-latest, tox: py37-dev}
38-
- {name: Typing, python: '3.10', os: ubuntu-latest, tox: typing}
38+
- {name: Typing, python: '3.11', os: ubuntu-latest, tox: typing}
3939
steps:
40-
- uses: actions/checkout@v3
41-
- uses: actions/setup-python@v4
40+
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
41+
- uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912
4242
with:
4343
python-version: ${{ matrix.python }}
4444
cache: 'pip'
@@ -49,7 +49,7 @@ jobs:
4949
pip install -U setuptools
5050
python -m pip install -U pip
5151
- name: cache mypy
52-
uses: actions/cache@v3.2.2
52+
uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12
5353
with:
5454
path: ./.mypy_cache
5555
key: mypy|${{ matrix.python }}|${{ hashFiles('setup.cfg') }}

‎requirements/build.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

‎requirements/build.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SHA1:80754af91bfb6d1073585b046fe0a474ce868509
2+
#
3+
# This file is autogenerated by pip-compile-multi
4+
# To update, run:
5+
#
6+
# pip-compile-multi
7+
#
8+
build==0.9.0
9+
# via -r requirements/build.in
10+
packaging==23.0
11+
# via build
12+
pep517==0.13.0
13+
# via build
14+
tomli==2.0.1
15+
# via
16+
# build
17+
# pep517

0 commit comments

Comments
 (0)
Please sign in to comment.