Skip to content

Commit 4d236c9

Browse files
committed
Add Github Actions to release to testpypi on commit and to pypi and Github on new tag
1 parent 7d423f1 commit 4d236c9

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

.github/workflows/main.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- '*'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Ensures version gets set correctly
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.x"
25+
26+
- name: Install testing dependencies
27+
run: |
28+
sudo apt update
29+
sudo apt install -y suckless-tools xdotool
30+
31+
- name: Install Hatch
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install hatch hatchling hatch-vcs
35+
36+
- name: Build package
37+
run: hatch build
38+
39+
- name: Test package
40+
run: hatch run make test
41+
42+
- name: Store the distribution packages
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: keepmenu
46+
path: dist/
47+
48+
publish-to-pypi:
49+
name: Publish to PyPI
50+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
51+
needs:
52+
- build
53+
runs-on: ubuntu-latest
54+
environment:
55+
name: pypi
56+
url: https://pypi.org/p/keepmenu # Replace <package-name> with your PyPI project name
57+
permissions:
58+
id-token: write # IMPORTANT: mandatory for trusted publishing
59+
60+
steps:
61+
- name: Download all the dists
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: keepmenu
65+
path: dist/
66+
- name: Publish to PyPI
67+
uses: pypa/gh-action-pypi-publish@release/v1
68+
69+
github-release:
70+
name: >-
71+
Sign the with Sigstore and upload to GitHub Release
72+
needs:
73+
- publish-to-pypi
74+
runs-on: ubuntu-latest
75+
76+
permissions:
77+
contents: write # IMPORTANT: mandatory for making GitHub Releases
78+
id-token: write # IMPORTANT: mandatory for sigstore
79+
80+
steps:
81+
- name: Download all the dists
82+
uses: actions/download-artifact@v4
83+
with:
84+
name: keepmenu
85+
path: dist/
86+
- name: Sign the dists with Sigstore
87+
uses: sigstore/gh-action-sigstore-python@v3.0.0
88+
with:
89+
inputs: >-
90+
./dist/*.tar.gz
91+
./dist/*.whl
92+
- name: Create GitHub Release
93+
env:
94+
GITHUB_TOKEN: ${{ github.token }}
95+
run: >-
96+
gh release create
97+
'${{ github.ref_name }}'
98+
--repo '${{ github.repository }}'
99+
--notes ""
100+
- name: Upload artifact signatures to GitHub Release
101+
env:
102+
GITHUB_TOKEN: ${{ github.token }}
103+
# Upload to GitHub Release using the `gh` CLI.
104+
# `dist/` contains the built packages, and the
105+
# sigstore-produced signatures and certificates.
106+
run: >-
107+
gh release upload
108+
'${{ github.ref_name }}' dist/**
109+
--repo '${{ github.repository }}'
110+
111+
publish-to-testpypi:
112+
name: Publish to TestPyPI
113+
needs:
114+
- build
115+
runs-on: ubuntu-latest
116+
117+
environment:
118+
name: testpypi
119+
url: https://test.pypi.org/p/keepmenu
120+
121+
permissions:
122+
id-token: write # IMPORTANT: mandatory for trusted publishing
123+
124+
steps:
125+
- name: Download all the dists
126+
uses: actions/download-artifact@v4
127+
with:
128+
name: keepmenu
129+
path: dist/
130+
- name: Publish to TestPyPI
131+
uses: pypa/gh-action-pypi-publish@release/v1
132+
with:
133+
repository-url: https://test.pypi.org/legacy/

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ classifiers = [
3131
"Programming Language :: Python :: 3.10",
3232
"Programming Language :: Python :: 3.11",
3333
"Programming Language :: Python :: 3.12",
34+
"Programming Language :: Python :: 3.13",
3435
"Topic :: Utilities",
3536
]
3637
dependencies = [
@@ -48,6 +49,9 @@ Homepage = "https://github.com/firecat53/keepmenu"
4849
source = "vcs"
4950
fallback-version = "0.0.0"
5051

52+
[tool.hatch.version.raw-options]
53+
local_scheme = "no-local-version"
54+
5155
[tool.hatch.build.hooks.vcs]
5256
version-file = "keepmenu/_version.py"
5357

0 commit comments

Comments
 (0)