Skip to content

Commit 9b8c536

Browse files
authored
Merge pull request #2 from fiandev/master
Implement ci/cd for automate release binary for linux and windows
2 parents 03c71b5 + c5e1010 commit 9b8c536

5 files changed

Lines changed: 500 additions & 91 deletions

File tree

.github/workflows/build.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Build PyHttrack
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches: [main, master]
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-linux:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- arch: x64
20+
gnu_arch: x86_64
21+
- arch: x86
22+
gnu_arch: i686
23+
- arch: arm64
24+
gnu_arch: aarch64
25+
- arch: armv7
26+
gnu_arch: armv7l
27+
- arch: ppc64le
28+
gnu_arch: ppc64le
29+
- arch: s390x
30+
gnu_arch: s390x
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: '3.x'
39+
40+
- name: Install wget
41+
run: sudo apt-get update && sudo apt-get install -y wget
42+
43+
- name: Install dependencies
44+
run: |
45+
pip install -r requirements.txt
46+
pip install pyinstaller
47+
48+
- name: Build binary for Linux
49+
run: |
50+
pyinstaller --onefile --name pyhttrack \
51+
--add-data "web.json:." \
52+
--hidden-import colorama \
53+
--console \
54+
pyhttrack.py
55+
mkdir -p build/pyhttrack-linux-${{ matrix.arch }}
56+
mv dist/pyhttrack build/pyhttrack-linux-${{ matrix.arch }}/
57+
mkdir -p build/pyhttrack-linux-${{ matrix.arch }}/web
58+
cp README.md LICENSE build/pyhttrack-linux-${{ matrix.arch }}/
59+
tar -czvf pyhttrack-linux-${{ matrix.arch }}.tar.gz -C build pyhttrack-linux-${{ matrix.arch }}
60+
61+
- name: Upload artifacts
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: pyhttrack-linux-${{ matrix.arch }}
65+
path: pyhttrack-linux-${{ matrix.arch }}.tar.gz
66+
67+
build-windows:
68+
runs-on: windows-latest
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
include:
73+
- arch: x64
74+
- arch: x86
75+
steps:
76+
- name: Checkout repository
77+
uses: actions/checkout@v4
78+
79+
- name: Set up Python
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: '3.x'
83+
84+
- name: Install dependencies
85+
run: |
86+
pip install -r requirements.txt
87+
pip install pyinstaller
88+
89+
- name: Download wget binaries for Windows
90+
run: |
91+
$arch = "${{ matrix.arch }}"
92+
New-Item -ItemType Directory -Force -Path "wget\$arch"
93+
$url = switch ($arch) {
94+
"x64" { "https://github.com/KnugiHK/wget-on-windows/releases/download/v1.25.0/wget-gnutls-x64.exe" }
95+
"x86" { "https://github.com/KnugiHK/wget-on-windows/releases/download/v1.25.0/wget-gnutls-x86.exe" }
96+
}
97+
Invoke-WebRequest -Uri $url -OutFile "wget\$arch\wget.exe"
98+
99+
- name: Build binary for Windows
100+
run: |
101+
pyinstaller --onefile --name pyhttrack `
102+
--add-data "wget;wget" `
103+
--add-data "web.json;." `
104+
--hidden-import colorama `
105+
--console `
106+
pyhttrack.py
107+
New-Item -ItemType Directory -Force -Path build\pyhttrack-windows-${{ matrix.arch }}
108+
Move-Item dist\pyhttrack.exe build\pyhttrack-windows-${{ matrix.arch }}\
109+
New-Item -ItemType Directory -Force -Path build\pyhttrack-windows-${{ matrix.arch }}\web
110+
Copy-Item README.md build\pyhttrack-windows-${{ matrix.arch }}\
111+
Copy-Item LICENSE build\pyhttrack-windows-${{ matrix.arch }}\
112+
Compress-Archive -Path build\pyhttrack-windows-${{ matrix.arch }}\* -DestinationPath pyhttrack-windows-${{ matrix.arch }}.tar.gz
113+
114+
- name: Upload artifacts
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: pyhttrack-windows-${{ matrix.arch }}
118+
path: pyhttrack-windows-${{ matrix.arch }}.tar.gz
119+
120+
release:
121+
needs: [build-linux, build-windows]
122+
if: startsWith(github.ref, 'refs/tags/v')
123+
runs-on: ubuntu-latest
124+
permissions:
125+
contents: write
126+
steps:
127+
- name: Download all artifacts
128+
uses: actions/download-artifact@v4
129+
with:
130+
path: artifacts
131+
132+
- name: Create Release
133+
uses: softprops/action-gh-release@v1
134+
with:
135+
files: artifacts/**/*
136+
generate_release_notes: true
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
web
22
log.txt
33
web.json
4+
dist
5+
build
6+
__pycache__/

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.PHONY: help install test clean build
2+
3+
PYHT := pyhttrack.py
4+
PYTHON := python
5+
PIP := pip
6+
7+
help:
8+
@echo "PyHttrack Makefile"
9+
@echo ""
10+
@echo "Available targets:"
11+
@echo " install - Install Python dependencies (including PyInstaller)"
12+
@echo " test - Run the script locally"
13+
@echo " build - Create binary executable"
14+
@echo " clean - Clean build artifacts"
15+
16+
install:
17+
$(PIP) install -r requirements.txt
18+
$(PIP) install pyinstaller
19+
20+
test:
21+
$(PYTHON) $(PYHT)
22+
23+
build:
24+
@echo "Building binary..."
25+
@rm -rf dist build
26+
@$(PYTHON) -m PyInstaller --onefile --name pyhttrack \
27+
--add-data "wget:wget" \
28+
--add-data "web.json:." \
29+
--hidden-import colorama \
30+
--console \
31+
$(PYHT)
32+
@rm -rf build pyhttrack.spec
33+
@echo "Binary created: dist/pyhttrack"
34+
35+
clean:
36+
rm -rf web/*.log web/*.html web/**/*.html 2>/dev/null || true
37+
rm -f log.txt
38+
rm -rf dist build pyhttrack.spec 2>/dev/null || true

README.md

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,40 @@ PyHttrack is a lightweight and powerful Python tool that allows you to download
2323

2424
### Installation
2525

26+
#### 1. Clone the repository
27+
28+
```bash
29+
git clone https://github.com/riodevnet/PyHttrack.git
30+
cd PyHttrack
31+
```
32+
33+
#### 2. Install Python dependencies
34+
2635
```bash
2736
pip install -r requirements.txt
2837
```
2938

39+
#### 3. Run PyHttrack
40+
41+
```bash
42+
python pyhttrack.py
43+
```
44+
45+
### CLI Options
46+
47+
PyHttrack can also be run with command-line arguments:
48+
49+
```bash
50+
python pyhttrack.py --url "https://example.com"
51+
```
52+
53+
Available options:
54+
- `--url` - Single URL to download (overrides web.json)
55+
- `--help` - Show help message
56+
3057
### Configuration
3158

32-
Edit the web.json file and add the url of the website you want to download, for example the following :
59+
Edit the `web.json` file and add the url of the website you want to download, for example the following :
3360

3461
```json
3562
["https://example.com/xxx/xxx"]
@@ -53,6 +80,65 @@ Run the following command to start the download :
5380
python pyhttrack.py
5481
```
5582

83+
## 🔨 Build from Source
84+
85+
### Using Makefile
86+
87+
```bash
88+
# Install dependencies
89+
make install
90+
91+
# Test locally
92+
make test
93+
94+
# Clean build artifacts
95+
make clean
96+
```
97+
98+
### GitHub Actions (Automated Build)
99+
100+
The repository includes `.github/workflows/build.yml` that automatically builds for all platforms when you push a tag:
101+
102+
```bash
103+
# Create and push a version tag
104+
git tag v1.0.0
105+
git push origin v1.0.0
106+
```
107+
108+
This will trigger builds for:
109+
- **Linux**: x64, x86, arm64, armv7, ppc64le, s390x
110+
- **Windows**: x64, x86, arm64
111+
112+
## 📦 Installation as a System Command (Optional)
113+
114+
You can install PyHttrack as a global command on your system using symlinks:
115+
116+
### Linux / macOS
117+
118+
```bash
119+
# Create a symlink to make pyhttrack available globally
120+
sudo ln -sf "$(pwd)/pyhttrack.py" /usr/local/bin/pyhttrack
121+
122+
# Run from anywhere
123+
pyhttrack
124+
```
125+
126+
### Windows
127+
128+
```cmd
129+
:: Open Command Prompt as Administrator
130+
cd C:\path\to\PyHttrack
131+
mklink C:\Windows\System32\pyhttrack.py pyhttrack.py
132+
133+
:: Run from anywhere
134+
python C:\Windows\System32\pyhttrack.py
135+
```
136+
137+
Or add the PyHttrack directory to your PATH:
138+
```cmd
139+
setx PATH "%PATH%;C:\path\to\PyHttrack"
140+
```
141+
56142
## 📥 Latest Release
57143

58144
[Click here](https://github.com/riodevnet/PyHttrack/releases/latest) to get the latest version of PyHttrack.

0 commit comments

Comments
 (0)