-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (87 loc) · 2.55 KB
/
release.yml
File metadata and controls
103 lines (87 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: release
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- name: Release Please
uses: googleapis/release-please-action@v4
id: release
with:
release-type: python
publish:
needs: release
if: ${{ needs.release.outputs.release_created }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
environment:
name: pypi
url: https://pypi.org/p/python_cli_template
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Use Python
uses: actions/setup-python@v6
with:
python-version: 3
- name: Install build
run: python -m pip install build
- name: Build package
run: python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
upload:
needs: release
if: ${{ needs.release.outputs.release_created }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Use Python
uses: actions/setup-python@v6
with:
python-version: 3
- name: Install dependencies
run: pip install -e '.[build]'
- name: Build executable
run: pyinstaller src/python_cli_template/cli.py --name python_cli_template --onefile --clean
- name: Compress executable
if: matrix.os != 'windows-latest'
working-directory: dist
run: zip archive.zip python_cli_template
- name: Compress executable
if: matrix.os == 'windows-latest'
working-directory: dist
run: Compress-Archive -Path python_cli_template.exe -Destination archive.zip
- name: Upload Release Artifact
shell: bash
working-directory: dist
run: |
os=${{ matrix.os }}
filename=${os%-*}.zip
if [[ $filename == 'ubuntu'* ]]; then
filename=linux.zip
fi
mv archive.zip $filename
gh release upload ${{ needs.release.outputs.tag_name }} $filename
env:
GH_TOKEN: ${{ github.token }}