-
Notifications
You must be signed in to change notification settings - Fork 1
151 lines (125 loc) · 4.05 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
name: Build
on:
push:
workflow_call:
workflow_dispatch:
jobs:
build-linux:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-in-project: true
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'poetry'
cache-dependency-path: '${{ github.workspace }}/poetry.lock'
- name: Install Dependencies
run: |
pip install poetry
poetry install
- name: Build with PyInstaller
run: |
poetry run pyinstaller --onefile --collect-submodules shellingham --name=isdb-scanner isdb_scanner/__main__.py
- name: Upload Executable as Artifact
uses: actions/upload-artifact@v3
with:
name: isdb-scanner
path: dist/isdb-scanner
- name: Build Wheel
run: |
poetry build
- name: Upload Wheel as Artifact
uses: actions/upload-artifact@v3
with:
name: isdb-scanner-wheel
path: dist/isdb_scanner-*.whl
build-linux-arm:
runs-on: ubuntu-20.04
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Create Dockerfile
run: |
cat <<EOF > Dockerfile
FROM arm64v8/ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends software-properties-common && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt-get install -y \
build-essential \
curl \
patchelf \
python3.11 \
python3.11-dev \
python3.11-distutils \
python3.11-venv \
zlib1g \
zlib1g-dev
RUN curl https://bootstrap.pypa.io/get-pip.py | python3.11
RUN python3.11 -m pip install poetry
EOF
- name: Build Docker Image
uses: docker/build-push-action@v3
with:
context: .
tags: arm64v8/ubuntu:build
cache-from: type=gha,scope=arm64v8/ubuntu
cache-to: type=gha,scope=arm64v8/ubuntu,mode=max
load: true
- name: Remove Dockerfile
run: rm Dockerfile
- name: Checkout Repository
uses: actions/checkout@v3
- name: Build with PyInstaller
run: |
docker run --rm -i -v $(pwd):/work -w /work arm64v8/ubuntu:build bash -c \
'poetry install && poetry run pyinstaller --onefile --collect-submodules shellingham --name=isdb-scanner-arm isdb_scanner/__main__.py'
- name: Upload Executable as Artifact
uses: actions/upload-artifact@v3
with:
name: isdb-scanner-arm
path: dist/isdb-scanner-arm
# build-linux と build-linux-arm のジョブが完了し、かつタグが push されたときのみ実行
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-20.04
needs:
- build-linux
- build-linux-arm
permissions:
contents: write
steps:
- name: Download Artifact (x86_64)
uses: actions/download-artifact@v3
with:
name: isdb-scanner
path: dist
- name: Download Artifact (arm64)
uses: actions/download-artifact@v3
with:
name: isdb-scanner-arm
path: dist
- name: Download Artifact (wheel)
uses: actions/download-artifact@v3
with:
name: isdb-scanner-wheel
path: dist
- name: Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
files: |
./dist/isdb-scanner
./dist/isdb-scanner-arm
./dist/isdb_scanner-*.whl