Skip to content

Commit 95654f6

Browse files
authored
Update GitHub actions (#7)
1 parent fd73887 commit 95654f6

File tree

2 files changed

+93
-2
lines changed

2 files changed

+93
-2
lines changed

.github/workflows/checks.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,37 @@ on: pull_request
55
jobs:
66
checks:
77
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ['3.10', '3.11']
811
steps:
912
#----------------------------------------------
1013
# check-out repo and set-up python
1114
#----------------------------------------------
1215
- name: Check out repository
1316
uses: actions/checkout@v3
14-
- name: Set up python
17+
- name: Set up Python ${{ matrix.python-version }}
1518
id: setup-python
1619
uses: actions/setup-python@v4
1720
with:
18-
python-version: '3.10'
21+
python-version: ${{ matrix.python-version }}
22+
#-----------------------------------------------
23+
# try to load cached poetry installation
24+
#-----------------------------------------------
25+
- name: Load cached Poetry installation
26+
id: cached-poetry
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.local # the path depends on the OS
30+
key: poetry-1.4.0-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
1931
#----------------------------------------------
2032
# ----- install & configure poetry -----
2133
#----------------------------------------------
2234
- name: Install Poetry
35+
if: steps.cached-poetry.outputs.cache-hit != 'true'
2336
uses: snok/install-poetry@v1
2437
with:
38+
version: 1.4.0
2539
virtualenvs-create: true
2640
virtualenvs-in-project: true
2741
installer-parallel: true

.github/workflows/python-publish.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build and publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ['3.10', '3.11']
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v2
19+
- name: Set up Python ${{ matrix.python-version }}
20+
id: setup-python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Load cached Poetry installation
25+
id: cached-poetry
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/.local # the path depends on the OS
29+
key: poetry-1.4.0-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
30+
- name: Install Poetry
31+
if: steps.cached-poetry.outputs.cache-hit != 'true'
32+
uses: snok/install-poetry@v1
33+
with:
34+
version: 1.4.0
35+
virtualenvs-create: true
36+
virtualenvs-in-project: true
37+
installer-parallel: true
38+
- name: Load cached venv
39+
id: cached-poetry-dependencies
40+
uses: actions/cache@v3
41+
with:
42+
path: .venv
43+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
44+
- name: Install dependencies
45+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
46+
run: poetry install --no-interaction --no-root
47+
- name: Build package
48+
run: poetry build
49+
- name: Upload artifacts
50+
uses: actions/upload-artifact@v2
51+
with:
52+
name: dist-${{ matrix.python-version }}
53+
path: dist
54+
55+
pypi-publish:
56+
name: Upload release to PyPI
57+
runs-on: ubuntu-latest
58+
environment:
59+
name: release
60+
url: https://pypi.org/project/chainbench
61+
permissions:
62+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
63+
steps:
64+
- name: Download artifacts
65+
uses: actions/download-artifact@v2
66+
with:
67+
name: dist-3.10
68+
path: dist
69+
70+
- name: Download artifacts
71+
uses: actions/download-artifact@v2
72+
with:
73+
name: dist-3.11
74+
path: dist
75+
76+
- name: Publish package distributions to PyPI
77+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)