Skip to content

Commit 167f70d

Browse files
committed
Add testpypi build and release with uv
1 parent 0f28009 commit 167f70d

File tree

5 files changed

+119
-59
lines changed

5 files changed

+119
-59
lines changed

.github/workflows/build.yaml

Lines changed: 98 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,48 @@
11
name: Build and Release
22

3-
on:
4-
push:
5-
tags:
6-
- "v*"
3+
on: push
74

85
jobs:
96
build:
7+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/release' }}
108
strategy:
119
matrix:
12-
os: [macos-latest, ubuntu-latest, windows-latest]
10+
os: [windows-latest, ubuntu-latest, macos-latest]
1311

1412
runs-on: ${{ matrix.os }}
1513

1614
steps:
1715
- name: Check-out repository
1816
uses: actions/checkout@v4
1917

18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v3
20+
with:
21+
enable-cache: true
22+
2023
- name: Setup Python
2124
uses: actions/setup-python@v5
2225
with:
23-
python-version: "3.11"
26+
python-version-file: ".python-version"
2427
cache: "pip"
2528
cache-dependency-path: |
2629
**/requirements*.txt
2730
28-
- name: Install your Dependencies
31+
- name: Install the project
32+
run: uv sync --all-extras --dev && source .venv/bin/activate
33+
34+
- name: Build a binary wheel and a source tarball
35+
if: matrix.os == 'ubuntu-latest'
2936
run: |
30-
pip install -r requirements.txt
37+
uv build
38+
39+
- name: Store the distribution packages
40+
if: matrix.os == 'ubuntu-latest'
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: python-package-distributions
44+
path: dist/
45+
overwrite: true
3146

3247
- name: Build Executable with Nuitka
3348
uses: Nuitka/Nuitka-Action@main
@@ -60,40 +75,84 @@ jobs:
6075
build/*.bin
6176
build/*.app/**/*
6277
overwrite: true
78+
79+
publish-to-testpypi:
80+
name: Publish Python 🐍 distribution 📦 to TestPyPI
81+
needs:
82+
- build
83+
runs-on: ubuntu-latest
84+
85+
environment:
86+
name: testpypi
87+
url: https://test.pypi.org/p/ytm2spt
88+
89+
permissions:
90+
id-token: write # IMPORTANT: mandatory for trusted publishing
91+
92+
steps:
93+
- name: Download all the dists
94+
uses: actions/download-artifact@v4
95+
with:
96+
name: python-package-distributions
97+
path: dist/
98+
- name: Publish distribution 📦 to TestPyPI
99+
uses: pypa/gh-action-pypi-publish@release/v1
100+
with:
101+
repository-url: https://test.pypi.org/legacy/
63102

