summarylogtreecommitdiffstats
path: root/.woodpecker.yaml
blob: e3a815e429433026fc2d685f6157c57bc4f27244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Woodpecker CI definition
# - bump version to latest upstream release
# - test binary run
# - push updates to codeberg repo
# https://codeberg.org/tuxxx/sparrow-wallet

when:
  - event: cron
    cron: daily-update
  - event: manual
  - event: pull_request

steps:
  - name: build-and-push
    image: archlinux:latest
    environment:
      CODEBERG_TOKEN:
        from_secret: codeberg_token
    commands:
      # Install all required tools
      - pacman -Syu --noconfirm --needed git base-devel devtools nvchecker pacman-contrib namcap sudo gnupg
      # Allow broken git ownerships
      - git config --global --add safe.directory "$(pwd)"
      # Create build user
      - useradd -m -G wheel builduser
      - "echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
      - chown -R builduser:builduser .
      # Configure git for builduser
      - sudo -u builduser git config --global user.name "Woodpecker CI"
      - sudo -u builduser git config --global user.email "ci@codeberg.org"
      # Run update check
      - chmod +x update.sh
      - BEFORE_COMMIT=$(git rev-parse HEAD)
      - TERM=linux sudo -u builduser ./update.sh
      - AFTER_COMMIT=$(git rev-parse HEAD)
      # Run PKGBUILD Linter (namcap)
      - |
        # Run namcap and save output
        echo "Running namcap check..."
        namcap -i PKGBUILD > /tmp/namcap_output.txt 2>&1 || true
        
        # Check if namcap produced any output
        if [ ! -s /tmp/namcap_output.txt ]; then
          echo "✅ PKGBUILD is clean - no namcap issues found"
          echo ""
          echo "=== namcap output ==="
          echo "(no output - PKGBUILD passed all checks)"
          echo "===================="
        else
          # Check for critical errors
          if grep -q " E: " /tmp/namcap_output.txt; then
            echo "❌ Critical namcap errors detected!"
            echo "Critical errors:"
            grep " E: " /tmp/namcap_output.txt
            echo ""
            echo "=== Full namcap output ==="
            cat /tmp/namcap_output.txt
            echo "=========================="
            exit 1
          else
            echo "✅ No critical namcap errors found"
            echo ""
            echo "=== Full namcap output ==="
            cat /tmp/namcap_output.txt
            echo "=========================="
          fi
        fi
      # Process results based on event type
      - |
        echo "Pipeline Event: ${CI_PIPELINE_EVENT}"
        if [ "$BEFORE_COMMIT" = "$AFTER_COMMIT" ]; then
          echo "No updates available - package is already current"
          echo "Result: NO_UPDATE_NEEDED"
          if [ "$CI_PIPELINE_EVENT" = "pull_request" ]; then
            echo "PR Test: No updates to test, proceeding with current package build"
          else
            exit 0
          fi
        fi
      # Build and test package (always runs)
      - echo "Building and testing package"
      - sudo -u builduser gpg --recv-keys D4D0D3202FC06849A257B38DE94618334C674B40
      - sudo -u builduser makepkg -si --noconfirm
      - sudo -u builduser sparrow --version
      # Conditional push (only for cron and manual)
      - |
        if [ "$CI_PIPELINE_EVENT" = "cron" ] || [ "$CI_PIPELINE_EVENT" = "manual" ]; then
          echo "Push allowed for event: ${CI_PIPELINE_EVENT}"
          git remote set-url origin "https://woodpecker:$${CODEBERG_TOKEN}@${CI_REPO_CLONE_URL#https://}"
          git push origin HEAD
          echo "Pipeline completed successfully: Package updated and deployed"
        else
          echo "Push skipped for event: ${CI_PIPELINE_EVENT} (test-only mode)"
          echo "Pipeline completed successfully: Package tested successfully"
        fi