Release workflow refinements #24

Merged
JMR-dev merged 23 commits from fix-gh-actions-refinements into develop 2025-10-16 23:51:33 +00:00
11 changed files with 1407 additions and 655 deletions
+15 -10
View File
@@ -2,13 +2,17 @@ name: Claude Code Review
on:
pull_request:
types: [opened, synchronize]
types: [opened]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"
# - "src/**/*.py"
workflow_dispatch:
inputs:
branch:
description: 'Branch to run the review against'
required: true
default: 'develop'
type: string
permissions:
contents: read
@@ -33,7 +37,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Run Claude Code Review
id: claude-review
@@ -42,18 +47,18 @@ jobs:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}
${{ github.event_name == 'pull_request' && format('PR NUMBER: {0}', github.event.pull_request.number) || format('BRANCH: {0}', inputs.branch) }}
Please review this pull request and provide feedback on:
Please review this ${{ github.event_name == 'pull_request' && 'pull request' || format('branch ({0})', inputs.branch) }} and provide feedback on:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
${{ github.event_name == 'pull_request' && 'Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.' || 'Provide a summary of your findings.' }}
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
+579 -146
View File
@@ -12,6 +12,15 @@ name: Build Multi-Platform Binaries
on:
workflow_dispatch:
inputs:
new_version:
description: "New version to release (e.g., 0.2.0)"
required: true
type: string
pr_check_timeout:
description: "Timeout in seconds for PR status checks (default: 1800)"
required: false
type: number
default: 1800
jobs:
description: "Comma-separated jobs to run (e.g., build-windows,build-debian,build-arch,build-rhel)"
required: true
@@ -21,6 +30,12 @@ permissions:
contents: write
pull-requests: write
# Prevent multiple release workflows from running simultaneously
# This is critical to prevent concurrent rollbacks
concurrency:
group: release-workflow
cancel-in-progress: false
env:
# change this if you prefer a different pinned fpm version
FPM_VERSION: "1.16.0"
@@ -29,8 +44,247 @@ env:
CI_CD: true
jobs:
merge-develop-to-main:
bump-version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
pr_number: ${{ steps.create-pr.outputs.pr_number }}
steps:
- name: Validate version format
run: |
VERSION="${{ github.event.inputs.new_version }}"
# Full semver regex supporting:
# - Basic: 1.2.3
# - Prerelease: 1.2.3-beta, 1.2.3-rc.1, 1.2.3-alpha.1.2
# - Build metadata: 1.2.3+build, 1.2.3+20130313144700
# - Combined: 1.2.3-beta.1+build.123
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?(\+[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$ ]]; then
echo "::error::Invalid version format: $VERSION"
echo "::error::Expected semantic version format (e.g., 1.2.3, 1.2.3-beta.1, 1.2.3+build.123)"
exit 1
fi
echo "Version format is valid: $VERSION"
- name: Checkout develop branch
uses: actions/checkout@v4
with:
ref: develop
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Check for existing PR or branch
id: check-existing
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
VERSION="${{ github.event.inputs.new_version }}"
BRANCH_NAME="release/v${VERSION}"
# Check if branch already exists
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
echo "::warning::Branch $BRANCH_NAME already exists"
# Check if there's an open PR for this branch
EXISTING_PR=$(gh pr list --base develop --head "$BRANCH_NAME" --state open --json number --jq '.[0].number' || echo "")
if [ -n "$EXISTING_PR" ]; then
echo "::error::PR #$EXISTING_PR already exists for version $VERSION"
echo "::error::Please close or merge the existing PR before creating a new release"
exit 1
fi
echo "::error::Branch $BRANCH_NAME exists but no open PR found"
echo "::error::Please delete the branch or use a different version number"
exit 1
fi
echo "✓ No existing branch or PR found for version $VERSION"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Create release branch and bump version
id: bump
run: |
set -e
VERSION="${{ github.event.inputs.new_version }}"
BRANCH_NAME="${{ steps.check-existing.outputs.branch_name }}"
# Create and checkout release branch
git checkout -b "$BRANCH_NAME"
# Update version in pyproject.toml
poetry version "$VERSION"
# Commit the version change
git add pyproject.toml
git commit -m "Bump version to ${VERSION}"
# Push the branch with error handling
if ! git push origin "$BRANCH_NAME"; then
echo "::error::Failed to push branch $BRANCH_NAME"
exit 1
fi
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Create PR to develop
id: create-pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
VERSION="${{ github.event.inputs.new_version }}"
BRANCH_NAME="${{ steps.bump.outputs.branch_name }}"
# Create PR with auto-merge enabled
PR_URL=$(gh pr create \
--base develop \
--head "$BRANCH_NAME" \
--title "Release v${VERSION}" \
--body "This PR bumps the version to ${VERSION} as part of the release process.
**Auto-generated by release workflow**
Once status checks pass, this PR will be automatically merged." \
--repo ${{ github.repository }} || {
echo "::error::Failed to create PR"
exit 1
})
# Extract PR number from URL
PR_NUMBER=$(echo "$PR_URL" | grep -oP '\d+$')
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "Created PR #$PR_NUMBER: $PR_URL"
# Enable auto-merge (rebase)
if ! gh pr merge "$PR_NUMBER" --auto --rebase --repo ${{ github.repository }}; then
echo "::error::Failed to enable auto-merge for PR #$PR_NUMBER"
exit 1
fi
echo "Auto-merge enabled for PR #$PR_NUMBER"
wait-for-version-pr:
needs: [bump-version]
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Wait for PR status checks and merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
PR_NUMBER="${{ needs.bump-version.outputs.pr_number }}"
echo "Monitoring PR #$PR_NUMBER for status checks..."
MAX_WAIT=${{ github.event.inputs.pr_check_timeout || 1800 }}
INITIAL_INTERVAL=10
MAX_INTERVAL=300 # 5 minutes maximum
BACKOFF_MULTIPLIER=1.5
SLEEP_INTERVAL=$INITIAL_INTERVAL
ELAPSED=0
RETRY_COUNT=0
MAX_RETRIES=3
echo "Max wait time: ${MAX_WAIT}s, using exponential backoff (max interval: ${MAX_INTERVAL}s)"
while [ $ELAPSED -lt $MAX_WAIT ]; do
# Get PR status with retry logic
if ! PR_STATE=$(gh pr view "$PR_NUMBER" --json state --jq '.state' --repo ${{ github.repository }} 2>&1); then
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
echo "::error::Failed to fetch PR status after $MAX_RETRIES retries"
exit 1
fi
echo "::warning::Failed to fetch PR status (attempt $RETRY_COUNT/$MAX_RETRIES), retrying..."
sleep $((2 ** RETRY_COUNT))
continue
fi
RETRY_COUNT=0
if [ "$PR_STATE" = "MERGED" ]; then
echo "✓ PR #$PR_NUMBER has been merged successfully!"
exit 0
fi
if [ "$PR_STATE" = "CLOSED" ]; then
echo "::error::PR #$PR_NUMBER was closed without merging"
exit 1
fi
# Check status checks with retry logic
RETRY_COUNT=0
if ! STATUS_JSON=$(gh pr view "$PR_NUMBER" --json statusCheckRollup --jq '.statusCheckRollup' --repo ${{ github.repository }} 2>&1); then
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
echo "::error::Failed to fetch status checks after $MAX_RETRIES retries"
exit 1
fi
echo "::warning::Failed to fetch status checks (attempt $RETRY_COUNT/$MAX_RETRIES), retrying..."
sleep $((2 ** RETRY_COUNT))
continue
fi
# Count check states
TOTAL=$(echo "$STATUS_JSON" | jq 'length')
COMPLETED=$(echo "$STATUS_JSON" | jq '[.[] | select(.conclusion != null)] | length')
SUCCESS=$(echo "$STATUS_JSON" | jq '[.[] | select(.conclusion == "SUCCESS" or .conclusion == "NEUTRAL" or .conclusion == "SKIPPED")] | length')
FAILED=$(echo "$STATUS_JSON" | jq '[.[] | select(.conclusion == "FAILURE" or .conclusion == "CANCELLED" or .conclusion == "TIMED_OUT")] | length')
echo "Status checks: $COMPLETED/$TOTAL completed, $SUCCESS passed, $FAILED failed (interval: ${SLEEP_INTERVAL}s)"
# Check for failures
if [ "$FAILED" -gt 0 ]; then
echo "::error::Status checks failed for PR #$PR_NUMBER"
gh pr view "$PR_NUMBER" --json statusCheckRollup --jq '.statusCheckRollup[] | select(.conclusion == "FAILURE" or .conclusion == "CANCELLED" or .conclusion == "TIMED_OUT") | "- " + .name + ": " + .conclusion' --repo ${{ github.repository }}
exit 1
fi
echo "Waiting for checks to complete... (${ELAPSED}s elapsed)"
sleep $SLEEP_INTERVAL
ELAPSED=$((ELAPSED + SLEEP_INTERVAL))
# Calculate next interval with exponential backoff (capped at MAX_INTERVAL)
NEXT_INTERVAL=$(awk "BEGIN {printf \"%.0f\", $SLEEP_INTERVAL * $BACKOFF_MULTIPLIER}")
if [ $NEXT_INTERVAL -gt $MAX_INTERVAL ]; then
SLEEP_INTERVAL=$MAX_INTERVAL
else
SLEEP_INTERVAL=$NEXT_INTERVAL
fi
done
echo "::error::Timeout waiting for PR #$PR_NUMBER to merge"
exit 1
merge-develop-to-main:
needs: [wait-for-version-pr]
runs-on: ubuntu-latest
permissions:
contents: write
# Ensure only one merge operation runs at a time
concurrency:
group: main-branch-merge
cancel-in-progress: false
outputs:
merge_commit_sha: ${{ steps.merge.outputs.merge_commit_sha }}
previous_main_sha: ${{ steps.merge.outputs.previous_main_sha }}
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -45,10 +299,16 @@ jobs:
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Fast-forward main to develop
id: merge
run: |
set -e
git fetch origin main develop
# Store current main SHA for potential rollback
PREVIOUS_MAIN_SHA=$(git rev-parse origin/main)
echo "previous_main_sha=$PREVIOUS_MAIN_SHA" >> $GITHUB_OUTPUT
echo "Previous main SHA: $PREVIOUS_MAIN_SHA"
# Verify develop is ahead of main
MERGE_BASE=$(git merge-base origin/main origin/develop)
MAIN_SHA=$(git rev-parse origin/main)
@@ -63,83 +323,128 @@ jobs:
DEVELOP_SHA=$(git rev-parse origin/develop)
if [ "$MAIN_SHA" = "$DEVELOP_SHA" ]; then
echo "Main is already up to date with develop. Nothing to merge."
echo "merge_commit_sha=$MAIN_SHA" >> $GITHUB_OUTPUT
exit 0
fi
# Fast-forward merge develop into main
# Merge develop into main (create merge commit for revert capability)
git checkout main
git merge origin/develop --ff-only
git merge origin/develop --no-ff -m "Merge develop into main for release"
echo "Successfully fast-forwarded main to develop"
echo "Successfully merged develop into main"
git log origin/main..HEAD --oneline
git push origin main
# Push with error handling
if ! git push origin main; then
echo "::error::Failed to push merge commit to main"
exit 1
fi
echo "Successfully pushed merge commit to main"
run-unit-tests-linux:
# Store the new merge commit SHA
MERGE_COMMIT_SHA=$(git rev-parse HEAD)
echo "merge_commit_sha=$MERGE_COMMIT_SHA" >> $GITHUB_OUTPUT
echo "New main SHA: $MERGE_COMMIT_SHA"
verify-main-status-checks:
needs: [merge-develop-to-main]
runs-on: ubuntu-latest
permissions:
contents: write
actions: read
# Prevent multiple rollback operations from running concurrently
concurrency:
group: main-branch-verify-and-rollback
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
- name: Display build information
- name: Verify commit status via GitHub API
id: check-status
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Event: ${{ github.event_name }}"
echo "Jobs to run: ${{ github.event.inputs.jobs || 'build-windows,build-debian,build-arch,build-rhel' }}"
set -e
MERGE_COMMIT="${{ needs.merge-develop-to-main.outputs.merge_commit_sha }}"
echo "Checking status of commit: $MERGE_COMMIT"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
# Wait a moment for status checks to be registered
sleep 5
- name: Install Poetry
uses: snok/install-poetry@v1
# Get commit status using GitHub API
MAX_WAIT=300 # 5 minutes max wait for status checks to appear
SLEEP_INTERVAL=10
ELAPSED=0
- name: Install dependencies
while [ $ELAPSED -lt $MAX_WAIT ]; do
# Get combined status for the commit
STATUS_RESPONSE=$(gh api "repos/${{ github.repository }}/commits/${MERGE_COMMIT}/status" --jq '{state: .state, statuses: .statuses | length, total_count: .total_count}' || echo '{"state":"pending","statuses":0,"total_count":0}')
STATE=$(echo "$STATUS_RESPONSE" | jq -r '.state')
TOTAL_COUNT=$(echo "$STATUS_RESPONSE" | jq -r '.total_count')
echo "Commit status: state=$STATE, checks=$TOTAL_COUNT (${ELAPSED}s elapsed)"
if [ "$STATE" = "failure" ] || [ "$STATE" = "error" ]; then
echo "::error::Status checks failed on commit $MERGE_COMMIT"
gh api "repos/${{ github.repository }}/commits/${MERGE_COMMIT}/status" --jq '.statuses[] | select(.state == "failure" or .state == "error") | "- " + .context + ": " + .state'
exit 1
elif [ "$STATE" = "success" ]; then
echo "✓ All status checks passed on main branch"
exit 0
fi
sleep $SLEEP_INTERVAL
ELAPSED=$((ELAPSED + SLEEP_INTERVAL))
done
# If we get here, treat as success if no checks were registered
if [ "$TOTAL_COUNT" -eq 0 ]; then
echo "⚠ No status checks found for commit. Investigate."
exit 1
fi
echo "::warning::Status checks still pending after ${MAX_WAIT}s, ending workflow. Investigate status checks"
exit 1
- name: Handle status check failures with rollback
if: failure() && steps.check-status.outcome == 'failure'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry install
set -e
echo "::error::Status checks failed on main branch - initiating rollback"
- name: Run tests
run: |
poetry run pytest tests/ -v
run-unit-tests-windows:
needs: [merge-develop-to-main]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
# Fetch latest
git fetch origin main
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
# Get the merge commit that needs to be reverted
MERGE_COMMIT="${{ needs.merge-develop-to-main.outputs.merge_commit_sha }}"
echo "Reverting merge commit: $MERGE_COMMIT"
- name: Ensure Poetry is on PATH (Windows)
shell: pwsh
run: |
# Add Poetry user bin to PATH for subsequent steps in this job
$poetryPath = Join-Path $env:USERPROFILE ".local\bin"
Write-Output $poetryPath >> $Env:GITHUB_PATH
# Checkout main and create revert commit
git checkout main
git revert "$MERGE_COMMIT" --no-edit -m 1
- name: Install dependencies
run: |
poetry install
# Push the revert commit with error handling
if ! git push origin main; then
echo "::error::Failed to push revert commit"
exit 1
fi
echo "::error::Reverted merge commit $MERGE_COMMIT on main branch"
echo "::error::Workflow failed due to status check failures"
exit 1
- name: Run tests
run: |
poetry run pytest tests/ -v
build-windows:
needs: [run-unit-tests-linux, run-unit-tests-windows]
needs: [verify-main-status-checks]
if: ${{ contains(github.event.inputs.jobs, 'build-windows') }}
runs-on: windows-latest
steps:
@@ -148,10 +453,10 @@ jobs:
with:
ref: main
- name: Set up Python 3.12
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.13'
- name: Install Poetry
uses: snok/install-poetry@v1
@@ -176,77 +481,88 @@ jobs:
# Use the Windows spec file so packaging is consistent and reproducible
poetry run pyinstaller scripts/spec_scripts/android-file-handler-windows.spec
- name: Import GPG key
shell: pwsh
run: |
$env:GPG_TTY = "not a tty"
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
gpg --list-secret-keys
- name: Sign and hash Windows executable
shell: pwsh
run: |
$exePath = Get-ChildItem -Path dist -Filter "android-file-handler.exe" -Recurse | Select-Object -First 1 -ExpandProperty FullName
if (-not $exePath) {
Write-Error "Executable not found"
exit 1
}
Write-Output "Found executable: $exePath"
# Create temporary file for passphrase
$passphraseFile = New-TemporaryFile
try {
"${{ secrets.GPG_PASSPHRASE }}" | Out-File -FilePath $passphraseFile -Encoding ASCII -NoNewline
# Sign with GPG using passphrase file
gpg --batch --yes --passphrase-file "$passphraseFile" --detach-sign --armor "$exePath"
}
finally {
# Clean up passphrase file
if (Test-Path $passphraseFile) {
Remove-Item $passphraseFile -Force
}
}
# Generate SHA-256 hash
$hash = (Get-FileHash -Path "$exePath" -Algorithm SHA256).Hash.ToLower()
$hashFile = "dist/android-file-handler-windows.sha256"
"$hash $(Split-Path -Leaf $exePath)" | Out-File -FilePath $hashFile -Encoding ASCII -NoNewline
Write-Output "SHA-256: $hash"
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: windows-binary
path: |
dist/**/android-file-handler*.exe
dist/**/android-file-handler*.exe.asc
dist/android-file-handler.exe
dist/android-file-handler.exe.asc
dist/android-file-handler-windows.sha256
build-debian:
needs: [run-unit-tests-linux, run-unit-tests-windows]
needs: [verify-main-status-checks]
if: ${{ contains(github.event.inputs.jobs, 'build-debian') }}
permissions:
contents: read
packages: read
env:
DISTRO_TYPE: debian
runs-on: ubuntu-latest
container:
image: python:3.12-slim
image: ghcr.io/jmr-dev/android-file-handler-debian-builder:debian13-trixie
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Install system dependencies & gem fpm (include Tcl/Tk)
run: |
set -euo pipefail
apt-get update
# Install Tcl/Tk runtimes, dev headers and common X libraries required by tkinter
apt-get install -y --no-install-recommends \
curl git build-essential ruby ruby-dev gcc make zlib1g-dev ca-certificates python3-tk \
tcl8.6 tk8.6 tcl8.6-dev tk8.6-dev libx11-6 libxext6 libxrender1 libxcb1
# install pinned fpm to the system gem dir (will be available under gem env's EXECUTABLE DIRECTORY or /usr/local/bin)
gem install --no-document -v "${FPM_VERSION}" fpm
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
- name: Configure Poetry
- name: Build executable
run: |
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $GITHUB_ENV
export PATH="$HOME/.local/bin:$PATH"
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Install dependencies & build executable
run: |
export PATH="$HOME/.local/bin:$PATH"
poetry env use python3.12 || true
# Debug: show tkinter/_tkinter and Tcl library discovery in the Poetry venv
poetry run python -c 'import tkinter, _tkinter, sys; print("tkinter=", getattr(tkinter, "__file__", None)); print("_tkinter=", getattr(_tkinter, "__file__", None)); import tkinter as tk; print("TCL_LIBRARY=", tk.Tcl().eval("info library"))'
# Build distro-specific package layout using the build script via Poetry
# Container has Poetry and all dependencies pre-installed
poetry install --no-interaction
poetry run python scripts/build_package_linux.py
- name: Package .deb (fpm)
shell: bash
run: |
set -euo pipefail
export PATH="$HOME/.local/bin:$PATH"
VERSION="$(poetry version -s)"
PKG_DIR="pkg_dist_debian"
mkdir -p dist
# Debug listing
echo "Packaging from $PKG_DIR"
ls -la "$PKG_DIR" || true
@@ -263,84 +579,153 @@ jobs:
--after-install scripts/debian_postinst.sh \
-p "dist/android-file-handler_${VERSION}_amd64.deb" -C "$PKG_DIR" "${PKG_ITEMS[@]}"
- name: Import GPG key
shell: bash
run: |
export GPG_TTY=$(tty) || true
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
gpg --list-secret-keys
- name: Sign and hash Debian package
shell: bash
run: |
set -euo pipefail
DEB_FILE=$(find dist -name "android-file-handler_*.deb" -type f | head -n 1)
if [ -z "$DEB_FILE" ]; then
echo "Error: .deb file not found"
exit 1
fi
echo "Found package: $DEB_FILE"
# Create temporary file for passphrase
PASSPHRASE_FILE=$(mktemp)
trap "rm -f '$PASSPHRASE_FILE'" EXIT
# Write passphrase to temporary file
echo "${{ secrets.GPG_PASSPHRASE }}" > "$PASSPHRASE_FILE"
# Sign with GPG using passphrase file
gpg --batch --yes --passphrase-file "$PASSPHRASE_FILE" --detach-sign --armor "$DEB_FILE"
# Clean up passphrase file
rm -f "$PASSPHRASE_FILE"
# Generate SHA-256 hash
sha256sum "$DEB_FILE" | awk '{print $1 " " $2}' > dist/android-file-handler-debian.sha256
echo "SHA-256: $(cat dist/android-file-handler-debian.sha256)"
- name: Upload Debian .deb
uses: actions/upload-artifact@v4
with:
name: debian-package
path: |
dist/android-file-handler_*.deb
dist/android-file-handler_*.deb.asc
dist/android-file-handler-debian.sha256
pkg_dist_debian/**
build-arch:
needs: [run-unit-tests-linux, run-unit-tests-windows]
needs: [verify-main-status-checks]
if: ${{ contains(github.event.inputs.jobs, 'build-arch') }}
permissions:
contents: read
packages: read
env:
DISTRO_TYPE: arch
runs-on: ubuntu-latest
container:
image: archlinux:latest
steps:
- name: Install system dependencies (Arch) and system Ruby
run: |
set -euo pipefail
pacman -Syu --noconfirm
pacman -S --noconfirm ruby base-devel curl git tar ca-certificates tk tcl libx11 libxext libxrender libxcb
# Install fpm system-wide and pin version so fpm will be in /usr/in
gem install --no-document erb
gem install --no-document -v "${FPM_VERSION}" fpm --bindir /usr/bin
# persist system bindir to subsequent steps (usually already on PATH)
echo "/usr/local/bin" >> $GITHUB_PATH
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
python-version: '3.12'
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CI_CD_PAT }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
- name: Pull Docker image
run: docker pull ghcr.io/jmr-dev/android-file-handler-arch-builder:latest
- name: Configure Poetry
- name: Build executable inside container
run: |
echo 'export PATH="$HOME/bin:$PATH"' >> $GITHUB_ENV
export PATH="$HOME/bin:$PATH"
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
-e DISTRO_TYPE=${{ env.DISTRO_TYPE }} \
-e FPM_VERSION=${{ env.FPM_VERSION }} \
-e CI_CD=${{ env.CI_CD }} \
ghcr.io/jmr-dev/android-file-handler-arch-builder:latest \
sh -c "poetry install --no-interaction && poetry run python scripts/build_package_linux.py"
- name: Install dependencies & build executable
- name: Package pacman (fpm) inside container
run: |
export PATH="$HOME/bin:/usr/bin:$PATH"
# Use unified build script to produce pkg_dist_arch layout via Poetry
poetry run python scripts/build_package_linux.py
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
-e FPM_VERSION=${{ env.FPM_VERSION }} \
ghcr.io/jmr-dev/android-file-handler-arch-builder:latest \
sh -c 'set -euo pipefail && \
VERSION="$(poetry version -s)" && \
PKG_DIR="pkg_dist_arch" && \
mkdir -p dist && \
echo "Packaging from $PKG_DIR" && \
ls -la "$PKG_DIR" || true && \
ICON_PATH="$PKG_DIR/usr/share/icons/hicolor/256x256/apps/android-file-handler.png" && \
if [ -f "$ICON_PATH" ]; then \
fpm -s dir -t pacman -n android-file-handler -v "$VERSION" \
--architecture x86_64 \
-p "dist/android-file-handler-${VERSION}-1-x86_64.pkg.tar.zst" \
-C "$PKG_DIR" \
"usr/bin/android-file-handler" \
"usr/share/applications/android-file-handler.desktop" \
"usr/share/icons/hicolor/256x256/apps/android-file-handler.png"; \
else \
echo "Note: icon not present, packaging without icon" && \
fpm -s dir -t pacman -n android-file-handler -v "$VERSION" \
--architecture x86_64 \
-p "dist/android-file-handler-${VERSION}-1-x86_64.pkg.tar.zst" \
-C "$PKG_DIR" \
"usr/bin/android-file-handler" \
"usr/share/applications/android-file-handler.desktop"; \
fi'
- name: Package pacman (fpm)
- name: Import GPG key
shell: bash
run: |
export GPG_TTY=$(tty) || true
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
gpg --list-secret-keys
- name: Sign and hash Arch package
shell: bash
run: |
set -euo pipefail
export PATH="$HOME/.local/bin:/usr/bin:$PATH"
VERSION="$(poetry version -s)"
PKG_DIR="pkg_dist_arch"
mkdir -p dist
echo "Packaging from $PKG_DIR"
ls -la "$PKG_DIR" || true
ICON_PATH="$PKG_DIR/usr/share/icons/hicolor/256x256/apps/android-file-handler.png"
PKG_ITEMS=( "usr/bin/android-file-handler" "usr/share/applications/android-file-handler.desktop" )
if [ -f "$ICON_PATH" ]; then
PKG_ITEMS+=( "usr/share/icons/hicolor/256x256/apps/android-file-handler.png" )
else
echo "Note: icon not present, packaging without icon"
PKG_FILE=$(find dist -name "android-file-handler-*.pkg.tar.zst" -type f | head -n 1)
if [ -z "$PKG_FILE" ]; then
echo "Error: .pkg.tar.zst file not found"
exit 1
fi
echo "Found package: $PKG_FILE"
fpm -s dir -t pacman -n android-file-handler -v "$VERSION" \
--architecture x86_64 \
-p "dist/android-file-handler-${VERSION}-1-x86_64.pkg.tar.zst" -C "$PKG_DIR" "${PKG_ITEMS[@]}"
# Create temporary file for passphrase
PASSPHRASE_FILE=$(mktemp)
trap "rm -f '$PASSPHRASE_FILE'" EXIT
# Write passphrase to temporary file
echo "${{ secrets.GPG_PASSPHRASE }}" > "$PASSPHRASE_FILE"
# Sign with GPG using passphrase file
gpg --batch --yes --passphrase-file "$PASSPHRASE_FILE" --detach-sign --armor "$PKG_FILE"
# Clean up passphrase file
rm -f "$PASSPHRASE_FILE"
# Generate SHA-256 hash
sha256sum "$PKG_FILE" | awk '{print $1 " " $2}' > dist/android-file-handler-arch.sha256
echo "SHA-256: $(cat dist/android-file-handler-arch.sha256)"
- name: Upload Arch package
uses: actions/upload-artifact@v4
@@ -348,11 +733,12 @@ jobs:
name: arch-package
path: |
dist/*.pkg.tar.*
dist/android-file-handler-arch.sha256
pkg_dist_arch/**
build-rhel:
needs: [run-unit-tests-linux, run-unit-tests-windows]
needs: [verify-main-status-checks]
if: ${{ contains(github.event.inputs.jobs, 'build-rhel') }}
permissions:
contents: read
@@ -361,7 +747,10 @@ jobs:
DISTRO_TYPE: rhel
runs-on: ubuntu-latest
container:
image: ghcr.io/jmr-dev/android-file-handler-adb:v0.1.0
image: ghcr.io/jmr-dev/android-file-handler-rhel-builder:fedora42
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -371,8 +760,7 @@ jobs:
- name: Build RHEL package
run: |
set -euo pipefail
export CI_CD=true
export DISTRO_TYPE=rhel
# Container has Poetry and all dependencies pre-installed
poetry install --no-interaction
poetry run python scripts/build_package_linux.py
@@ -396,12 +784,49 @@ jobs:
fpm -s dir -t rpm -n android-file-handler -v "$VERSION" --architecture x86_64 --prefix /usr/bin --after-install scripts/rhel_postinst.sh -p "dist/android-file-handler-${VERSION}.x86_64.rpm" -C "$PKG_DIR" "${PKG_ITEMS[@]}"
- name: Import GPG key
shell: bash
run: |
export GPG_TTY=$(tty) || true
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
gpg --list-secret-keys
- name: Sign and hash RHEL package
shell: bash
run: |
set -euo pipefail
RPM_FILE=$(find dist -name "android-file-handler-*.rpm" -type f | head -n 1)
if [ -z "$RPM_FILE" ]; then
echo "Error: .rpm file not found"
exit 1
fi
echo "Found package: $RPM_FILE"
# Create temporary file for passphrase
PASSPHRASE_FILE=$(mktemp)
trap "rm -f '$PASSPHRASE_FILE'" EXIT
# Write passphrase to temporary file
echo "${{ secrets.GPG_PASSPHRASE }}" > "$PASSPHRASE_FILE"
# Sign with GPG using passphrase file
gpg --batch --yes --passphrase-file "$PASSPHRASE_FILE" --detach-sign --armor "$RPM_FILE"
# Clean up passphrase file
rm -f "$PASSPHRASE_FILE"
# Generate SHA-256 hash
sha256sum "$RPM_FILE" | awk '{print $1 " " $2}' > dist/android-file-handler-rhel.sha256
echo "SHA-256: $(cat dist/android-file-handler-rhel.sha256)"
- name: Upload RHEL artifacts
uses: actions/upload-artifact@v4
with:
name: rhel-package
path: |
dist/*.rpm
dist/*.rpm.asc
dist/android-file-handler-rhel.sha256
pkg_dist_rhel/**
@@ -432,10 +857,18 @@ jobs:
- name: Prepare release files
run: |
mkdir -p ./release-files
# Copy binary packages
find ./binaries -name "*.exe" -exec cp {} ./release-files/ \; || true
find ./binaries -name "*.deb" -exec cp {} ./release-files/ \; || true
find ./binaries -name "*.rpm" -exec cp {} ./release-files/ \; || true
find ./binaries -name "*.pkg.tar.*" -exec cp {} ./release-files/ \; || true
# Copy GPG signatures
find ./binaries -name "*.asc" -exec cp {} ./release-files/ \; || true
# Copy SHA-256 hashes
find ./binaries -name "*.sha256" -exec cp {} ./release-files/ \; || true
echo "Release files prepared:"
ls -lh ./release-files/
- name: Create Release
uses: softprops/action-gh-release@v1
+124 -112
View File
@@ -16,22 +16,64 @@ env:
CI_CD: true
jobs:
run-unit-tests-linux:
run-unit-tests-debian:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
container:
image: ghcr.io/jmr-dev/android-file-handler-debian-builder:debian13-trixie
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
poetry install --no-interaction
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Run tests
run: |
poetry run pytest tests/ -v
run-unit-tests-arch:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
container:
image: ghcr.io/jmr-dev/android-file-handler-arch-builder:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
poetry install
poetry install --no-interaction
- name: Run tests
run: |
poetry run pytest tests/ -v
run-unit-tests-rhel:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
container:
image: ghcr.io/jmr-dev/android-file-handler-rhel-builder:fedora42
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
poetry install --no-interaction
- name: Run tests
run: |
@@ -45,7 +87,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.13'
- name: Install Poetry
uses: snok/install-poetry@v1
@@ -70,16 +112,16 @@ jobs:
poetry run pytest tests/ -v
build-windows:
needs: [run-unit-tests-linux, run-unit-tests-windows]
needs: [run-unit-tests-windows]
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.12
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.13'
- name: Install Poetry
uses: snok/install-poetry@v1
@@ -113,65 +155,35 @@ jobs:
dist/android-file-handler.exe
build-debian:
needs: [run-unit-tests-linux, run-unit-tests-windows]
needs: [run-unit-tests-debian, run-unit-tests-arch, run-unit-tests-rhel]
permissions:
contents: read
packages: read
env:
DISTRO_TYPE: debian
runs-on: ubuntu-latest
container:
image: python:3.12-slim
image: ghcr.io/jmr-dev/android-file-handler-debian-builder:debian13-trixie
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Install system dependencies & gem fpm (include Tcl/Tk)
run: |
set -euo pipefail
apt-get update
# Install Tcl/Tk runtimes, dev headers and common X libraries required by tkinter
apt-get install -y --no-install-recommends \
curl git build-essential ruby ruby-dev gcc make zlib1g-dev ca-certificates python3-tk \
tcl8.6 tk8.6 tcl8.6-dev tk8.6-dev libx11-6 libxext6 libxrender1 libxcb1
# install pinned fpm to the system gem dir (will be available under gem env's EXECUTABLE DIRECTORY or /usr/local/bin)
gem install --no-document -v "${FPM_VERSION}" fpm
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
- name: Configure Poetry
- name: Build executable
run: |
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $GITHUB_ENV
export PATH="$HOME/.local/bin:$PATH"
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Install dependencies & build executable
run: |
export PATH="$HOME/.local/bin:$PATH"
poetry env use python3.12 || true
# Debug: show tkinter/_tkinter and Tcl library discovery in the Poetry venv
poetry run python -c 'import tkinter, _tkinter, sys; print("tkinter=", getattr(tkinter, "__file__", None)); print("_tkinter=", getattr(_tkinter, "__file__", None)); import tkinter as tk; print("TCL_LIBRARY=", tk.Tcl().eval("info library"))'
# Build distro-specific package layout using the build script via Poetry
# Container has Poetry and all dependencies pre-installed
poetry install --no-interaction
poetry run python scripts/build_package_linux.py
- name: Package .deb (fpm)
shell: bash
run: |
set -euo pipefail
export PATH="$HOME/.local/bin:$PATH"
VERSION="$(poetry version -s)"
PKG_DIR="pkg_dist_debian"
mkdir -p dist
# Debug listing
echo "Packaging from $PKG_DIR"
ls -la "$PKG_DIR" || true
@@ -184,7 +196,7 @@ jobs:
fi
fpm -s dir -t deb -n android-file-handler -v "$VERSION" \
--architecture amd64 --prefix /usr/local/bin --deb-user root --deb-group root \
--architecture amd64 --deb-user root --deb-group root \
--after-install scripts/debian_postinst.sh \
-p "dist/android-file-handler_${VERSION}_amd64.deb" -C "$PKG_DIR" "${PKG_ITEMS[@]}"
@@ -197,72 +209,70 @@ jobs:
pkg_dist_debian/**
build-arch:
needs: [run-unit-tests-linux, run-unit-tests-windows]
needs: [run-unit-tests-debian, run-unit-tests-arch, run-unit-tests-rhel]
permissions:
contents: read
packages: read
env:
DISTRO_TYPE: arch
runs-on: ubuntu-latest
container:
image: archlinux:latest
steps:
- name: Install system dependencies (Arch) and system Ruby
run: |
set -euo pipefail
pacman -Syu --noconfirm
pacman -S --noconfirm ruby base-devel curl git tar ca-certificates tk tcl libx11 libxext libxrender libxcb
# Install fpm system-wide and pin version so fpm will be in /usr/in
gem install --no-document erb
gem install --no-document -v "${FPM_VERSION}" fpm --bindir /usr/bin
# persist system bindir to subsequent steps (usually already on PATH)
echo "/usr/local/bin" >> $GITHUB_PATH
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
python-version: '3.12'
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CI_CD_PAT }} # Personal Access Token with read:packages
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
- name: Pull Docker image
run: docker pull ghcr.io/jmr-dev/android-file-handler-arch-builder:latest
- name: Configure Poetry
- name: Build executable inside container
run: |
echo 'export PATH="$HOME/bin:$PATH"' >> $GITHUB_ENV
export PATH="$HOME/bin:$PATH"
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
-e DISTRO_TYPE=${{ env.DISTRO_TYPE }} \
-e FPM_VERSION=${{ env.FPM_VERSION }} \
-e CI_CD=${{ env.CI_CD }} \
ghcr.io/jmr-dev/android-file-handler-arch-builder:latest \
sh -c "poetry install --no-interaction && poetry run python scripts/build_package_linux.py"
- name: Install dependencies & build executable
- name: Package pacman (fpm) inside container
run: |
export PATH="$HOME/bin:/usr/bin:$PATH"
# Use unified build script to produce pkg_dist_arch layout via Poetry
poetry run python scripts/build_package_linux.py
- name: Package pacman (fpm)
shell: bash
run: |
set -euo pipefail
export PATH="$HOME/.local/bin:/usr/bin:$PATH"
VERSION="$(poetry version -s)"
PKG_DIR="pkg_dist_arch"
mkdir -p dist
echo "Packaging from $PKG_DIR"
ls -la "$PKG_DIR" || true
ICON_PATH="$PKG_DIR/usr/share/icons/hicolor/256x256/apps/android-file-handler.png"
PKG_ITEMS=( "usr/bin/android-file-handler" "usr/share/applications/android-file-handler.desktop" )
if [ -f "$ICON_PATH" ]; then
PKG_ITEMS+=( "usr/share/icons/hicolor/256x256/apps/android-file-handler.png" )
else
echo "Note: icon not present, packaging without icon"
fi
fpm -s dir -t pacman -n android-file-handler -v "$VERSION" \
--architecture x86_64 --prefix /usr/bin \
-p "dist/android-file-handler-${VERSION}-1-x86_64.pkg.tar.zst" -C "$PKG_DIR" "${PKG_ITEMS[@]}"
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
-e FPM_VERSION=${{ env.FPM_VERSION }} \
ghcr.io/jmr-dev/android-file-handler-arch-builder:latest \
sh -c 'set -euo pipefail && \
VERSION="$(poetry version -s)" && \
PKG_DIR="pkg_dist_arch" && \
mkdir -p dist && \
echo "Packaging from $PKG_DIR" && \
ls -la "$PKG_DIR" || true && \
ICON_PATH="$PKG_DIR/usr/share/icons/hicolor/256x256/apps/android-file-handler.png" && \
if [ -f "$ICON_PATH" ]; then \
fpm -s dir -t pacman -n android-file-handler -v "$VERSION" \
--architecture x86_64 \
-p "dist/android-file-handler-${VERSION}-1-x86_64.pkg.tar.zst" \
-C "$PKG_DIR" \
"usr/bin/android-file-handler" \
"usr/share/applications/android-file-handler.desktop" \
"usr/share/icons/hicolor/256x256/apps/android-file-handler.png"; \
else \
echo "Note: icon not present, packaging without icon" && \
fpm -s dir -t pacman -n android-file-handler -v "$VERSION" \
--architecture x86_64 \
-p "dist/android-file-handler-${VERSION}-1-x86_64.pkg.tar.zst" \
-C "$PKG_DIR" \
"usr/bin/android-file-handler" \
"usr/share/applications/android-file-handler.desktop"; \
fi'
- name: Upload Arch package
uses: actions/upload-artifact@v4
@@ -273,7 +283,7 @@ jobs:
pkg_dist_arch/**
build-rhel:
needs: [run-unit-tests-linux, run-unit-tests-windows]
needs: [run-unit-tests-debian, run-unit-tests-arch, run-unit-tests-rhel]
permissions:
contents: read
packages: read
@@ -281,7 +291,10 @@ jobs:
DISTRO_TYPE: rhel
runs-on: ubuntu-latest
container:
image: ghcr.io/jmr-dev/android-file-handler-adb:v0.1.0
image: ghcr.io/jmr-dev/android-file-handler-rhel-builder:fedora42
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -289,8 +302,7 @@ jobs:
- name: Build RHEL package
run: |
set -euo pipefail
export CI_CD=true
export DISTRO_TYPE=rhel
# Container has Poetry and all dependencies pre-installed
poetry install --no-interaction
poetry run python scripts/build_package_linux.py
+3 -2
View File
@@ -133,10 +133,11 @@ The project uses GitHub Actions for multi-platform builds (`.github/workflows/re
- Do not recreate deleted files
- Do not change user-facing text unless asked
- Always run the application to test if it will run and have it run successfully before declaring an iteration complete
- Never use the squash merge strategy unless specifically instructed to do so
## Notes
- **ADB Binaries**: Stored in `src/platform-tools/` - do not modify or delete
- **Python Version**: Requires Python 3.12 (< 3.13)
- **ADB Binaries**: Stored in `src/platform-tools/` - do not modify or delete unless explictly instructed to
- **Python Version**: Requires Python 3.13 (< 3.14)
- **Package Mode**: Poetry is configured with `package-mode = false`
- **License**: First-run license agreement required on Windows
+10
View File
@@ -0,0 +1,10 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEaPAWyxYJKwYBBAHaRw8BAQdAZvH8TI491M3W7PCRrs3Iks4qsIMGFZ71UW4E
Di808m20OmFuZHJvaWQtZmlsZS1oYW5kbGVyIFJlbGVhc2UgQm90IDxqYXNvbi5y
b3NzODQxQGdtYWlsLmNvbT6IkwQTFgoAOxYhBAlZWbUAICc77jajXKVv3PRrBEqG
BQJo8BbLAhsDBQsJCAcCAiICBhUKCQgLAgQWAgMBAh4HAheAAAoJEKVv3PRrBEqG
FGIA/3wXwy2esmP0M5kVwyjoXvkxz9icqETxvWj613nVgTP0AQCErfBCae5gce2h
Ruw4g2a1dyvO+020t429qXv1T8XhCA==
=GOiu
-----END PGP PUBLIC KEY BLOCK-----
Generated
+454 -363
View File
File diff suppressed because it is too large Load Diff
+14 -14
View File
@@ -7,14 +7,14 @@ authors = [
]
license = { text = "MIT" }
readme = "README.md"
requires-python = "<3.13,>=3.12"
requires-python = ">=3.13, <3.15"
dependencies = ["requests>=2.32.4,<3.0.0", "platformdirs>4.0.0,<5.0.0"]
[tool.poetry.dependencies]
python = "<3.13,>=3.12"
requests = ">=2.32.4,<3.0.0"
platformdirs = ">4.0.0,<5.0.0"
urllib3 = ">=2.0.0,<3.0.0"
python = ">=3.13, <3.15"
requests = "^2.32.5"
platformdirs = "^4.5.0"
urllib3 = "^2.0"
[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
@@ -26,25 +26,25 @@ android-file-handler = "src.main:main"
[tool.poetry.group.dev.dependencies]
black = "^25.0.0"
flake8 = "^6.0.0"
mypy = "^1.5.0"
pre-commit = "^3.4.0"
black = "^25.9.0"
flake8 = "^7.3.0"
mypy = "^1.18.2"
pre-commit = "^4.3.0"
[tool.poetry.group.test.dependencies]
pytest = "^7.4.0"
pytest-mock = "^3.11.0"
pytest-cov = "^4.1.0"
pytest = "^8.4.2"
pytest-mock = "^3.15.1"
pytest-cov = "^7.0.0"
[tool.poetry.group.build.dependencies]
pyinstaller = "^6.1.0"
[tool.black]
line-length = 88
target-version = ['py312']
target-version = ['py313']
[tool.mypy]
python_version = "3.12"
python_version = "3.13"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
+2 -2
View File
@@ -15,7 +15,7 @@ class DistroType(Enum):
RHEL = "rhel"
def run_command(cmd: list[str], check: bool = True, working_dir: str = None) -> subprocess.CompletedProcess:
def run_command(cmd: list[str], check: bool = True, working_dir: str | None = None) -> subprocess.CompletedProcess:
"""Run command and handle errors."""
print(f"Running: {' '.join(cmd)}")
try:
@@ -172,7 +172,7 @@ StartupNotify=true
print(f" (missing) {item_path}")
def main():
def main() -> None:
# Get project root (parent of scripts directory)
project_root = Path(__file__).parent.parent.resolve()
print(f"Project root: {project_root}")
+99
View File
@@ -0,0 +1,99 @@
# Dockerfile for Arch Linux build environment
# Automates all setup steps from the build-arch workflow job
#
# Usage:
# docker build -f scripts/docker/Dockerfile.arch -t android-file-handler-arch-builder .
# docker run -v $(pwd):/workspace -w /workspace android-file-handler-arch-builder
# Use latest Arch Linux base image (rolling release)
# For reproducibility, pin to a specific date tag like: archlinux:base-20251016
FROM archlinux:latest
# Set build argument for fpm version (can be overridden at build time)
ARG FPM_VERSION=1.16.0
# Install system dependencies (Arch) including Python build dependencies
RUN pacman -Syu --noconfirm \
ruby \
ruby-bundler \
ruby-rake \
base-devel \
curl \
git \
tar \
ca-certificates \
ca-certificates-utils \
tk \
tcl \
libx11 \
libxext \
libxrender \
libxcb \
gcc \
make \
zlib \
bzip2 \
readline \
sqlite \
openssl \
libffi \
wget \
xz \
patch && \
update-ca-trust && \
pacman -Scc --noconfirm
# Install erb gem (required for fpm on Arch)
RUN gem install --no-document erb
# Install fpm and create symlink so it's accessible in PATH
# Note: Gems install to user directory on Arch, so we use Gem.user_dir
RUN gem install --no-document -v "${FPM_VERSION}" fpm && \
GEM_BIN_DIR=$(ruby -e 'puts Gem.user_dir')/bin && \
echo "Gem bin directory: ${GEM_BIN_DIR}" && \
ln -sf "${GEM_BIN_DIR}/fpm" /usr/local/bin/fpm && \
/usr/local/bin/fpm --version
# Install pyenv
ENV PYENV_ROOT="/root/.pyenv"
ENV PATH="$PYENV_ROOT/bin:$PATH"
RUN git clone https://github.com/pyenv/pyenv.git /root/.pyenv
# Install Python 3.12 via pyenv with tkinter support
# The tk and tcl packages must be installed before this step for _tkinter to be compiled
RUN eval "$(pyenv init -)" && \
LDFLAGS="-L/usr/lib" \
CPPFLAGS="-I/usr/include" \
PYTHON_CONFIGURE_OPTS="--enable-shared" \
pyenv install 3.13 && \
pyenv global 3.13 && \
pyenv rehash
# Update PATH to include pyenv shims
ENV PATH="/root/.pyenv/shims:$PATH"
# Verify Python has tkinter support
RUN python3 -c "import tkinter; import _tkinter; print('tkinter support verified')" || \
(echo "ERROR: Python was built without tkinter support" && exit 1)
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 - --yes
# Add Poetry to PATH
ENV PATH="/root/.local/bin:$PATH"
# Verify Poetry installation
RUN poetry --version
# Set working directory
WORKDIR /workspace
# Set environment variables for build
ENV CI_CD=true
ENV DISTRO_TYPE=arch
# Default command runs the build script
CMD ["sh", "-c", "poetry install --no-interaction && poetry run python scripts/build_package_linux.py"]
+87
View File
@@ -0,0 +1,87 @@
# Dockerfile for Debian build environment
# Automates all setup steps from the build-debian workflow job
#
# Usage:
# docker build -f scripts/docker/Dockerfile.debian -t android-file-handler-debian-builder .
# docker run -v $(pwd):/workspace -w /workspace android-file-handler-debian-builder
# Use Debian 13 "Trixie" (latest stable release)
FROM debian:13
# Set build argument for fpm version (can be overridden at build time)
ARG FPM_VERSION=1.16.0
# Install system dependencies including Python build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
git \
build-essential \
ruby \
ruby-dev \
gcc \
make \
zlib1g-dev \
ca-certificates \
tcl-dev \
tk-dev \
libx11-6 \
libxext6 \
libxrender1 \
libxcb1 \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libffi-dev \
wget \
tar \
liblzma-dev \
patch && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install pyenv
ENV PYENV_ROOT="/root/.pyenv"
ENV PATH="$PYENV_ROOT/bin:$PATH"
RUN git clone https://github.com/pyenv/pyenv.git /root/.pyenv
# Install Python 3.12 via pyenv with tkinter support
# The tk8.6-dev package must be installed before this step for _tkinter to be compiled
RUN eval "$(pyenv init -)" && \
LDFLAGS="-L/usr/lib/x86_64-linux-gnu" \
CPPFLAGS="-I/usr/include/tcl8.6" \
PYTHON_CONFIGURE_OPTS="--enable-shared" \
pyenv install 3.13 && \
pyenv global 3.13 && \
pyenv rehash
# Update PATH to include pyenv shims
ENV PATH="/root/.pyenv/shims:$PATH"
# Verify Python has tkinter support
RUN python3 -c "import tkinter; import _tkinter; print('tkinter support verified')" || \
(echo "ERROR: Python was built without tkinter support" && exit 1)
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 - --yes
# Add Poetry to PATH
ENV PATH="/root/.local/bin:$PATH"
# Verify Poetry installation
RUN poetry --version
# Install fpm
RUN gem install --no-document -v "${FPM_VERSION}" fpm
# Set working directory
WORKDIR /workspace
# Set environment variables for build
ENV CI_CD=true
ENV DISTRO_TYPE=debian
# Default command runs the build script
CMD ["sh", "-c", "poetry install --no-interaction && poetry run python scripts/build_package_linux.py"]
+20 -6
View File
@@ -5,12 +5,13 @@
# docker build -f scripts/docker/Dockerfile.rhel -t android-file-handler-rhel-builder .
# docker run -v $(pwd):/workspace -w /workspace android-file-handler-rhel-builder
FROM fedora:latest
FROM fedora:42
# Set build argument for fpm version (can be overridden at build time)
ARG FPM_VERSION=1.16.0
# Install system dependencies
# Install system dependencies including tk8-devel for Python tkinter support
# Using tk8 (version 8.6) instead of tk (version 9.0) for Python 3.12 compatibility
RUN dnf -y update && \
dnf -y install \
gcc \
@@ -33,7 +34,12 @@ RUN dnf -y update && \
gcc-c++ \
patch \
which \
xz-devel && \
xz-devel \
tk-devel \
tcl-devel \
libX11-devel \
libXext-devel \
libXrender-devel && \
dnf clean all
# Install pyenv
@@ -42,15 +48,23 @@ ENV PATH="$PYENV_ROOT/bin:$PATH"
RUN git clone https://github.com/pyenv/pyenv.git /root/.pyenv
# Install Python 3.12 via pyenv
# Install Python 3.12 via pyenv with tkinter support
# The tk8-devel package must be installed before this step for _tkinter to be compiled
RUN eval "$(pyenv init -)" && \
pyenv install 3.12.0 && \
pyenv global 3.12.0 && \
LDFLAGS="-L/usr/lib64" \
CPPFLAGS="-I/usr/include" \
PYTHON_CONFIGURE_OPTS="--enable-shared" \
pyenv install 3.13 && \
pyenv global 3.13 && \
pyenv rehash
# Update PATH to include pyenv shims
ENV PATH="/root/.pyenv/shims:$PATH"
# Verify Python has tkinter support
RUN python3 -c "import tkinter; import _tkinter; print('tkinter support verified')" || \
(echo "ERROR: Python was built without tkinter support" && exit 1)
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 - --yes