This repository was archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
194 lines (186 loc) · 7.88 KB
/
ci.yml
File metadata and controls
194 lines (186 loc) · 7.88 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Lint Vanilla Installer and build a dev build
on: [push, pull_request]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint with flake8
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04", "macos-12", "windows-2022"]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Load cached venv
id: cached-poetry-dependencies
# https://github.com/snok/install-poetry#caching-on-windows-runners
if: ${{ runner.os != 'Windows' }}
uses: actions/cache@v3
with:
path: .venv
key: ci-lint-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: pipx run poetry install --no-interaction --no-root --only ci
- name: Lint with flake8
run: |
source .venv/bin/activate || source .venv/Scripts/activate
# stop the build if there are Python syntax errors or undefined names
flake8 ./vanilla_installer/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ./vanilla_installer/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --ignore=E501,E722,E266
build-python:
name: Build Python wheels
runs-on: ubuntu-22.04
needs: lint
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: ci-build-python-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: pipx run poetry install --no-interaction --no-root
- name: Shorten commit SHA
uses: benjlevesque/short-sha@v2.2
id: short-sha
- name: Build
run: |
source .venv/bin/activate
pip install pyside6
pyside6-rcc vanilla_installer/assets/fonts.qrc -o vanilla_installer/fonts.py
pipx run poetry build --no-interaction
- name: Get normalized branch name
run: |
RAW_BRANCH=${{ github.ref_name || github.head_ref }}
BRANCH=${RAW_BRANCH//\//-}
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Upload built wheels
uses: actions/upload-artifact@v3
with:
name: Vanilla Installer ${{ env.BRANCH }}+${{ steps.short-sha.outputs.sha }} (Python sdist + whl)
path: "dist/*"
build-windows:
name: Build Windows exe
runs-on: windows-2022
needs: [lint, build-python]
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
id: setup-python
with:
python-version: "3.11"
- name: Shorten commit SHA
uses: benjlevesque/short-sha@v2.2
id: short-sha
- name: Cache
uses: actions/cache@v3
with:
path: ~/AppData/Local/Nuitka
key: ci-build-source-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
- name: Cache venv
uses: actions/cache@v3
with:
path: .venv
key: ci-build-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
- name: Get normalized branch name
shell: bash
run: |
RAW_BRANCH=${{ github.ref_name || github.head_ref }}
BRANCH=${RAW_BRANCH//\//-}
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Checkout Nuitka
uses: actions/checkout@v3
with:
repository: Nuitka/Nuitka
path: Nuitka
fetch-depth: '0'
- name: Checkout Nuitka on latest tag and install
working-directory: ./Nuitka
run: |
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
python3 -m pip install -e .
- name: Install other dependencies and build
run: |
# required to use `python3` here as otherwise the venv is created with python 3.9
python3 -m pip install pipx
python3 -m pipx run poetry install --no-interaction --with compile -E gui
./.venv/Scripts/activate.ps1
# pip install minecraft_launcher_lib PySide6 click tomli darkdetect
echo '__version__ = "${{ env.BRANCH }}+${{ steps.short-sha.outputs.sha }}"' | Out-File vanilla_installer/__init__.py
pyside6-rcc vanilla_installer/assets/fonts.qrc -o vanilla_installer/fonts.py
python -m nuitka --standalone --onefile --windows-icon-from-ico=media/icon.ico --output-dir=build --include-package=minecraft_launcher_lib,PySide6,click,tomli,darkdetect -o "Vanilla Installer-GUI ${{ env.BRANCH }}+${{ steps.short-sha.outputs.sha }}.exe" --enable-plugin=pyside6 --include-data-dir=vanilla_installer/assets=assets/ --disable-console --nofollow-import-to=PySide6.examples vanilla_installer/gui.py --assume-yes-for-downloads
- name: Upload built executable
uses: actions/upload-artifact@v3
with:
name: Vanilla Installer ${{ env.BRANCH }}+${{ steps.short-sha.outputs.sha }} (Windows)
path: "build/*.exe"
build-windows-cli:
name: Build CLI for Windows
runs-on: windows-2022
needs: [lint, build-python]
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Shorten commit SHA
uses: benjlevesque/short-sha@v2.2
id: short-sha
- name: Cache
uses: actions/cache@v3
with:
path: ~/AppData/Local/Nuitka
key: ci-build-source-cli-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
- name: Cache venv
uses: actions/cache@v3
with:
path: .venv
key: ci-build-venv-cli-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
- name: Get normalized branch name
shell: bash
run: |
RAW_BRANCH=${{ github.ref_name || github.head_ref }}
BRANCH=${RAW_BRANCH//\//-}
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Install dependencies and build
run: |
# required to use `python3` here as otherwise the venv is created with python 3.9
python3 -m pip install pipx
python3 -m pipx run poetry install --no-interaction --with compile
./.venv/Scripts/activate.ps1
# pip install nuitka minecraft_launcher_lib click tomli darkdetect asyncclick
echo '__version__ = "${{ env.BRANCH }}+${{ steps.short-sha.outputs.sha }}"' | Out-File vanilla_installer/__init__.py
python -m nuitka --standalone --onefile --windows-icon-from-ico=media/icon.ico --output-dir=build --include-package=minecraft_launcher_lib,asyncclick,click,tomli -o "vanilla-installer.exe" --enable-console --include-data-dir=vanilla_installer/assets=assets/ vanilla_installer/cli.py --assume-yes-for-downloads
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: Vanilla Installer ${{ env.BRANCH }}+${{ steps.short-sha.outputs.sha }} (Windows CLI)
path: build/*.exe