Skip to content

Commit a514b8f

Browse files
committed
Add workflow to build standalone binaries
Thanks to Francesco Pira <[email protected]> for the idea.
1 parent b43e043 commit a514b8f

File tree

3 files changed

+121
-1
lines changed

3 files changed

+121
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
pull_request:
55
schedule:
6-
- cron: '0 8 * * 6'
6+
- cron: "0 8 * * 6"
77
jobs:
88
test:
99
env:

.github/workflows/release.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
8+
jobs:
9+
test:
10+
env:
11+
PIP_DISABLE_PIP_VERSION_CHECK: 1
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- os: ubuntu-latest
17+
platform: linux
18+
arch: x64
19+
- os: ubuntu-24.04-arm
20+
platform: linux
21+
arch: arm64
22+
- os: macos-13
23+
platform: macos
24+
arch: x64
25+
- os: macos-latest
26+
platform: macos
27+
arch: arm64
28+
- os: windows-latest
29+
platform: windows
30+
arch: x64
31+
- os: windows-11-arm
32+
platform: windows
33+
arch: arm64
34+
runs-on: ${{ matrix.os }}
35+
name: "Test: ${{ matrix.platform }}-${{ matrix.arch }}"
36+
steps:
37+
- uses: actions/checkout@v4
38+
with:
39+
submodules: recursive
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: "3.11"
43+
- uses: pypa/hatch@install
44+
- run: hatch test
45+
46+
build-binaries:
47+
needs: test
48+
strategy:
49+
matrix:
50+
include:
51+
- os: ubuntu-latest
52+
platform: linux
53+
arch: x64
54+
- os: ubuntu-24.04-arm
55+
platform: linux
56+
arch: arm64
57+
- os: macos-13
58+
platform: macos
59+
arch: x64
60+
- os: macos-latest
61+
platform: macos
62+
arch: arm64
63+
- os: windows-latest
64+
platform: windows
65+
arch: x64
66+
- os: windows-11-arm
67+
platform: windows
68+
arch: arm64
69+
runs-on: ${{ matrix.os }}
70+
name: Build binary for ${{ matrix.platform }}-${{ matrix.arch }}
71+
steps:
72+
- uses: actions/checkout@v4
73+
with:
74+
submodules: recursive
75+
- uses: actions/setup-python@v5
76+
with:
77+
python-version: "3.11"
78+
- name: Install dependencies
79+
run: |
80+
python -m pip install --upgrade pip
81+
pip install pyinstaller
82+
pip install .
83+
- name: Build binary
84+
run: |
85+
pyinstaller --onefile --name dotbot src/dotbot/cli.py
86+
- name: Package binary
87+
shell: bash
88+
run: |
89+
if [[ "${{ matrix.platform }}" == "windows" ]]; then
90+
cd dist && powershell Compress-Archive -Path dotbot.exe -DestinationPath dotbot-${{ matrix.platform }}-${{ matrix.arch }}.zip
91+
else
92+
cd dist && tar -czf dotbot-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz dotbot
93+
fi
94+
- name: Upload binary
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: dotbot-${{ matrix.platform }}-${{ matrix.arch }}
98+
path: dist/dotbot-${{ matrix.platform }}-${{ matrix.arch }}.*
99+
100+
github-release:
101+
needs: build-binaries
102+
runs-on: ubuntu-latest
103+
name: Create GitHub Release
104+
permissions:
105+
contents: write
106+
steps:
107+
- uses: actions/checkout@v4
108+
- name: Download all artifacts
109+
uses: actions/download-artifact@v4
110+
with:
111+
path: artifacts
112+
- name: Create Release
113+
uses: softprops/action-gh-release@v2
114+
with:
115+
files: artifacts/*/dotbot-*
116+
generate_release_notes: true

src/dotbot/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,7 @@ def main() -> None:
149149
except KeyboardInterrupt:
150150
log.error("\n==> Operation aborted") # noqa: TRY400
151151
sys.exit(1)
152+
153+
154+
if __name__ == "__main__":
155+
main()

0 commit comments

Comments
 (0)