Skip to content

Commit a50307b

Browse files
committed
Add automated build and release workflow
1 parent 83ba7a5 commit a50307b

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create_release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
outputs:
16+
upload_url: ${{ steps.create_release.outputs.upload_url }}
17+
tag_name: ${{ steps.tag_generator.outputs.tag_name }}
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Generate Tag Name
24+
id: tag_generator
25+
run: |
26+
git fetch --tags
27+
28+
# Get the latest tag, default to v0.0.0 if none exists
29+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
30+
echo "Latest tag found: $LATEST_TAG"
31+
32+
# Remove 'v' prefix
33+
VERSION=${LATEST_TAG#v}
34+
35+
# Split version into array (assuming vX.Y.Z)
36+
IFS='.' read -r -a parts <<< "$VERSION"
37+
38+
# Calculate new version
39+
if [ ${#parts[@]} -eq 3 ]; then
40+
# Standard X.Y.Z format
41+
MAJOR=${parts[0]}
42+
MINOR=${parts[1]}
43+
PATCH=${parts[2]}
44+
NEW_PATCH=$((PATCH + 1))
45+
NEW_TAG="v$MAJOR.$MINOR.$NEW_PATCH"
46+
else
47+
# Fail-safe / Initial formatting
48+
NEW_TAG="v0.0.1"
49+
fi
50+
51+
echo "Generated new tag: $NEW_TAG"
52+
echo "tag_name=$NEW_TAG" >> $GITHUB_OUTPUT
53+
54+
- name: Create Release
55+
id: create_release
56+
uses: softprops/action-gh-release@v1
57+
with:
58+
tag_name: ${{ steps.tag_generator.outputs.tag_name }}
59+
name: Release ${{ steps.tag_generator.outputs.tag_name }}
60+
draft: false
61+
prerelease: false
62+
generate_release_notes: true
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
66+
build:
67+
name: Build Executable
68+
needs: create_release
69+
runs-on: ${{ matrix.os }}
70+
strategy:
71+
matrix:
72+
os: [windows-latest, ubuntu-latest, macos-latest]
73+
74+
steps:
75+
- uses: actions/checkout@v3
76+
77+
- name: Set up Python
78+
uses: actions/setup-python@v4
79+
with:
80+
python-version: '3.10'
81+
82+
- name: Install Dependencies
83+
run: |
84+
python -m pip install --upgrade pip
85+
pip install -r requirements.txt
86+
pip install pyinstaller
87+
88+
- name: Install Linux System Dependencies
89+
if: runner.os == 'Linux'
90+
run: |
91+
sudo apt-get update
92+
sudo apt-get install -y python3-tk
93+
94+
- name: Build with PyInstaller (Windows)
95+
if: runner.os == 'Windows'
96+
run: |
97+
pyinstaller --name WASP --onefile --windowed --add-data "core;core" --add-data "gui;gui" main.py
98+
mv dist/WASP.exe dist/WASP-windows.exe
99+
100+
- name: Build with PyInstaller (Linux)
101+
if: runner.os == 'Linux'
102+
run: |
103+
pyinstaller --name WASP --onefile --windowed --add-data "core:core" --add-data "gui:gui" main.py
104+
mv dist/WASP dist/WASP-linux
105+
106+
- name: Build with PyInstaller (macOS)
107+
if: runner.os == 'macOS'
108+
run: |
109+
pyinstaller --name WASP --onefile --windowed --add-data "core:core" --add-data "gui:gui" main.py
110+
# Create DMG
111+
hdiutil create dist/WASP.dmg -srcfolder dist/WASP.app -ov -format UDZO
112+
mv dist/WASP.dmg dist/WASP-macos.dmg
113+
114+
- name: Move to Output Folder (Simulating "Store at output")
115+
shell: bash
116+
run: |
117+
mkdir -p output
118+
if [ "${{ runner.os }}" == "Windows" ]; then
119+
cp dist/WASP-windows.exe output/
120+
elif [ "${{ runner.os }}" == "Linux" ]; then
121+
cp dist/WASP-linux output/
122+
elif [ "${{ runner.os }}" == "macOS" ]; then
123+
cp dist/WASP-macos.dmg output/
124+
fi
125+
126+
- name: Upload Release Asset (Windows)
127+
if: runner.os == 'Windows'
128+
uses: softprops/action-gh-release@v1
129+
with:
130+
tag_name: ${{ needs.create_release.outputs.tag_name }}
131+
files: output/WASP-windows.exe
132+
env:
133+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
135+
- name: Upload Release Asset (Linux)
136+
if: runner.os == 'Linux'
137+
uses: softprops/action-gh-release@v1
138+
with:
139+
tag_name: ${{ needs.create_release.outputs.tag_name }}
140+
files: output/WASP-linux
141+
env:
142+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143+
144+
- name: Upload Release Asset (macOS)
145+
if: runner.os == 'macOS'
146+
uses: softprops/action-gh-release@v1
147+
with:
148+
tag_name: ${{ needs.create_release.outputs.tag_name }}
149+
files: output/WASP-macos.dmg
150+
env:
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152+
153+
- name: Upload Artifact
154+
uses: actions/upload-artifact@v3
155+
with:
156+
name: WASP-${{ matrix.os }}
157+
path: output/*

0 commit comments

Comments
 (0)