|
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 | + if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/release' }} |
10 | 8 | strategy:
|
11 | 9 | matrix:
|
12 |
| - os: [macos-latest, ubuntu-latest, windows-latest] |
| 10 | + os: [windows-latest, ubuntu-latest, macos-latest] |
13 | 11 |
|
14 | 12 | runs-on: ${{ matrix.os }}
|
15 | 13 |
|
16 | 14 | steps:
|
17 | 15 | - name: Check-out repository
|
18 | 16 | uses: actions/checkout@v4
|
19 | 17 |
|
| 18 | + - name: Install uv |
| 19 | + uses: astral-sh/setup-uv@v3 |
| 20 | + with: |
| 21 | + enable-cache: true |
| 22 | + |
20 | 23 | - name: Setup Python
|
21 | 24 | uses: actions/setup-python@v5
|
22 | 25 | with:
|
23 |
| - python-version: "3.11" |
| 26 | + python-version-file: ".python-version" |
24 | 27 | cache: "pip"
|
25 | 28 | cache-dependency-path: |
|
26 | 29 | **/requirements*.txt
|
27 | 30 |
|
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' |
29 | 36 | 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 |
31 | 46 |
|
32 | 47 | - name: Build Executable with Nuitka
|
33 | 48 | uses: Nuitka/Nuitka-Action@main
|
@@ -60,40 +75,84 @@ jobs:
|
60 | 75 | build/*.bin
|
61 | 76 | build/*.app/**/*
|
62 | 77 | 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/ |
63 | 102 |
|
64 | 103 | release:
|
65 |
| - if: startsWith(github.ref, 'refs/tags/') |
66 |
| - needs: build |
| 104 | + needs: |
| 105 | + - build |
| 106 | + - publish-to-testpypi |
67 | 107 | 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 | + |
68 | 113 | 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 | + |
| 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 |
72 | 129 |
|
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 |
91 | 148 |
|
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/* |
0 commit comments