Skip to content

Commit b929162

Browse files
committed
chore: use Flask inspired GHA workflow
1 parent 07049e3 commit b929162

File tree

3 files changed

+105
-22
lines changed

3 files changed

+105
-22
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: pre-commit
2+
on:
3+
pull_request:
4+
push:
5+
branches: [main, '*.x']
6+
jobs:
7+
main:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
11+
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
12+
with:
13+
python-version: 3.x
14+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
15+
- uses: pre-commit-ci/lite-action@9d882e7a565f7008d4faf128f27d1cb6503d4ebf # v1.0.2
16+
if: ${{ !cancelled() }}

.github/workflows/publish.yaml

Lines changed: 72 additions & 0 deletions
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@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/generator_generic_slsa3.yml@v2.0.0
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/flask-wtf/${{ 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/

.github/workflows/tests.yaml

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,34 @@ on:
44
branches:
55
- main
66
- '*.x'
7+
paths-ignore:
8+
- 'docs/**'
9+
- '*.md'
10+
- '*.rst'
711
pull_request:
8-
branches:
9-
- main
10-
- '*.x'
1112
paths-ignore:
1213
- 'docs/**'
14+
- '*.md'
1315
- '*.rst'
1416
jobs:
1517
tests:
16-
name: ${{ matrix.name }}
17-
runs-on: ubuntu-latest
18+
name: ${{ matrix.name || matrix.python }}
19+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
1820
strategy:
1921
fail-fast: false
2022
matrix:
2123
include:
22-
- {name: '3.13', python: '3.13', tox: 'py313,py-no-babel'}
23-
- {name: '3.12', python: '3.12', tox: py312}
24-
- {name: '3.11', python: '3.11', tox: py311}
25-
- {name: '3.10', python: '3.10', tox: py310}
26-
- {name: '3.9', python: '3.9', tox: py39}
27-
- {name: 'PyPy310', python: 'pypy-3.10', tox: pypy310}
28-
- {name: 'PyPy39', python: 'pypy-3.9', tox: pypy39}
24+
- {python: '3.13'}
25+
- {python: '3.12'}
26+
- {python: '3.11'}
27+
- {python: '3.10'}
28+
- {python: '3.9'}
2929
steps:
30-
- uses: actions/checkout@v4
31-
- uses: actions/setup-python@v5
30+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
31+
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
3232
with:
3333
python-version: ${{ matrix.python }}
34-
cache: 'pip'
35-
cache-dependency-path: 'requirements/*.txt'
36-
- name: update pip
37-
run: |
38-
pip install -U wheel
39-
pip install -U setuptools
40-
python -m pip install -U pip
34+
allow-prereleases: true
35+
cache: pip
4136
- run: pip install tox
42-
- run: tox -e ${{ matrix.tox }}
37+
- run: tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }}

0 commit comments

Comments
 (0)