|
1 | | -name: Publish to PyPI and GitHub release |
| 1 | +name: Publish |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - 'v*' |
| 4 | + release: |
| 5 | + types: [created] |
7 | 6 | workflow_dispatch: |
8 | | - inputs: |
9 | | - ref: |
10 | | - description: 'Git ref (branch, tag, or SHA) to build from' |
11 | | - required: true |
12 | | - default: 'master' # ← was 'main' |
13 | | - type: string |
14 | | - |
15 | | -# Least-privilege defaults for all jobs (override per-job if needed) |
16 | | -permissions: |
17 | | - contents: write # to create releases and read code |
18 | | - packages: write # to push container images to ghcr.io |
19 | | - id-token: write # for PyPI OIDC publish |
20 | 7 |
|
21 | 8 | jobs: |
22 | | - python-package: |
| 9 | + build-python-package: |
23 | 10 | runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: read |
24 | 13 |
|
25 | 14 | steps: |
26 | | - - name: Select ref |
27 | | - id: select-ref |
28 | | - run: | |
29 | | - if [ -n "${{ github.event.inputs.ref }}" ]; then |
30 | | - echo "ref=${{ github.event.inputs.ref }}" >> $GITHUB_OUTPUT |
31 | | - else |
32 | | - # Fallback to the event ref (e.g. refs/tags/v1.2.3 on tag pushes) |
33 | | - echo "ref=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT |
34 | | - fi |
35 | | -
|
36 | | - - uses: actions/checkout@v4 |
37 | | - with: |
38 | | - # Checkout the chosen ref for manual runs; for tag-push runs this will be that tag |
39 | | - ref: ${{ steps.select-ref.outputs.ref }} |
40 | | - |
41 | | - - name: Derive version |
42 | | - id: version |
43 | | - shell: bash |
44 | | - run: | |
45 | | - # If the ref looks like a release tag (v*), use it as version (strip refs/tags/ if present) |
46 | | - REF="${{ steps.select-ref.outputs.ref }}" |
47 | | - if [[ "$GITHUB_REF" == refs/tags/v* ]]; then |
48 | | - VER="${GITHUB_REF#refs/tags/}" |
49 | | - elif [[ "$REF" == refs/tags/v* ]]; then |
50 | | - VER="${REF#refs/tags/}" |
51 | | - elif [[ "$REF" == v* ]]; then |
52 | | - VER="$REF" |
53 | | - else |
54 | | - # Fallback for non-tag manual runs |
55 | | - VER="manual-${{ github.run_number }}" |
56 | | - fi |
57 | | - echo "version=$VER" >> $GITHUB_OUTPUT |
58 | | - echo "Resolved version: $VER" |
59 | | -
|
60 | | - - name: Set up Python |
61 | | - uses: actions/setup-python@v5 |
62 | | - with: |
63 | | - python-version: '3.11' |
64 | | - |
65 | | - - name: Install dependencies |
66 | | - run: | |
67 | | - python -m pip install --upgrade pip |
68 | | - pip install build flake8 |
69 | | -
|
70 | | - - name: Check for syntax errors |
71 | | - run: | |
72 | | - flake8 ./deeplc --count --select=E9,F63,F7,F82 --show-source --statistics |
| 15 | + - uses: actions/checkout@v6 |
73 | 16 |
|
74 | | - - name: Build package |
75 | | - run: | |
76 | | - python -m build . --sdist --wheel |
| 17 | + - uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version-file: "pyproject.toml" |
77 | 20 |
|
78 | | - - name: Publish to PyPI |
79 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
80 | | - with: |
81 | | - skip-existing: true |
| 21 | + - uses: astral-sh/setup-uv@v7 |
| 22 | + with: |
| 23 | + enable-cache: true |
82 | 24 |
|
83 | | - - name: Upload compiled wheels |
84 | | - uses: actions/upload-artifact@v4 |
85 | | - with: |
86 | | - name: python-wheels |
87 | | - path: dist/*.whl |
| 25 | + - name: Build |
| 26 | + run: uv build --no-sources |
88 | 27 |
|
89 | | - windows-installer: |
90 | | - runs-on: windows-latest |
91 | | - needs: python-package |
92 | | - steps: |
93 | | - - uses: actions/checkout@v4 |
94 | | - with: |
95 | | - # Match the same ref used for building the Python package |
96 | | - ref: ${{ needs.python-package.outputs.ref || github.ref }} |
97 | | - # If you want to avoid recomputing the ref/version here, you can |
98 | | - # alternatively repeat the "Select ref" + "Derive version" steps as above |
99 | | - - uses: actions/setup-python@v5 |
100 | | - with: |
101 | | - python-version: '3.11' |
102 | | - - name: Install dependencies |
103 | | - run: | |
104 | | - python -m pip install --upgrade pip |
105 | | - pip install .[gui] pyinstaller |
106 | | - - name: Install Inno Setup |
107 | | - uses: crazy-max/ghaction-chocolatey@v3 |
108 | | - with: |
109 | | - args: install innosetup -y --allow-unofficial --force |
110 | | - - name: Run pyinstaller |
111 | | - run: pyinstaller ./deeplc_pyinstaller.spec --clean --noconfirm |
112 | | - - name: Test built DeepLC exe |
113 | | - run: dist/deeplc/deeplc.exe --ignore-gooey --help |
114 | | - - name: Derive version (Windows) |
115 | | - id: version |
116 | | - shell: bash |
117 | | - run: | |
118 | | - REF="${{ github.event.inputs.ref }}" |
119 | | - if [[ "$GITHUB_REF" == refs/tags/v* ]]; then |
120 | | - VER="${GITHUB_REF#refs/tags/}" |
121 | | - elif [[ "$REF" == refs/tags/v* ]]; then |
122 | | - VER="${REF#refs/tags/}" |
123 | | - elif [[ "$REF" == v* ]]; then |
124 | | - VER="$REF" |
125 | | - else |
126 | | - VER="manual-${{ github.run_number }}" |
127 | | - fi |
128 | | - echo "version=$VER" >> $GITHUB_OUTPUT |
129 | | - echo "Resolved version: $VER" |
130 | | - - name: Run Inno Setup |
131 | | - run: ISCC.exe ./deeplc_innosetup.iss /DAppVersion=${{ steps.version.outputs.version }} |
132 | | - - name: Upload installer |
133 | | - uses: actions/upload-artifact@v4 |
134 | | - with: |
135 | | - name: windows-installer |
136 | | - path: dist/*.exe |
| 28 | + - name: Upload dists |
| 29 | + uses: actions/upload-artifact@v7 |
| 30 | + with: |
| 31 | + name: python-package-distributions |
| 32 | + path: dist/ |
| 33 | + if-no-files-found: error |
137 | 34 |
|
138 | | - git-release: |
| 35 | + publish-python-package: |
| 36 | + needs: build-python-package |
139 | 37 | runs-on: ubuntu-latest |
140 | | - needs: [python-package, windows-installer] |
141 | | - # Only create a GitHub Release when the ref is a v* tag (either push or manual) |
142 | | - if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.event.inputs.ref, 'v') |
143 | | - steps: |
144 | | - - uses: actions/checkout@v4 |
145 | | - |
146 | | - - name: Resolve version/tag |
147 | | - id: version |
148 | | - shell: bash |
149 | | - run: | |
150 | | - if [[ "$GITHUB_REF" == refs/tags/v* ]]; then |
151 | | - VER="${GITHUB_REF#refs/tags/}" |
152 | | - elif [[ "${{ github.event.inputs.ref }}" == v* ]]; then |
153 | | - VER="${{ github.event.inputs.ref }}" |
154 | | - else |
155 | | - echo "This job should only run for v* tags." |
156 | | - exit 1 |
157 | | - fi |
158 | | - echo "version=$VER" >> $GITHUB_OUTPUT |
159 | | - echo "Resolved version: $VER" |
| 38 | + permissions: |
| 39 | + id-token: write |
160 | 40 |
|
161 | | - - name: Download artifacts |
162 | | - uses: actions/download-artifact@v4 |
163 | | - with: |
164 | | - path: dist |
165 | | - |
166 | | - - name: Create GitHub Release |
167 | | - # The docker action infers the tag from GITHUB_REF; set it explicitly for manual runs. |
168 | | - uses: docker://antonyurchenko/git-release:v6 |
169 | | - env: |
170 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
171 | | - DRAFT_RELEASE: "false" |
172 | | - PRE_RELEASE: "false" |
173 | | - CHANGELOG_FILE: "CHANGELOG.md" |
174 | | - # Provide a synthetic tag ref for manual runs with input v* |
175 | | - GITHUB_REF: refs/tags/${{ steps.version.outputs.version }} |
176 | | - with: |
177 | | - args: | |
178 | | - dist/**/*.exe |
179 | | - dist/**/*.whl |
180 | | -
|
181 | | - build-streamlit-image: |
182 | | - runs-on: ubuntu-latest |
183 | | - needs: python-package |
184 | 41 | steps: |
185 | | - - uses: actions/checkout@v4 |
186 | | - - id: latest_release |
187 | | - uses: pozetroninc/github-action-get-latest-release@master |
188 | | - with: |
189 | | - owner: compomics |
190 | | - repo: DeepLC |
191 | | - - name: Login to GitHub Container Registry |
192 | | - uses: docker/login-action@v3 |
193 | | - with: |
194 | | - registry: ghcr.io |
195 | | - username: ${{ github.repository_owner }} |
196 | | - password: ${{ secrets.GITHUB_TOKEN }} |
197 | | - - name: Build and push to ghcr.io |
198 | | - uses: docker/build-push-action@v5 |
199 | | - with: |
200 | | - context: streamlit |
201 | | - push: true |
202 | | - tags: | |
203 | | - ghcr.io/compomics/deeplc-streamlit:${{ steps.latest_release.outputs.release }} |
204 | | - ghcr.io/compomics/deeplc-streamlit:latest |
| 42 | + - name: Download dists |
| 43 | + uses: actions/download-artifact@v8 |
| 44 | + with: |
| 45 | + name: python-package-distributions |
| 46 | + path: dist/ |
| 47 | + |
| 48 | + - name: Publish to PyPI |
| 49 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 50 | + |
| 51 | + # windows-installer: |
| 52 | + # runs-on: windows-latest |
| 53 | + # needs: python-package |
| 54 | + # steps: |
| 55 | + # - uses: actions/checkout@v6 |
| 56 | + # - uses: actions/setup-python@v5 |
| 57 | + # with: |
| 58 | + # python-version: '3.11' |
| 59 | + # - name: Install dependencies |
| 60 | + # run: | |
| 61 | + # python -m pip install --upgrade pip |
| 62 | + # pip install .[gui] pyinstaller |
| 63 | + # - name: Install Inno Setup |
| 64 | + # uses: crazy-max/ghaction-chocolatey@v3 |
| 65 | + # with: |
| 66 | + # args: install innosetup -y --allow-unofficial --force |
| 67 | + # - name: Run pyinstaller |
| 68 | + # run: pyinstaller ./deeplc_pyinstaller.spec --clean --noconfirm |
| 69 | + # - name: Test built DeepLC exe |
| 70 | + # run: dist/deeplc/deeplc.exe --ignore-gooey --help |
| 71 | + # - name: Run Inno Setup |
| 72 | + # run: ISCC.exe ./deeplc_innosetup.iss /DAppVersion=${{ github.ref_name }} |
| 73 | + # - name: Upload installer |
| 74 | + # uses: actions/upload-artifact@v4 |
| 75 | + # with: |
| 76 | + # name: windows-installer |
| 77 | + # path: dist/*.exe |
| 78 | + # - name: Upload installer to release |
| 79 | + # uses: svenstaro/upload-release-action@v2 |
| 80 | + # with: |
| 81 | + # repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + # tag: ${{ github.ref }} |
| 83 | + # file_glob: true |
| 84 | + # file: dist/*.exe |
| 85 | + |
| 86 | + # build-streamlit-image: |
| 87 | + # runs-on: ubuntu-latest |
| 88 | + # needs: publish-python-package |
| 89 | + |
| 90 | + # steps: |
| 91 | + # - uses: actions/checkout@v6 |
| 92 | + |
| 93 | + # - name: Login to GitHub Container Registry |
| 94 | + # uses: docker/login-action@v3 |
| 95 | + # with: |
| 96 | + # registry: ghcr.io |
| 97 | + # username: ${{ github.repository_owner }} |
| 98 | + # password: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + |
| 100 | + # - name: Build and push to ghcr.io |
| 101 | + # uses: docker/build-push-action@v5 |
| 102 | + # with: |
| 103 | + # context: streamlit |
| 104 | + # push: true |
| 105 | + # tags: | |
| 106 | + # ghcr.io/compomics/deeplc-streamlit:${{ github.ref }} |
| 107 | + # ghcr.io/compomics/deeplc-streamlit:latest |
0 commit comments