|
1 | 1 | name: Build and Release
|
2 | 2 |
|
3 |
| -on: |
4 |
| - push: |
5 |
| - tags: |
6 |
| - - "v*" |
| 3 | +on: push |
7 | 4 |
|
8 | 5 | jobs:
|
9 | 6 | build:
|
| 7 | + name: >- |
| 8 | + Build and Package 📦 |
| 9 | + if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/release' }} |
10 | 10 | strategy:
|
11 | 11 | matrix:
|
12 |
| - os: [macos-latest, ubuntu-latest, windows-latest] |
| 12 | + os: [windows-latest, ubuntu-latest, macos-latest] |
13 | 13 |
|
14 | 14 | runs-on: ${{ matrix.os }}
|
15 | 15 |
|
16 | 16 | steps:
|
17 | 17 | - name: Check-out repository
|
18 | 18 | uses: actions/checkout@v4
|
19 | 19 |
|
| 20 | + - name: Install uv |
| 21 | + uses: astral-sh/setup-uv@v3 |
| 22 | + with: |
| 23 | + enable-cache: true |
| 24 | + |
20 | 25 | - name: Setup Python
|
21 | 26 | uses: actions/setup-python@v5
|
22 | 27 | with:
|
23 |
| - python-version: "3.11" |
| 28 | + python-version-file: ".python-version" |
24 | 29 | cache: "pip"
|
25 | 30 | cache-dependency-path: |
|
26 | 31 | **/requirements*.txt
|
27 | 32 |
|
28 |
| - - name: Install your Dependencies |
| 33 | + - name: Install the project |
| 34 | + run: pip install . |
| 35 | + |
| 36 | + - name: Build a binary wheel and a source tarball |
| 37 | + if: matrix.os == 'ubuntu-latest' |
29 | 38 | run: |
|
30 |
| - pip install -r requirements.txt |
| 39 | + uv build |
| 40 | + |
| 41 | + - name: Store the distribution packages |
| 42 | + if: matrix.os == 'ubuntu-latest' |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: python-package-distributions |
| 46 | + path: dist/ |
| 47 | + overwrite: true |
31 | 48 |
|
32 | 49 | - name: Build Executable with Nuitka
|
33 | 50 | uses: Nuitka/Nuitka-Action@main
|
@@ -60,40 +77,84 @@ jobs:
|
60 | 77 | build/*.bin
|
61 | 78 | build/*.app/**/*
|
62 | 79 | overwrite: true
|
63 |
| - |
| 80 | + |
| 81 | + publish-to-pypi: |
| 82 | + name: >- |
| 83 | + Publish Python 🐍 distribution 📦 to PyPI |
| 84 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 85 | + needs: |
| 86 | + - build |
| 87 | + runs-on: ubuntu-latest |
| 88 | + environment: |
| 89 | + name: pypi |
| 90 | + url: https://pypi.org/p/ytm2spt |
| 91 | + permissions: |
| 92 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 93 | + |
| 94 | + steps: |
| 95 | + - name: Download all the dists |
| 96 | + uses: actions/download-artifact@v4 |
| 97 | + with: |
| 98 | + name: python-package-distributions |
| 99 | + path: dist/ |
| 100 | + - name: Publish distribution 📦 to PyPI |
| 101 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 102 | + |
64 | 103 | release:
|
65 |
| - if: startsWith(github.ref, 'refs/tags/') |
66 |
| - needs: build |
| 104 | + name: >- |
| 105 | + Create a GitHub Release 🚀 |
| 106 | + needs: |
| 107 | + - build |
| 108 | + - publish-to-pypi |
67 | 109 | runs-on: ubuntu-latest
|
| 110 | + |
| 111 | + permissions: |
| 112 | + contents: write # IMPORTANT: mandatory for making GitHub Releases |
| 113 | + id-token: write # IMPORTANT: mandatory for sigstore |
| 114 | + |
68 | 115 | steps:
|
69 |
| - - name: Download All Artifacts |
70 |
| - uses: actions/download-artifact@v4 |
71 |
| - - run: ls -R |
| 116 | + - name: Download all the dists |
| 117 | + uses: actions/download-artifact@v4 |
| 118 | + with: |
| 119 | + name: python-package-distributions |
| 120 | + path: dist/ |
| 121 | + - name: Sign the dists with Sigstore |
| 122 | + |
| 123 | + with: |
| 124 | + inputs: >- |
| 125 | + ./dist/*.tar.gz |
| 126 | + ./dist/*.whl |
| 127 | + |
| 128 | + - name: Download All Artifacts |
| 129 | + uses: actions/download-artifact@v4 |
| 130 | + - run: ls -R |
72 | 131 |
|
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 |
| 132 | + - name: Add Executable Permissions |
| 133 | + run: | |
| 134 | + chmod +x *build/*.bin *build/*.exe *build/*.app/Contents/MacOS/* |
| 135 | + |
| 136 | + - name: Zip Windows Executable |
| 137 | + run: | |
| 138 | + cd *windows-build |
| 139 | + zip -9 ytm2spt-windows.zip *-installer.exe |
| 140 | + |
| 141 | + - name: Zip Linux Executable |
| 142 | + run: | |
| 143 | + cd *linux-build |
| 144 | + tar -cavf ytm2spt-linux.tar.gz *.bin |
| 145 | + |
| 146 | + - name: Zip MacOS Executable |
| 147 | + run: | |
| 148 | + cd *macos-build |
| 149 | + zip -r -9 ytm2spt-macos.zip *.app |
91 | 150 |
|
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 |
| 151 | + - name: GitHub Release |
| 152 | + uses: softprops/action-gh-release@v2 |
| 153 | + with: |
| 154 | + draft: true |
| 155 | + generate_release_notes: true |
| 156 | + files: | |
| 157 | + *build/ytm2spt-windows.zip |
| 158 | + *build/ytm2spt-linux.tar.gz |
| 159 | + *build/ytm2spt-macos.zip |
| 160 | + dist/* |
0 commit comments