Skip to content

add git lfs flag to deploy pypi action #59

add git lfs flag to deploy pypi action

add git lfs flag to deploy pypi action #59

Workflow file for this run

name: Build and Release
on:
push:
branches:
- "*release*"
tags:
- "v*"
jobs:
build_and_package:
name: Build & Package ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
include:
- os: windows-latest
platform: windows
exe_name: cst.exe
- os: ubuntu-latest
platform: linux
exe_name: cst
- os: macos-latest
platform: macos
exe_name: cst
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Switched to PyInstaller
pip install pyinstaller
# Install the project so PyInstaller can find dependencies in the environment
pip install -e .
# --- BUILD STEP ---
- name: Build Executable (PyInstaller)
run: python build_exe.py
# --- TEST STEPS ---
- name: Install Test Dependencies
run: |
pip install pytest
- name: Create Integration Test Config
shell: bash
run: echo "model = 'no-model'"> codestoryconfig.toml
- name: Test Built Executable
shell: bash
run: |
echo ">>> Testing Standalone Build"
EXE_PATH="dist/cst/${{ matrix.exe_name }}"
echo "Target Exe: $EXE_PATH"
# Validation: Ensure it exists before testing
if [ ! -f "$EXE_PATH" ]; then
echo "Error: Executable not found at $EXE_PATH"
ls -R dist/
exit 1
fi
# Set the env var for tests to use this specific binary
export CLI_ARTIFACT_PATH="$EXE_PATH"
pytest -vv src/tests/integration
# --- PACKAGING STEPS ---
# 1. WINDOWS: Inno Setup
- name: Install Inno Setup
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
choco install innosetup --no-progress
echo "C:\Program Files (x86)\Inno Setup 6" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Create & Compile Windows Installer
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
# Extract version from git tag
$VERSION = "${{ github.ref_name }}"
$VERSION = $VERSION -replace '^(v|release[-/]?)', ''
if ([string]::IsNullOrEmpty($VERSION) -or $VERSION -notmatch '^\d') { $VERSION = "0.0.1" }
# Package entire cli.dist directory
$issContent = @"
[Setup]
AppName=codestory
AppVersion=$VERSION
DefaultDirName={autopf}\codestory
DefaultGroupName=codestory
OutputBaseFilename=codestory-windows-installer
OutputDir=dist\installers
Compression=lzma
SolidCompression=yes
ChangesEnvironment=yes
ArchitecturesInstallIn64BitMode=x64
[Files]
Source: "dist\cst\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; \
Check: NeedsAddPath('{app}')
[Code]
function NeedsAddPath(Param: string): boolean;
var
OrigPath: string;
begin
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', OrigPath)
then begin
Result := True;
exit;
end;
Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
end;
"@
$issContent | Out-File -FilePath "setup.iss" -Encoding ASCII
New-Item -ItemType Directory -Force -Path "dist\installers"
ISCC.exe setup.iss
# 2. LINUX: Build .deb
- name: Create Linux Installer (.deb)
if: matrix.os == 'ubuntu-latest'
run: |
VERSION="${{ github.ref_name }}"
VERSION=$(echo "$VERSION" | sed -E 's/^(v|release[-/]?)//')
if [[ -z "$VERSION" || ! "$VERSION" =~ ^[0-9] ]]; then VERSION="0.0.1"; fi
mkdir -p dist/package/opt/codestory
mkdir -p dist/package/usr/bin
mkdir -p dist/installers
# Copy entire cst directory to /opt/codestory
cp -r dist/cst/* dist/package/opt/codestory/
chmod +x dist/package/opt/codestory/cst
# Create wrapper script in /usr/bin
cat > dist/package/usr/bin/cst <<'EOF'
#!/bin/bash
exec /opt/codestory/cst "$@"
EOF
chmod +x dist/package/usr/bin/cst
mkdir -p dist/package/DEBIAN
cat > dist/package/DEBIAN/control <<EOF
Package: codestory
Version: $VERSION
Section: utils
Priority: optional
Architecture: amd64
Maintainer: Adem Can <ademfcan@gmail.com>
Description: An AI-powered abstraction layer above Git.
EOF
dpkg-deb --build dist/package dist/installers/codestory-linux-installer.deb
# 3. MACOS: Build .pkg
- name: Create macOS Installer (.pkg)
if: matrix.os == 'macos-latest'
run: |
VERSION="${{ github.ref_name }}"
VERSION=$(echo "$VERSION" | sed -E 's/^(v|release[-/]?)//')
if [[ -z "$VERSION" || ! "$VERSION" =~ ^[0-9] ]]; then VERSION="1.0"; fi
mkdir -p dist/installers
# Prepare a root folder for pkgbuild
mkdir -p dist/pkg_root/opt/codestory
mkdir -p dist/pkg_root/usr/local/bin
# Copy entire cst directory to /opt/codestory
cp -r dist/cst/* dist/pkg_root/opt/codestory/
# Create wrapper script in /usr/local/bin
cat > dist/pkg_root/usr/local/bin/cst <<'EOF'
#!/bin/bash
exec /opt/codestory/cst "$@"
EOF
chmod +x dist/pkg_root/usr/local/bin/cst
# Generate PKG from the root folder
pkgbuild --root dist/pkg_root \
--identifier com.codestory.cli \
--version "$VERSION" \
--install-location / \
dist/installers/codestory-macos-installer.pkg
# --- PREPARE ARTIFACTS ---
- name: Prepare Standalone & Installers
shell: bash
run: |
mkdir -p dist/ready_for_upload
# Package the standalone directory as a zip/tar.gz
if [ "${{ matrix.platform }}" == "windows" ]; then
cd dist
7z a -tzip ready_for_upload/cst-${{ matrix.platform }}-standalone.zip cst/*
cd ..
else
tar -czf dist/ready_for_upload/cst-${{ matrix.platform }}-standalone.tar.gz -C dist cst
fi
# Copy installers
cp dist/installers/* dist/ready_for_upload/
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: release-assets-${{ matrix.platform }}
path: dist/ready_for_upload/*
release:
permissions:
contents: write
name: Create Release
needs: [build_and_package]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure
run: ls -R artifacts/
- name: Extract version
id: get_version
run: |
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ steps.get_version.outputs.version }}
files: |
artifacts/release-assets-windows/*
artifacts/release-assets-linux/*
artifacts/release-assets-macos/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}