1- name : release-please
1+ name : release
22on :
33 push :
44 branches :
55 - master
66
77jobs :
8- release-please :
8+ release :
99 runs-on : ubuntu-latest
1010 permissions :
1111 contents : write
1212 pull-requests : write
1313 outputs :
1414 release_created : ${{ steps.release.outputs.release_created }}
15+ tag_name : ${{ steps.release.outputs.tag_name }}
1516
1617 steps :
1718 - name : Release Please
2122 release-type : python
2223
2324 publish :
24- needs : release-please
25- if : ${{ needs.release-please .outputs.release_created }}
25+ needs : release
26+ if : ${{ needs.release.outputs.release_created }}
2627 runs-on : ubuntu-latest
2728 permissions :
2829 contents : read
3839 - name : Use Python
3940 uses : actions/setup-python@v5
4041 with :
41- cache : pip
4242 python-version : 3
4343
4444 - name : Install build
@@ -48,11 +48,13 @@ jobs:
4848 run : python -m build
4949
5050 - name : Publish package to PyPI
51- uses : pypa/gh-action-pypi-publish@v1
51+ uses : pypa/gh-action-pypi-publish@release/v1
52+ with :
53+ password : ${{ secrets.PYPI_API_TOKEN }}
5254
5355 upload :
54- needs : release-please
55- if : ${{ needs.release-please .outputs.release_created }}
56+ needs : release
57+ if : ${{ needs.release.outputs.release_created }}
5658 runs-on : ${{ matrix.os }}
5759 strategy :
5860 matrix :
@@ -67,22 +69,34 @@ jobs:
6769 - name : Use Python
6870 uses : actions/setup-python@v5
6971 with :
70- cache : pip
7172 python-version : 3
7273
7374 - name : Install dependencies
74- run : pip install pyinstaller
75+ run : pip install -e '.[build]'
76+
77+ - name : Build executable
78+ run : pyinstaller src/python_cli_template/cli.py --name python_cli_template --onefile --clean
79+
80+ - name : Compress executable
81+ if : matrix.os != 'windows-latest'
82+ working-directory : dist
83+ run : zip archive.zip python_cli_template
7584
76- - name : Build binary
77- run : pyinstaller src/python_cli_template/cli.py --name python_cli_template
85+ - name : Compress executable
86+ if : matrix.os == 'windows-latest'
87+ working-directory : dist
88+ run : Compress-Archive -Path python_cli_template.exe -Destination archive.zip
7889
7990 - name : Upload Release Artifact
8091 shell : bash
92+ working-directory : dist
8193 run : |
82- cd dist
8394 os=${{ matrix.os }}
8495 filename=${os%-*}.zip
85- zip -r $filename python_cli_template
96+ if [[ $filename == 'ubuntu'* ]]; then
97+ filename=linux.zip
98+ fi
99+ mv archive.zip $filename
86100 gh release upload ${{ needs.release.outputs.tag_name }} $filename
87101 env :
88102 GH_TOKEN : ${{ github.token }}
0 commit comments