8000 fix: resolve AUR and release workflow failures by ahmet-cetinkaya · Pull Request #282 · ahmet-cetinkaya/whph · GitHub
[go: up one dir, main page]

Skip to content

fix: resolve AUR and release workflow failures - #282

Merged
ahmet-cetinkaya merged 62 commits into
mainfrom
ci/fix-aur-release
May 25, 2026
Merged

ahmet-cetinkaya merged 62 commits into
mainfrom
ci/fix-aur-release

Conversation

@ahmet-cetinkaya
Copy link
Copy Markdown
Owner

🚀 Motivation and Context

The release workflow was consistently failing in the update-aur, update-nix, and update-flathub jobs. These jobs update their respective package repositories (AUR, Nix, Flathub) and push submodule pointer changes back to the main repository. Multiple critical issues prevented successful releases.

⚙️ Implementation Details

This fix addresses multiple interconnected issues:

  1. Git SSH Authentication: The AUR update job runs in an archlinux container and requires SSH authentication to push to the AUR. The SSH setup was failing because the GIT_SSH_COMMAND environment variable wasn't persisting across workflow steps. Moved SSH configuration to job-level environment variables.

  2. Git Push Race Conditions: All three update jobs (update-aur, update-nix, update-flathub) were running in parallel and attempting to push submodule pointer changes to the same parent repository simultaneously. This caused 'failed to push some refs' errors. Restructured job dependencies to run sequentially: aur → nix → flathub.

  3. Unstaged/Untracked File Conflicts: The jobs were failing during git pull operations due to unstaged and untracked files in the working directory. Implemented comprehensive handling that stashes both tracked and untracked files before pull operations and discards them afterward (they're temporary build artifacts).

  4. Downloaded Source Artifacts: The AUR update script downloads release artifacts to compute checksums but these files remained in the working directory, causing git status checks to fail. Added cleanup commands to remove these files after checksum generation.

  5. Release Asset Availability: The jobs were attempting to update before release assets were fully propagated to GitHub's CDN. Implemented smart waiting logic that polls for asset availability instead of using fixed delays.

📋 Checklist for Reviewer

  • Tests passed locally.
  • Commit history is clean and descriptive.
  • Documentation updated (if applicable).
  • Code quality standards were met (e.g., linter passed).

🔗 Related

Closes #[if applicable]

ahmet-cetinkaya and others added 22 commits May 25, 2026 02:35
Change update-aur job to exclude submodules during initial checkout,
then manually initialize AUR submodule after SSH agent setup.

Root cause: actions/checkout attempted to clone AUR submodule via SSH
before SSH keys and known_hosts were available, causing "Host key
verification failed" errors.

Changes:
- Set submodules: false in update-aur checkout step
- Add ssh-keyscan to populate aur.archlinux.org in known_hosts
- Manually initialize AUR submodule after SSH setup

Fixes workflow failure in update-aur job where AUR submodule clone
failed during recursive submodule checkout.
…iner

The webfactory/ssh-agent action doesn't work properly with container-based
workflows because the SSH agent socket is not accessible inside containers.

Changes:
- Remove webfactory/ssh-agent action from update-aur job
- Add manual SSH setup step that runs inside the archlinux container
- Write SSH private key from secret to file with proper permissions
- Configure SSH to use the AUR key for aur.archlinux.org host
- Add known_hosts entry for AUR
- Test SSH connection before proceeding

This ensures SSH authentication works within the container environment
required for AUR package operations.
Git was failing to use the SSH config file when cloning submodules,
resulting in "Permission denied (publickey)" errors despite successful
SSH connection tests.

Changes:
- Use GIT_SSH_COMMAND environment variable to explicitly specify SSH
  key and options for Git operations
- Fix SSH config EOF marker to prevent variable expansion issues
- Change AUR test command from 'uname' to 'help' (uname is invalid on AUR)

This ensures Git uses the correct SSH key when cloning AUR submodules
inside the container environment.
Replace verbose 'help' command with silent 'list-repos' test.
Redirect all output to /dev/null and only show success message.

This makes workflow logs much cleaner while still verifying
SSH connectivity to AUR.
Prevent checkout failures in update-nix and update-flathub jobs by
excluding the AUR submodule that requires SSH authentication.

Changes:
- Set submodules: false for both jobs
- Manually initialize only required submodules:
  - update-nix: packages/acore-scripts
  - update-flatpak: fdroid, flathub, flatpak-flutter, shared-modules
- Skip packaging/aur submodule that needs SSH access

This allows non-AUR jobs to run without SSH setup while ensuring
each job only initializes the submodules it actually needs.
Instead of failing when release hash doesn't match PKGBUILD, automatically
update the PKGBUILD with the new hash. This handles common scenario where
releases are recreated during development.

Changes:
- Rename step from 'Verify checksums' to 'Verify and update checksums'
- Replace exit 1 on hash mismatch with automatic PKGBUILD update
- Use sed to update sha256sums line with new computed hash
- Log the change for debugging and transparency

This makes the AUR update workflow more robust by automatically handling
release recreations without manual intervention.
Replace unconditional 3-minute sleep with smart asset availability check.

Changes:
- Check if release assets exist before waiting
- If assets ready: proceed immediately (0s wait)
- If assets not ready: wait 2 minutes instead of 3
- Retry after wait and report status
- Better logging for debugging

This improves workflow speed when assets are ready quickly while
still providing sufficient wait time for GitHub's CDN propagation.
Fix two critical issues causing job failures:

1. update-aur job:
   - Add packages/acore-scripts submodule initialization
   - update_aur.sh depends on logger.sh from acore-scripts
   - Without this, script fails with "No such file or directory"

2. update_nix.sh script:
   - Handle git pull --rebase failures gracefully
   - nix flake update creates uncommitted .scratch files
   - When rebase fails, push changes directly instead of failing
   - Use --no-recurse-submodules flags for git operations

These fixes ensure all release jobs complete successfully.
The update_flathub.sh script depends on logger.sh from acore-scripts
but the workflow wasn't initializing that submodule.

Changes:
- Add packages/acore-scripts to update-flathub job submodule initialization

This fixes the "No such file or directory" error for logger.sh
in the update_flathub script.
Fix critical issues causing update-aur and update-flathub failures:

1. update-aur SSH authentication:
   - Move GIT_SSH_COMMAND to job-level environment variables
   - This ensures SSH key configuration persists across steps
   - Fix update_aur.sh to not override existing GIT_SSH_COMMAND
   - Previously script overwrote the SSH key path, causing permission errors

2. update-flathub git rebase conflicts:
   - Handle git pull --rebase failures gracefully
   - Abort failed rebases and push directly instead of failing
   - Clean up rebase state before retrying push

These fixes ensure all release jobs handle git operations robustly
without failing on authentication or merge conflicts.
Apply the same graceful rebase failure handling that was added to
the update-flathub job. The AUR job was also failing with
'cannot pull with rebase: You have unstaged changes'.

Changes:
- Wrap git pull --rebase in error handling
- Abort failed rebases and push directly instead of failing
- Use --no-edit flag for cleaner rebase behavior

This ensures the AUR update job completes successfully even when
git encounters conflicts during rebase operations.
The updpkgsums command downloads the release artifact (tar.gz) to
compute checksums. This file remains in the working directory and
causes 'git status -s' to return non-empty, triggering the
'No changes to commit' exit path even though PKGBUILD and .SRCINFO
have been updated.

Changes:
- Add cleanup command after .SRCINFO generation
- Remove whph-v*.tar.gz files before git status check

This ensures the script correctly identifies when there are actual
changes to commit and continues with the AUR update process.
All three update jobs (update-flathub, update-nix, update-aur) were
running in parallel and trying to push to the same parent repository
simultaneously. This created a race condition where only one job
would succeed and the others would fail with 'failed to push some refs'.

Changes:
- Make jobs run sequentially: update-flathub → update-nix → update-aur
- update-nix now needs: [release, update-flathub]
- update-aur now needs: [release, update-nix]
- Simplified git push handling (no longer need complex rebase fallback logic)
- Remove forced push attempts that could cause conflicts

Now each job waits for the previous one to complete, ensuring clean
git operations without conflicting pushes to the parent repository.
Update job dependency chain to follow the correct order:
1. update-aur (runs first after release)
2. update-nix (waits for aur)
3. update-flathub (waits for nix, runs last)

This ensures proper sequential execution and avoids git push
race conditions when updating submodule pointers.
The jobs are failing with 'cannot pull with rebase: You have unstaged
changes' because there are files from earlier operations or submodule
initialization that remain untracked or modified.

Changes:
- Check for unstaged changes (excluding our staged submodule changes)
- Stash them before pulling
- Fallback to merge pull if rebase fails
- Restore stashed changes after pull
- Apply this pattern to all three jobs: AUR, Nix, Flathub

This ensures git operations succeed regardless of the working directory
state from previous steps.
The issue was that git stash without -u flag only stashes tracked files,
leaving untracked files in the working directory. When git pull tries to
merge, it fails because the untracked files conflict with incoming changes.

Changes:
- Use 'git stash push -u' to include untracked files
- Don't restore stash with 'git stash pop' (causes merge conflicts)
- Instead, drop the stash after pull (these are temporary build files)
- Apply to all three update jobs: AUR, Nix, Flathub

The stashed files are temporary artifacts from build processes, not
actual work that needs to be preserved. By stashing them for the pull
and then discarding them, we ensure clean merges without conflicts.
@ahmet-cetinkaya ahmet-cetinkaya added the bug Something isn't working label May 25, 2026
@ahmet-cetinkaya ahmet-cetinkaya self-assigned this May 25, 2026
The update-flathub job was initializing 5 submodules but only needs 2:
- packages/acore-scripts (for update_flathub.sh logger)
- packaging/flatpak/flathub (the target submodule to update)

Removed unnecessary initialization of:
- packaging/fdroid (not used by flathub job)
- packaging/flatpak/flatpak-flutter (not used by flathub job)
- packaging/flatpak/shared-modules (not used by flathub job)

This reduces job initialization time and network overhead.
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates subproject commits, bumps the Nix package version to 0.22.3, and enhances the AUR and Nix update scripts with improved cleanup and git synchronization logic. The review feedback identifies several critical issues in the update_nix.sh script, specifically regarding the new stashing logic. Key concerns include an ineffective grep filter due to path mismatches and regex syntax errors, an incorrect git stash drop command that could lead to data loss for local users, and the unnecessary suppression of error messages during git operations. Improvements were suggested to simplify the status check and ensure safe, correct stash management.

Comment thread scripts/update_nix.sh Outdated
git push

# Handle any unstaged changes before pulling (including untracked files)
if [[ -n $(git status -s | grep -v "$FLAKE_FILE\|$NIX_DIR/flake.lock") ]]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The grep filter is ineffective and contains several issues:

  1. Path Mismatch: $FLAKE_FILE and $NIX_DIR are absolute paths, while git status -s returns paths relative to the repository root. The filter will fail to match, meaning it won't actually exclude these files.
  2. Regex Syntax: The pipe | is not escaped, so in standard grep it is treated as a literal character rather than an OR operator. It should be \| or use grep -E.
  3. Redundancy: Since the Nix changes were already committed on line 89, they will not appear in git status anyway.
  4. Data Loss Risk: The subsequent git stash drop (line 106) will permanently delete any changes caught by this block. If a developer runs this locally with other work-in-progress, their work will be lost.

If the goal is to stash any other remaining changes to ensure a clean pull, a simple check for a non-empty status is sufficient.

Suggested change
if [[ -n $(git status -s | grep -v "$FLAKE_FILE\|$NIX_DIR/flake.lock") ]]; then
if [[ -n $(git status -s) ]]; then

Comment thread scripts/update_nix.sh Outdated
Comment on lines +105 to +107
if git stash list | grep -q "Temporary stash before rebase"; then
git stash drop "Temporary stash before rebase" || true
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The git stash drop command is used incorrectly here:

  1. Syntax Error: It does not accept a message string as an argument; it requires a stash reference like stash@{0}. The current command will fail with an error.
  2. Destructive Operation: Dropping the stash without restoring it (git stash pop) is a destructive operation. While intended to clean up temporary artifacts in CI, this script can be run locally. If a developer has uncommitted work in other files, this logic will permanently delete their changes.

If these are strictly temporary build artifacts, it is safer to use git clean -fd on specific known artifact paths or use git stash pop to restore the workspace state after the pull.

Suggested change
if git stash list | grep -q "Temporary stash before rebase"; then
git stash drop "Temporary stash before rebase" || true
fi
# Clean up stash (drop the latest stash created at line 94)
if git stash list | grep -q "Temporary stash before rebase"; then
git stash drop stash@{0} || true
fi

Comment thread scripts/update_nix.sh Outdated
fi

# Pull with rebase, fallback to merge if it fails
if ! git pull --rebase --no-recurse-submodules --no-edit 2>/dev/null; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Suppressing stderr with 2>/dev/null makes it difficult to diagnose why a git pull might have failed (e.g., network issues, authentication errors, or complex conflicts). It is generally better to allow the error output to be visible in the logs for troubleshooting.

Suggested change
if ! git pull --rebase --no-recurse-submodules --no-edit 2>/dev/null; then
if ! git pull --rebase --no-recurse-submodules --no-edit; then

The flathub submodule has a nested submodule (shared-modules) that is
required by the flathub manifest. Without initializing this nested
submodule, the flathub build will fail.

Changes:
- Initialize flathub's shared-modules submodule after cloning flathub
- Change back to GITHUB_WORKSPACE after initialization
- Only initialize what's needed: acore-scripts, flathub, and its nested shared-modules

This ensures all required dependencies are available for the flathub
manifest update process.
- Simplify untracked files check (remove broken grep filter with absolute paths)
- Remove stderr suppression on git pull for better debugging
- Fix git stash drop syntax to use reference (stash@{0}) instead of message string
Critical fixes:
- Fix stash drop to use message-based reference instead of stash@{0}
  Prevents accidentally dropping wrong stash when multiple exist

Important fixes:
- Add rebase state check before aborting (check for .git/rebase-* files)
- Add SSH key masking in workflow to prevent log exposure
- Add explicit error handling for ssh-keyscan and submodule init
- Log nix fallback explicitly when nix-prefetch-url fails

Medium priority fixes:
- Add comment explaining 2-minute wait for GitHub CDN propagation
- Fix stash drop in both workflow locations (aur and flathub jobs)

Files modified:
- .github/workflows/release.yml: SSH masking, rebase checks, error handling
- scripts/update_nix.sh: Stash reference, nix fallback log, rebase check
- scripts/update_aur.sh: Explicit ssh-keyscan error handling
Extracts duplicated pull-with-rebase-fallback logic into a reusable function:
- Creates scripts/git_helpers.sh with git_pull_with_fallback function
- Supports optional filter pattern to exclude paths from stash check
- Updates workflow to use shared function in aur and flathub jobs
- Updates update_nix.sh to use shared function

Benefits:
- Reduces code duplication across 3 locations
- Centralizes git pull logic for easier maintenance
- Ensures consistent behavior across all update jobs
- Net reduction: 33 lines of code

Files:
- scripts/git_helpers.sh (new)
- .github/workflows/release.yml (simplified)
- scripts/update_nix.sh (simplified)
ahmet-cetinkaya and others added 28 commits May 25, 2026 01:47
The --strategy-option theirs syntax is incorrect for git merge.
Changed to:
- Fetch first: git fetch origin <branch>
- Then merge with proper flags: git merge -X theirs -X patience

This ensures the merge strategy is correctly applied when handling
divergent branches that were created before a release.
@ahmet-cetinkaya
ahmet-cetinkaya merged commit 05cb7a3 into main May 25, 2026
@ahmet-cetinkaya
ahmet-cetinkaya deleted the ci/fix-aur-release branch May 28, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0