Skip to content

Commit 8632d5c

Browse files
authored
Merge pull request #52 from azmeuk/flask-gha
GHA workflows inspired from Flask
2 parents 3d0216c + ae4630a commit 8632d5c

File tree

3 files changed

+111
-51
lines changed

3 files changed

+111
-51
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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
- run: pip install build
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@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
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/[email protected]
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@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
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:
60+
name: publish
61+
url: https://pypi.org/project/wtforms-sqlalchemy/${{ github.ref_name }}
62+
runs-on: ubuntu-latest
63+
permissions:
64+
id-token: write
65+
steps:
66+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
67+
- uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
68+
with:
69+
repository-url: https://test.pypi.org/legacy/
70+
packages-dir: artifact/
71+
- uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
72+
with:
73+
packages-dir: artifact/

.github/workflows/tests.yaml

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,37 @@
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+
- {python: '3.11'}
27+
- {python: '3.10'}
28+
- {python: '3.9'}
2629
steps:
27-
- uses: actions/checkout@v2
28-
- uses: actions/setup-python@v2
30+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
31+
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
2932
with:
3033
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.12'
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.12'
61-
- uses: actions/cache@v1
62-
with:
63-
path: ~/.cache/pip
64-
key: pip|${{ hashFiles('setup.py') }}|${{ hashFiles('tox.ini') }}
34+
allow-prereleases: true
35+
cache: pip
6536
- run: pip install tox
66-
- run: tox -e docs
37+
- run: tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }}

0 commit comments

Comments
 (0)