add dynamic versioning to build/release scripts;add fixed versioning to csproj file
All checks were successful
Release / release (push) Successful in 1m15s
All checks were successful
Release / release (push) Successful in 1m15s
This commit is contained in:
parent
afd13c660e
commit
b82312d26f
@ -59,16 +59,17 @@ jobs:
|
|||||||
- name: Create Release Archive
|
- name: Create Release Archive
|
||||||
run: |
|
run: |
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
|
VERSION_NUM=${VERSION#v} # Remove 'v' prefix (e.g., v0.1.4 -> 0.1.4)
|
||||||
mkdir -p release
|
mkdir -p release
|
||||||
|
|
||||||
# Copy AppImage (if it exists)
|
# Copy AppImage (if it exists) - use version from build
|
||||||
if [ -f publish/appimage/NotePad-0.1.0-x86_64.AppImage ]; then
|
if [ -f publish/appimage/NotePad-${VERSION_NUM}-x86_64.AppImage ]; then
|
||||||
cp publish/appimage/NotePad-0.1.0-x86_64.AppImage \
|
cp publish/appimage/NotePad-${VERSION_NUM}-x86_64.AppImage \
|
||||||
release/NotePad-${VERSION}-x86_64.AppImage
|
release/NotePad-${VERSION}-x86_64.AppImage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy Linux Tarball
|
# Copy Linux Tarball
|
||||||
cp publish/tarball/notepad-0.1.0-linux-x64.tar.gz \
|
cp publish/tarball/notepad-${VERSION_NUM}-linux-x64.tar.gz \
|
||||||
release/notepad-${VERSION}-linux-x64.tar.gz
|
release/notepad-${VERSION}-linux-x64.tar.gz
|
||||||
|
|
||||||
# Create Windows zip
|
# Create Windows zip
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
<ApplicationIcon>img\notepad-icon.ico</ApplicationIcon>
|
<ApplicationIcon>img\notepad-icon.ico</ApplicationIcon>
|
||||||
|
<Version>0.1.5</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
APP_NAME="NotePad"
|
APP_NAME="NotePad"
|
||||||
VERSION="0.1.0"
|
VERSION="${1:-0.1.0}" # Use first argument or default to 0.1.0
|
||||||
ARCH="x86_64"
|
ARCH="x86_64"
|
||||||
|
|
||||||
# Directories
|
# Directories
|
||||||
|
|||||||
@ -9,9 +9,30 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tarfile
|
import tarfile
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
"""Extract version from .csproj file"""
|
||||||
|
csproj_path = Path("NotePad.csproj")
|
||||||
|
if not csproj_path.exists():
|
||||||
|
print("⚠️ WARNING: NotePad.csproj not found. Using default version 0.1.0")
|
||||||
|
return "0.1.0"
|
||||||
|
|
||||||
|
try:
|
||||||
|
tree = ET.parse(csproj_path)
|
||||||
|
root = tree.getroot()
|
||||||
|
version_elem = root.find(".//Version")
|
||||||
|
if version_elem is not None and version_elem.text:
|
||||||
|
return version_elem.text
|
||||||
|
print("⚠️ WARNING: Version not found in .csproj. Using default version 0.1.0")
|
||||||
|
return "0.1.0"
|
||||||
|
except Exception as e:
|
||||||
|
print(f"⚠️ WARNING: Failed to parse .csproj: {e}. Using default version 0.1.0")
|
||||||
|
return "0.1.0"
|
||||||
|
|
||||||
|
|
||||||
def run_command(cmd, description):
|
def run_command(cmd, description):
|
||||||
"""Run a shell command and print status"""
|
"""Run a shell command and print status"""
|
||||||
print(f"\n{'=' * 60}")
|
print(f"\n{'=' * 60}")
|
||||||
@ -69,7 +90,7 @@ def build_windows_installer():
|
|||||||
print(f"\n⚠️ WARNING: Failed to create installer: {e}")
|
print(f"\n⚠️ WARNING: Failed to create installer: {e}")
|
||||||
|
|
||||||
|
|
||||||
def build_linux_tarball():
|
def build_linux_tarball(version):
|
||||||
"""Create tar.gz archive with install script"""
|
"""Create tar.gz archive with install script"""
|
||||||
print(f"\n{'=' * 60}")
|
print(f"\n{'=' * 60}")
|
||||||
print("Creating Linux tar.gz archive")
|
print("Creating Linux tar.gz archive")
|
||||||
@ -100,8 +121,13 @@ def build_linux_tarball():
|
|||||||
shutil.copy(script_path, temp_dir / "notepad" / script)
|
shutil.copy(script_path, temp_dir / "notepad" / script)
|
||||||
os.chmod(temp_dir / "notepad" / script, 0o755)
|
os.chmod(temp_dir / "notepad" / script, 0o755)
|
||||||
|
|
||||||
|
# Copy img directory (contains icon)
|
||||||
|
img_dir = Path("img")
|
||||||
|
if img_dir.exists():
|
||||||
|
shutil.copytree(img_dir, temp_dir / "notepad" / "img")
|
||||||
|
|
||||||
# Create tar.gz
|
# Create tar.gz
|
||||||
tarball_path = tarball_dir / "notepad-0.1.0-linux-x64.tar.gz"
|
tarball_path = tarball_dir / f"notepad-{version}-linux-x64.tar.gz"
|
||||||
with tarfile.open(tarball_path, "w:gz") as tar:
|
with tarfile.open(tarball_path, "w:gz") as tar:
|
||||||
tar.add(temp_dir / "notepad", arcname="notepad")
|
tar.add(temp_dir / "notepad", arcname="notepad")
|
||||||
|
|
||||||
@ -116,7 +142,7 @@ def build_linux_tarball():
|
|||||||
print(f" sudo ./install.sh")
|
print(f" sudo ./install.sh")
|
||||||
|
|
||||||
|
|
||||||
def build_linux_appimage():
|
def build_linux_appimage(version):
|
||||||
"""Build Linux AppImage"""
|
"""Build Linux AppImage"""
|
||||||
build_script = Path("build-appimage.sh")
|
build_script = Path("build-appimage.sh")
|
||||||
if not build_script.exists():
|
if not build_script.exists():
|
||||||
@ -125,7 +151,7 @@ def build_linux_appimage():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["bash", str(build_script)],
|
["bash", str(build_script), version],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True
|
text=True
|
||||||
)
|
)
|
||||||
@ -190,10 +216,11 @@ def publish_platform(platform, linux_package='both'):
|
|||||||
|
|
||||||
# Build Linux packages
|
# Build Linux packages
|
||||||
if platform == 'linux':
|
if platform == 'linux':
|
||||||
|
version = get_version()
|
||||||
if linux_package in ['appimage', 'both']:
|
if linux_package in ['appimage', 'both']:
|
||||||
build_linux_appimage()
|
build_linux_appimage(version)
|
||||||
if linux_package in ['tarball', 'both']:
|
if linux_package in ['tarball', 'both']:
|
||||||
build_linux_tarball()
|
build_linux_tarball(version)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user