Skip to content

Commit 6d4bf36

Browse files
committed
ci: update latest ci and secure publish
1 parent 80852fc commit 6d4bf36

File tree

2 files changed

+94
-31
lines changed

2 files changed

+94
-31
lines changed

.github/workflows/tests.yml

Lines changed: 92 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1717
- name: Set up Python
18-
uses: actions/setup-python@v1
18+
uses: actions/setup-python@v5
1919
with:
20-
python-version: 3.7
21-
- uses: pre-commit/action@v2.0.0
20+
python-version: '3.x'
21+
- uses: pre-commit/action@v3.0.1
2222

2323
tests:
2424
runs-on: ${{ matrix.os }}
2525
strategy:
2626
matrix:
27-
python-version: [3.7, 3.8, 3.9, '3.10']
27+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
2828
os: [ubuntu-latest, windows-latest]
2929

3030
steps:
31-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v4
3232

3333
- name: Set up Python ${{ matrix.python-version }}
34-
uses: actions/setup-python@v2
34+
uses: actions/setup-python@v5
3535
with:
3636
python-version: ${{ matrix.python-version }}
3737

@@ -59,11 +59,11 @@ jobs:
5959
runs-on: ubuntu-latest
6060

6161
steps:
62-
- uses: actions/checkout@v2
62+
- uses: actions/checkout@v4
6363
- name: Set up Python
64-
uses: actions/setup-python@v2
64+
uses: actions/setup-python@v5
6565
with:
66-
python-version: 3.7
66+
python-version: "3.x"
6767

6868
- name: Installation (deps and package)
6969
run: |
@@ -74,24 +74,87 @@ jobs:
7474
run: |
7575
pre-commit run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure
7676
77-
publish:
78-
name: Publish to PyPi
79-
needs: [pre-commit, tests, pre-commit-hook]
80-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
77+
build:
78+
name: build
8179
runs-on: ubuntu-latest
8280
steps:
83-
- name: Checkout source
84-
uses: actions/checkout@v2
85-
- name: Set up Python 3.7
86-
uses: actions/setup-python@v1
87-
with:
88-
python-version: 3.7
89-
- name: install flit
90-
run: |
91-
pip install flit~=3.0
92-
- name: Build and publish
93-
run: |
94-
flit publish
95-
env:
96-
FLIT_USERNAME: __token__
97-
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}
81+
- uses: actions/checkout@v4
82+
- name: Set up Python
83+
uses: actions/setup-python@v5
84+
with:
85+
python-version: "3.x"
86+
- name: Upgrade Pip
87+
run: python -m pip install --upgrade pip
88+
- name: Install Poetry
89+
run: python -m pip install build
90+
- name: Build a binary wheel and a source tarball
91+
run: python3 -m build
92+
- name: Store the distribution packages
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: python-package-distributions
96+
path: dist/
97+
98+
publish-to-pypi:
99+
name: >-
100+
Publish Python 🐍 distribution 📦 to PyPI
101+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
102+
needs:
103+
- build
104+
runs-on: ubuntu-latest
105+
environment:
106+
name: pypi
107+
url: https://pypi.org/p/pelican-markdown-it-reader
108+
permissions:
109+
id-token: write
110+
steps:
111+
- name: Download all the dists
112+
uses: actions/download-artifact@v4
113+
with:
114+
name: python-package-distributions
115+
path: dist/
116+
- name: Publish distribution 📦 to PyPI
117+
uses: pypa/gh-action-pypi-publish@release/v1
118+
119+
github-release:
120+
name: >-
121+
Sign the Python 🐍 distribution 📦 with Sigstore
122+
and upload them to GitHub Release
123+
needs:
124+
- publish-to-pypi
125+
runs-on: ubuntu-latest
126+
127+
permissions:
128+
contents: write # IMPORTANT: mandatory for making GitHub Releases
129+
id-token: write # IMPORTANT: mandatory for sigstore
130+
131+
steps:
132+
- name: Download all the dists
133+
uses: actions/download-artifact@v4
134+
with:
135+
name: python-package-distributions
136+
path: dist/
137+
- name: Sign the dists with Sigstore
138+
uses: sigstore/[email protected]
139+
with:
140+
inputs: >-
141+
./dist/*.tar.gz
142+
./dist/*.whl
143+
- name: Create GitHub Release
144+
env:
145+
GITHUB_TOKEN: ${{ github.token }}
146+
run: >-
147+
gh release create
148+
'${{ github.ref_name }}'
149+
--repo '${{ github.repository }}'
150+
--notes ""
151+
- name: Upload artifact signatures to GitHub Release
152+
env:
153+
GITHUB_TOKEN: ${{ github.token }}
154+
# Upload to GitHub Release using the `gh` CLI.
155+
# `dist/` contains the built packages, and the
156+
# sigstore-produced signatures and certificates.
157+
run: >-
158+
gh release upload
159+
'${{ github.ref_name }}' dist/**
160+
--repo '${{ github.repository }}'

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ repos:
1818
rev: 20.8b1
1919
hooks:
2020
- id: black
21-
- repo: https://gitlab.com/pycqa/flake8
22-
rev: 3.9.0
21+
- repo: https://github.com/PyCQA/flake8
22+
rev: 7.10.0
2323
hooks:
2424
- id: flake8
2525
additional_dependencies:

0 commit comments

Comments
 (0)