-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (153 loc) · 5.99 KB
/
build.yml
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
name: Build PyQt5 App
on:
push:
branches: [ deploy ]
env:
POETRY_VERSION: 1.6.1
PCKG_NAME: metaanalyser
VERSION: 0.1.7
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Ubuntu only until closer to production ready!
os: [ubuntu-latest]
python-version: [3.11.1]
steps:
- name: Checkout code
uses: actions/checkout@v3
# Setup Python environment
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# Install system libraries for Linux
- name: Install Linux system libraries
if: runner.os == 'Linux'
run: |
sudo apt-get update && sudo apt-get install -y \
xvfb x11-utils libxkbcommon-x11-0
# Install Poetry
- name: Install Poetry on Linux
if: runner.os == 'Linux'
run: |
curl -sSL https://install.python-poetry.org | python3 - \
--version ${{ env.POETRY_VERSION }}
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Poetry on macOS
if: runner.os == 'macOS'
run: |
curl -sSL https://install.python-poetry.org | python3 - \
--version ${{ env.POETRY_VERSION }}
echo "$HOME/Library/Application Support/pypoetry/venv/bin" >> $GITHUB_PATH
- name: Install Poetry on Windows
if: runner.os == 'Windows'
run: |
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python3 - --version ${{ env.POETRY_VERSION }}
echo "$env:APPDATA\Python\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Append
# Install dependencies
- name: Install dependencies
run: |
poetry install
# Install Chrome for Playwright (Mac/Linux)
- name: Install Chrome for Playwright (Mac/Linux)
if: runner.os != 'Windows'
run: |
export PLAYWRIGHT_BROWSERS_PATH=0
poetry run playwright install chromium
- name: Install Chrome for Playwright (Windows)
if: runner.os == 'Windows'
run: |
$env:PLAYWRIGHT_BROWSERS_PATH="0"
poetry run playwright install chromium
- name: Download NLTK data
run: |
poetry run python -c "import nltk; nltk.download('punkt', download_dir='./nltk_data')"
- name: Build with PyInstaller (Mac/Linux)
if: runner.os != 'Windows'
run: |
poetry run pyinstaller --onedir --noconsole \
--add-data "./nltk_data:./nltk_data" \
--name ${{ env.PCKG_NAME }}_${{ env.VERSION }} app/main.py
# Build PyQt5 app binary with PyInstaller
- name: Build with PyInstaller (Windows)
if: runner.os == 'Windows'
run: |
poetry run pyinstaller --onedir --noconsole --add-data ".\nltk_data;.\nltk_data" --name ${{ env.PCKG_NAME }}_${{ env.VERSION }} app/main.py
# Package the binary
- name: Package Binary on Mac/Linux
if: runner.os != 'Windows'
run: |
tar czvf \
${{ env.PCKG_NAME }}_${{ env.VERSION }}_${{ runner.os }}.tar.gz \
-C dist ${{ env.PCKG_NAME }}_${{ env.VERSION }}
- name: Package Binary on Windows
if: runner.os == 'Windows'
run: |
Compress-Archive -Path .\dist\${{ env.PCKG_NAME }}_${{ env.VERSION }}\* -DestinationPath .\${{ env.PCKG_NAME }}_${{ env.VERSION }}_windows.zip
# Upload the packaged binary as an artifact for Mac/Linux
- name: Upload Mac/Linux Binary as Artifact
if: runner.os != 'Windows'
uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-binary
path: '*.tar.gz'
# Upload the packaged binary as an artifact for Windows
- name: Upload Windows Binary as Artifact
if: runner.os == 'Windows'
uses: actions/upload-artifact@v2
with:
name: windows-binary
path: '*.zip'
release:
needs: build
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download all compiled artifacts
uses: actions/download-artifact@v2
with:
path: ./artifacts
- name: Create Public Release
run: |
RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-d '{
"tag_name": "v${{ env.VERSION }}",
"target_commitish": "main",
"name": "Release v${{ env.VERSION }}",
"body": "First public release!",
"draft": true,
"prerelease": true
}' \
https://api.github.com/repos/jordantgh/meta-analyser-rc/releases)
echo "Full API Response: $RESPONSE"
UPLOAD_URL=$(echo "$RESPONSE" | jq -r '.upload_url')
echo "UPLOAD_URL=${UPLOAD_URL}" >> $GITHUB_ENV
# Upload assets to the public repo
- name: Upload Public Release Asset for Linux
run: |
UPLOAD_URL="${UPLOAD_URL/\{?name,label\}/?name=${{ env.PCKG_NAME }}_${{ env.VERSION }}_Linux.tar.gz}"
curl -s -X POST "$UPLOAD_URL" \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Content-Type: application/gzip" \
--data-binary "@./artifacts/Linux-binary/${{ env.PCKG_NAME }}_${{ env.VERSION }}_Linux.tar.gz"
- name: Upload Public Release Asset for Mac
run: |
UPLOAD_URL="${UPLOAD_URL/\{?name,label\}/?name=${{ env.PCKG_NAME }}_${{ env.VERSION }}_macOS.tar.gz}"
curl -s -X POST "$UPLOAD_URL" \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Content-Type: application/gzip" \
--data-binary "@./artifacts/macOS-binary/${{ env.PCKG_NAME }}_${{ env.VERSION }}_macOS.tar.gz"
- name: Upload Public Release Asset for Windows
run: |
UPLOAD_URL="${UPLOAD_URL/\{?name,label\}/?name=${{ env.PCKG_NAME }}_${{ env.VERSION }}_windows.zip}"
curl -s -X POST "$UPLOAD_URL" \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Content-Type: application/zip" \
--data-binary "@./artifacts/windows-binary/${{ env.PCKG_NAME }}_${{ env.VERSION }}_windows.zip"