64103
release:
65-
if: startsWith(github.ref, 'refs/tags/')
66-
needs: build
104+
needs:
105+
- build
106+
- publish-to-testpypi
67107
runs-on: ubuntu-latest
108+
109+
permissions:
110+
contents: write # IMPORTANT: mandatory for making GitHub Releases
111+
id-token: write # IMPORTANT: mandatory for sigstore
112+
68113
steps:
69-
- name: Download All Artifacts
70-
uses: actions/download-artifact@v4
71-
- run: ls -R
114+
- name: Download all the dists
115+
uses: actions/download-artifact@v4
116+
with:
117+
name: python-package-distributions
118+
path: dist/
119+
- name: Sign the dists with Sigstore
120+
uses: sigstore/[email protected]
121+
with:
122+
inputs: >-
123+
./dist/*.tar.gz
124+
./dist/*.whl
125+
126+
- name: Download All Artifacts
127+
uses: actions/download-artifact@v4
128+
- run: ls -R
72129

73-
- name: Add Executable Permissions
74-
run: |
75-
chmod +x *build/*.bin *build/*.exe *build/*.app/Contents/MacOS/*
76-
77-
- name: Zip Windows Executable
78-
run: |
79-
cd *windows-build
80-
zip -9 ytm2spt-${{ github.ref_name }}-windows.zip *-installer.exe
81-
82-
- name: Tar Linux Executable
83-
run: |
84-
cd *linux-build
85-
tar -cavf ytm2spt-${{ github.ref_name }}-linux.tar.gz *.bin
86-
87-
- name: Zip MacOS Executable
88-
run: |
89-
cd *macos-build
90-
zip -r -9 ytm2spt-${{ github.ref_name }}-macos.zip *.app
130+
- name: Add Executable Permissions
131+
run: |
132+
chmod +x *build/*.bin *build/*.exe *build/*.app/Contents/MacOS/*
133+
134+
- name: Zip Windows Executable
135+
run: |
136+
cd *windows-build
137+
zip -9 ytm2spt-${{ github.ref_name }}-windows.zip *-installer.exe
138+
139+
- name: Zip Linux Executable
140+
run: |
141+
cd *linux-build
142+
tar -cavf ytm2spt-${{ github.ref_name }}-linux.tar.gz *.bin
143+
144+
- name: Zip MacOS Executable
145+
run: |
146+
cd *macos-build
147+
zip -r -9 ytm2spt-${{ github.ref_name }}-macos.zip *.app
91148
92-
- name: Release
93-
uses: softprops/action-gh-release@v2
94-
with:
95-
draft: true
96-
files: |
97-
*build/ytm2spt-${{ github.ref_name }}-windows.zip
98-
*build/ytm2spt-${{ github.ref_name }}-linux.tar.gz
99-
*build/ytm2spt-${{ github.ref_name }}-macos.zip
149+
- name: GitHub Release
150+
uses: softprops/action-gh-release@v2
151+
with:
152+
draft: true
153+
generate_release_notes: true
154+
files: |
155+
*build/ytm2spt-${{ github.ref_name }}-windows.zip
156+
*build/ytm2spt-${{ github.ref_name }}-linux.tar.gz
157+
*build/ytm2spt-${{ github.ref_name }}-macos.zip
158+
dist/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ ytmusicapi-oauth.json
1818
*.exe
1919
venv
2020
dist
21+
build

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ytm2spt"
3-
version = "1.0.2"
3+
version = "1.0.3-rc1"
44
authors = [
55
{ name="Abhishek M J", email="[email protected]" },
66
]

src/ytm2spt/__init__.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
# Nuitka Configuration
2-
# nuitka-project: --enable-plugins=pyside6
3-
# nuitka-project: --user-package-configuration-file=ytmusicapi.nuitka-package.config.yaml
4-
#
5-
# Compilation mode, standalone everywhere, except on macOS there app bundle
6-
# nuitka-project-if: {OS} in ("Linux", "FreeBSD"):
7-
# nuitka-project: --onefile
8-
# nuitka-project-if: {OS} == "Windows":
9-
# nuitka-project: --standalone
10-
# nuitka-project-if: {OS} == "Darwin":
11-
# nuitka-project: --standalone
12-
# nuitka-project: --macos-create-app-bundle
13-
#
14-
# Debugging options, controlled via environment variable at compile time.
15-
# nuitka-project-if: os.getenv("DEBUG_COMPILATION", "yes") == "yes":
16-
# nuitka-project: --enable-console
17-
# nuitka-project-else:
18-
# nuitka-project: --disable-console
19-
201
import sys
212

223

ytm2spt.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# Nuitka Configuration
2+
# nuitka-project: --enable-plugins=pyside6
3+
# nuitka-project: --user-package-configuration-file=ytmusicapi.nuitka-package.config.yaml
4+
#
5+
# Compilation mode, standalone everywhere, except on macOS there app bundle
6+
# nuitka-project-if: {OS} in ("Linux", "FreeBSD"):
7+
# nuitka-project: --onefile
8+
# nuitka-project-if: {OS} == "Windows":
9+
# nuitka-project: --standalone
10+
# nuitka-project-if: {OS} == "Darwin":
11+
# nuitka-project: --standalone
12+
# nuitka-project: --macos-create-app-bundle
13+
#
14+
# Debugging options, controlled via environment variable at compile time.
15+
# nuitka-project-if: os.getenv("DEBUG_COMPILATION", "yes") == "yes":
16+
# nuitka-project: --enable-console
17+
# nuitka-project-else:
18+
# nuitka-project: --disable-console
19+
120
from src.ytm2spt import main
221

322
main()

0 commit comments

Comments
 (0)