|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ['v*'] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + name: Test (${{ matrix.os }}) |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + strategy: |
| 15 | + fail-fast: true |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest, macos-latest] |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - uses: actions/setup-go@v5 |
| 22 | + with: |
| 23 | + go-version-file: go.mod |
| 24 | + |
| 25 | + - name: Vet |
| 26 | + run: go vet ./... |
| 27 | + |
| 28 | + - name: Build all binaries |
| 29 | + run: make build |
| 30 | + |
| 31 | + - name: Unit tests |
| 32 | + run: go test -parallel 4 -count=1 -timeout 120s ./tests/ ./pkg/beacon/ |
| 33 | + |
| 34 | + build: |
| 35 | + name: Build (${{ matrix.goos }}/${{ matrix.goarch }}) |
| 36 | + needs: test |
| 37 | + runs-on: ${{ matrix.runner }} |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + include: |
| 41 | + - goos: linux |
| 42 | + goarch: amd64 |
| 43 | + runner: ubuntu-latest |
| 44 | + - goos: linux |
| 45 | + goarch: arm64 |
| 46 | + runner: ubuntu-latest |
| 47 | + - goos: darwin |
| 48 | + goarch: amd64 |
| 49 | + runner: macos-latest |
| 50 | + - goos: darwin |
| 51 | + goarch: arm64 |
| 52 | + runner: macos-latest |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - uses: actions/setup-go@v5 |
| 57 | + with: |
| 58 | + go-version-file: go.mod |
| 59 | + |
| 60 | + - name: Build release binaries |
| 61 | + env: |
| 62 | + GOOS: ${{ matrix.goos }} |
| 63 | + GOARCH: ${{ matrix.goarch }} |
| 64 | + CGO_ENABLED: '0' |
| 65 | + run: | |
| 66 | + VERSION=${GITHUB_REF_NAME} |
| 67 | + LDFLAGS="-s -w -X main.version=${VERSION}" |
| 68 | + BINS="daemon pilotctl gateway registry beacon rendezvous nameserver" |
| 69 | + mkdir -p dist |
| 70 | + for bin in $BINS; do |
| 71 | + echo "Building $bin for ${{ matrix.goos }}/${{ matrix.goarch }}..." |
| 72 | + go build -ldflags "$LDFLAGS" -o dist/$bin ./cmd/$bin |
| 73 | + done |
| 74 | +
|
| 75 | + - name: Smoke test binaries |
| 76 | + if: matrix.goos == 'linux' && matrix.goarch == 'amd64' || matrix.goos == 'darwin' |
| 77 | + run: | |
| 78 | + echo "=== Binary smoke tests ===" |
| 79 | + for bin in dist/*; do |
| 80 | + name=$(basename $bin) |
| 81 | + # Verify it's a valid executable |
| 82 | + file $bin |
| 83 | + # Version flag check (all binaries should accept -h without crashing) |
| 84 | + timeout 5 $bin -h 2>&1 || true |
| 85 | + echo " ✓ $name" |
| 86 | + done |
| 87 | +
|
| 88 | + echo "" |
| 89 | + echo "=== Registry start/stop test ===" |
| 90 | + dist/registry -addr 127.0.0.1:0 & |
| 91 | + REG_PID=$! |
| 92 | + sleep 1 |
| 93 | + kill $REG_PID 2>/dev/null && echo " ✓ registry starts and stops cleanly" |
| 94 | +
|
| 95 | + echo "" |
| 96 | + echo "=== Daemon help test ===" |
| 97 | + dist/daemon -h 2>&1 | head -5 |
| 98 | + echo " ✓ daemon shows help" |
| 99 | +
|
| 100 | + echo "" |
| 101 | + echo "=== pilotctl version test ===" |
| 102 | + dist/pilotctl version 2>&1 || dist/pilotctl -h 2>&1 | head -3 |
| 103 | + echo " ✓ pilotctl responds" |
| 104 | +
|
| 105 | + - name: Package archive |
| 106 | + run: | |
| 107 | + ARCHIVE="pilot-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz" |
| 108 | + tar -czf $ARCHIVE -C dist . |
| 109 | + echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV |
| 110 | +
|
| 111 | + - name: Upload artifact |
| 112 | + uses: actions/upload-artifact@v4 |
| 113 | + with: |
| 114 | + name: pilot-${{ matrix.goos }}-${{ matrix.goarch }} |
| 115 | + path: ${{ env.ARCHIVE }} |
| 116 | + |
| 117 | + harness: |
| 118 | + name: Integration harness |
| 119 | + needs: build |
| 120 | + runs-on: ubuntu-latest |
| 121 | + steps: |
| 122 | + - uses: actions/checkout@v4 |
| 123 | + |
| 124 | + - name: Download linux/amd64 binaries |
| 125 | + uses: actions/download-artifact@v4 |
| 126 | + with: |
| 127 | + name: pilot-linux-amd64 |
| 128 | + |
| 129 | + - name: Extract binaries |
| 130 | + run: | |
| 131 | + mkdir -p bin |
| 132 | + tar -xzf pilot-linux-amd64.tar.gz -C bin |
| 133 | + chmod +x bin/* |
| 134 | +
|
| 135 | + - name: End-to-end harness |
| 136 | + run: | |
| 137 | + set -e |
| 138 | + echo "=== Starting registry ===" |
| 139 | + bin/registry -addr 127.0.0.1:19000 -log-level error & |
| 140 | + REG_PID=$! |
| 141 | + sleep 1 |
| 142 | +
|
| 143 | + echo "=== Starting beacon ===" |
| 144 | + bin/beacon -registry-addr 127.0.0.1:19000 -listen :19001 -log-level error & |
| 145 | + BEACON_PID=$! |
| 146 | + sleep 1 |
| 147 | +
|
| 148 | + echo "=== Starting daemon A ===" |
| 149 | + PILOT_HOME=$(mktemp -d) |
| 150 | + bin/daemon -registry 127.0.0.1:19000 -beacon 127.0.0.1:19001 \ |
| 151 | + -hostname harness-a -home "$PILOT_HOME/a" -log-level error & |
| 152 | + DA_PID=$! |
| 153 | + sleep 2 |
| 154 | +
|
| 155 | + echo "=== Starting daemon B ===" |
| 156 | + bin/daemon -registry 127.0.0.1:19000 -beacon 127.0.0.1:19001 \ |
| 157 | + -hostname harness-b -home "$PILOT_HOME/b" -log-level error & |
| 158 | + DB_PID=$! |
| 159 | + sleep 2 |
| 160 | +
|
| 161 | + echo "=== Verify nodes registered ===" |
| 162 | + # pilotctl info via daemon A |
| 163 | + PILOT_SOCK="$PILOT_HOME/a/pilot.sock" bin/pilotctl info --json 2>&1 | head -20 |
| 164 | + echo " ✓ daemon A responds to info" |
| 165 | +
|
| 166 | + PILOT_SOCK="$PILOT_HOME/b/pilot.sock" bin/pilotctl info --json 2>&1 | head -20 |
| 167 | + echo " ✓ daemon B responds to info" |
| 168 | +
|
| 169 | + echo "=== Health check ===" |
| 170 | + PILOT_SOCK="$PILOT_HOME/a/pilot.sock" bin/pilotctl health --json 2>&1 | head -20 |
| 171 | + echo " ✓ daemon A health OK" |
| 172 | +
|
| 173 | + echo "=== Teardown ===" |
| 174 | + kill $DA_PID $DB_PID $BEACON_PID $REG_PID 2>/dev/null || true |
| 175 | + wait $DA_PID $DB_PID $BEACON_PID $REG_PID 2>/dev/null || true |
| 176 | + rm -rf "$PILOT_HOME" |
| 177 | + echo " ✓ all processes stopped cleanly" |
| 178 | + echo "" |
| 179 | + echo "=== HARNESS PASSED ===" |
| 180 | +
|
| 181 | + release: |
| 182 | + name: Create release |
| 183 | + needs: harness |
| 184 | + runs-on: ubuntu-latest |
| 185 | + steps: |
| 186 | + - uses: actions/checkout@v4 |
| 187 | + |
| 188 | + - name: Download all artifacts |
| 189 | + uses: actions/download-artifact@v4 |
| 190 | + with: |
| 191 | + path: artifacts |
| 192 | + |
| 193 | + - name: Collect archives |
| 194 | + run: | |
| 195 | + mkdir -p release |
| 196 | + find artifacts -name '*.tar.gz' -exec cp {} release/ \; |
| 197 | + ls -la release/ |
| 198 | +
|
| 199 | + - name: Generate checksums |
| 200 | + run: | |
| 201 | + cd release |
| 202 | + sha256sum *.tar.gz > checksums.txt |
| 203 | + cat checksums.txt |
| 204 | +
|
| 205 | + - name: Create GitHub release |
| 206 | + uses: softprops/action-gh-release@v2 |
| 207 | + with: |
| 208 | + files: | |
| 209 | + release/*.tar.gz |
| 210 | + release/checksums.txt |
| 211 | + generate_release_notes: true |
| 212 | + draft: false |
| 213 | + prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') }} |
0 commit comments