Skip to content

Commit 10dfc97

Browse files
committed
Github actions
1 parent 57ca136 commit 10dfc97

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

.github/workflows/build.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build tor-relay-scanner
2+
3+
on:
4+
push:
5+
paths:
6+
- 'src/**'
7+
8+
env:
9+
PYTHON_URL: https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe
10+
PYTHON_NAME: python-3.8.10.exe
11+
PYTHON_SHA256: ad07633a1f0cd795f3bf9da33729f662281df196b4567fa795829f3bb38a30ac
12+
WINEARCH: win32
13+
14+
jobs:
15+
build_linux:
16+
name: Build Python pyz file
17+
runs-on: ubuntu-20.04
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Declare short commit variable
22+
id: vars
23+
run: |
24+
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
25+
26+
- name: Build pyz file
27+
run: |
28+
./build.sh
29+
mv torparse.pyz tor-relay-scanner-${{ steps.vars.outputs.sha_short }}.pyz
30+
31+
- name: Upload output file x86
32+
uses: actions/upload-artifact@v2
33+
with:
34+
name: tor-relay-scanner-${{ steps.vars.outputs.sha_short }}.pyz
35+
path: tor-relay-scanner-${{ steps.vars.outputs.sha_short }}.pyz
36+
37+
build_windows:
38+
name: Build Windows exe file
39+
runs-on: ubuntu-20.04
40+
steps:
41+
- uses: actions/checkout@v2
42+
43+
- name: Declare short commit variable
44+
id: vars
45+
run: |
46+
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
47+
48+
- name: Install Wine
49+
run: >
50+
sudo rm /var/lib/man-db/auto-update &&
51+
sudo sed -i 's/yes/no/g' /etc/initramfs-tools/update-initramfs.conf &&
52+
sudo dpkg --add-architecture i386 && sudo apt update &&
53+
sudo eatmydata apt install -y --allow-downgrades libpcre2-8-0/focal &&
54+
sudo DEBIAN_FRONTEND=noninteractive eatmydata
55+
apt install -y --no-install-recommends wine-stable wine32 xvfb
56+
57+
- name: Download Python from cache
58+
id: python-cache
59+
uses: actions/cache@v2
60+
with:
61+
path: ${{ env. PYTHON_NAME }}
62+
key: ${{ env. PYTHON_SHA256 }}
63+
64+
- name: Download Python from the website
65+
if: steps.python-cache.outputs.cache-hit != 'true'
66+
run: >
67+
wget ${{ env. PYTHON_URL }} &&
68+
(echo ${{ env. PYTHON_SHA256 }} ${{ env. PYTHON_NAME }} | sha256sum -c)
69+
70+
- name: Install Python and dependencies (Windows)
71+
run: |
72+
xvfb-run wine ${{ env. PYTHON_NAME }} /quiet InstallAllUsers=1 PrependPath=1
73+
wine pip install .
74+
wine pip install pyinstaller
75+
76+
- name: Build exe file for Windows
77+
run: |
78+
wine pyinstaller -c -F src/tor_relay_scanner/__main__.py
79+
mv dist/__main__.exe tor-relay-scanner-${{ steps.vars.outputs.sha_short }}.exe
80+
81+
- name: Upload output file
82+
uses: actions/upload-artifact@v2
83+
with:
84+
name: tor-relay-scanner-${{ steps.vars.outputs.sha_short }}.exe
85+
path: tor-relay-scanner-${{ steps.vars.outputs.sha_short }}.exe

0 commit comments

Comments
 (0)