-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (91 loc) · 3.29 KB
/
build_executables.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
name: Build Executables
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest]
outputs:
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for tagging
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install pipenv
run: pip install pipenv
- name: Install dependencies
run: pipenv install --dev
- name: Run tests
run: pipenv run test
- name: Install PyInstaller
run: pipenv run pip install pyinstaller
- name: Build executable for ${{ matrix.os }}
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
pipenv run pyinstaller --onefile --name weduc_timetable_extractor_windows weduc_timetable_extractor/__main__.py
elif [[ "${{ matrix.os }}" == "ubuntu-20.04" ]]; then
pipenv run pyinstaller --onefile --name weduc_timetable_extractor_ubuntu_20.04 weduc_timetable_extractor/__main__.py
elif [[ "${{ matrix.os }}" == "ubuntu-22.04" ]]; then
pipenv run pyinstaller --onefile --name weduc_timetable_extractor_ubuntu_22.04 weduc_timetable_extractor/__main__.py
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
pipenv run pyinstaller --onefile --name weduc_timetable_extractor_macos weduc_timetable_extractor/__main__.py
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: weduc_timetable_extractor-${{ matrix.os }}
path: dist/*
- name: Create Release
if: ${{ matrix.os == 'macos-latest' }}
id: create_release
uses: ncipollo/release-action@v1
with:
tag: v${{ github.run_number }}
name: Release v${{ github.run_number }}
body: |
Automated release generated by GitHub Actions.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload:
needs: build
runs-on: macos-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get Release Upload URL
run: echo "RELEASE_UPLOAD_URL=${{ needs.build.outputs.release_upload_url }}" >> $GITHUB_ENV
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
# Strip the template placeholder from the upload URL
UPLOAD_URL="${RELEASE_UPLOAD_URL%\{*}"
for filepath in artifacts/**/*; do
if [ -f "$filepath" ]; then
filename=$(basename "$filepath")
echo "Uploading $filename..."
curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$filepath" \
"${UPLOAD_URL}?name=$filename"
fi
done