Skip to content

Commit 8f9a390

Browse files
committed
Switching to Trusted Publishing and github actions for release
1 parent 4979598 commit 8f9a390

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

.github/workflows/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Python package
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.10", "3.11", "3.12"]
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install flake8 pytest
22+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
23+
if [ -f pyproject.toml ]; then pip install .; fi
24+
- name: Lint with flake8
25+
run: |
26+
# stop the build if there are Python syntax errors or undefined names
27+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
28+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
29+
flake8 . --count --exit-zero --max-complexity=16 --max-line-length=127 --statistics
30+
- name: Run tests
31+
run: |
32+
python memcache.py
33+
pytest

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
# See: https://github.com/pypa/gh-action-pypi-publish
4+
5+
# Triggered from github UI
6+
#on: ["workflow_dispatch"]
7+
on:
8+
release:
9+
types: [released]
10+
11+
jobs:
12+
build-and-publish:
13+
runs-on: ubuntu-latest
14+
environment: release
15+
permissions:
16+
# IMPORTANT: this permission is mandatory for trusted publishing
17+
id-token: write
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.x'
25+
- name: Extract version from tag
26+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
27+
- name: Update version in memcache.py
28+
run: |
29+
sed -ri 's/^(\s*__version__\s*=\s*).*$/\1"'"${RELEASE_VERSION}"'"/' memcache.py
30+
- name: Update version in PKG-INFO
31+
run: |
32+
sed -ri 's/^(\sVersion:\s*).*$/\1"'"${RELEASE_VERSION}"'"/' PKG-INFO
33+
- name: Build
34+
run: pipx run build .
35+
# This requires Trusted Publishing be set up at PyPi
36+
# Go to <Project> -> Manage -> Publishing and enter this repos info
37+
# Info: [Owner] / [Repo name] / release.yml / [BLANK]
38+
- name: Publish
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
with:
41+
skip-existing: true

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@
3636
"Programming Language :: Python :: 3.9",
3737
"Programming Language :: Python :: 3.10",
3838
"Programming Language :: Python :: 3.11",
39+
"Programming Language :: Python :: 3.12",
3940
],
4041
)

0 commit comments

Comments
 (0)