Skip to content

Commit 500b9f6

Browse files
committed
chore: use Flask inspired GHA workflow
1 parent b0a58f9 commit 500b9f6

File tree

3 files changed

+112
-51
lines changed

3 files changed

+112
-51
lines changed

.github/workflows/pre-commit.yaml

+16
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

+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@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/

.github/workflows/tests.yaml

+24-51
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,39 @@
1-
---
2-
name: tests
1+
name: Tests
32
on:
43
push:
54
branches:
65
- main
76
- '*.x'
7+
paths-ignore:
8+
- 'docs/**'
9+
- '*.md'
10+
- '*.rst'
811
pull_request:
9-
branches:
10-
- main
11-
- '*.x'
12+
paths-ignore:
13+
- 'docs/**'
14+
- '*.md'
15+
- '*.rst'
1216
jobs:
1317
tests:
14-
name: ${{ matrix.python }}
15-
runs-on: ubuntu-latest
18+
name: ${{ matrix.name || matrix.python }}
19+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
1620
strategy:
1721
fail-fast: false
1822
matrix:
19-
python:
20-
- '3.13'
21-
- '3.12'
22-
- '3.11'
23-
- '3.10'
24-
- '3.9'
25-
- 'pypy-3.10'
23+
include:
24+
- {python: '3.13'}
25+
- {python: '3.12'}
26+
- {name: Windows, python: '3.12', os: windows-latest}
27+
- {name: Mac, python: '3.12', os: macos-latest}
28+
- {python: '3.11'}
29+
- {python: '3.10'}
30+
- {python: '3.9'}
2631
steps:
27-
- uses: actions/checkout@v2
28-
- uses: actions/setup-python@v2
32+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
33+
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
2934
with:
3035
python-version: ${{ matrix.python }}
31-
- uses: actions/cache@v1
32-
with:
33-
path: ~/.cache/pip
34-
key: pip|${{ hashFiles('setup.py') }}|${{ hashFiles('tox.ini') }}
35-
- run: pip install tox
36-
- run: tox -e py
37-
style:
38-
runs-on: ubuntu-latest
39-
steps:
40-
- uses: actions/checkout@v2
41-
- uses: actions/setup-python@v2
42-
with:
43-
python-version: '3.13'
44-
- uses: actions/cache@v1
45-
with:
46-
path: ~/.cache/pip
47-
key: pip|${{ hashFiles('setup.py') }}|${{ hashFiles('tox.ini') }}
48-
- uses: actions/cache@v1
49-
with:
50-
path: ~/.cache/pre-commit
51-
key: pre-commit|${{ hashFiles('.pre-commit-config.yaml') }}
52-
- run: pip install tox
53-
- run: tox -e style
54-
docs:
55-
runs-on: ubuntu-latest
56-
steps:
57-
- uses: actions/checkout@v2
58-
- uses: actions/setup-python@v2
59-
with:
60-
python-version: '3.13'
61-
- uses: actions/cache@v1
62-
with:
63-
path: ~/.cache/pip
64-
key: pip|${{ hashFiles('setup.py') }}|${{ hashFiles('tox.ini') }}
36+
allow-prereleases: true
37+
cache: pip
6538
- run: pip install tox
66-
- run: tox -e docs
39+
- run: tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }}

0 commit comments

Comments
 (0)