|
| 1 | +name: Build ClearNDR ISO |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master, main, docker-iso-builder] |
| 6 | + paths: |
| 7 | + - 'build-debian-live.sh' |
| 8 | + - 'build-iso-docker.sh' |
| 9 | + - 'Dockerfile' |
| 10 | + - 'staging/**' |
| 11 | + - '.github/workflows/build-iso.yml' |
| 12 | + pull_request: |
| 13 | + branches: [master, main, docker-iso-builder] |
| 14 | + paths: |
| 15 | + - 'build-debian-live.sh' |
| 16 | + - 'build-iso-docker.sh' |
| 17 | + - 'Dockerfile' |
| 18 | + - 'staging/**' |
| 19 | + - '.github/workflows/build-iso.yml' |
| 20 | + release: |
| 21 | + types: [published, created] |
| 22 | + workflow_dispatch: |
| 23 | + inputs: |
| 24 | + kernel_version: |
| 25 | + description: 'Custom kernel version (e.g., 6.10.11)' |
| 26 | + required: false |
| 27 | + type: string |
| 28 | + gui_option: |
| 29 | + description: 'GUI option' |
| 30 | + required: false |
| 31 | + default: 'desktop' |
| 32 | + type: choice |
| 33 | + options: |
| 34 | + - desktop |
| 35 | + - no-desktop |
| 36 | + |
| 37 | +jobs: |
| 38 | + build-iso: |
| 39 | + name: Build ClearNDR ISO |
| 40 | + runs-on: ubuntu-latest |
| 41 | + timeout-minutes: 180 # 3 hours timeout for the build |
| 42 | + |
| 43 | + permissions: |
| 44 | + contents: read |
| 45 | + packages: write |
| 46 | + actions: write |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Check out the repository |
| 50 | + uses: actions/checkout@v4 |
| 51 | + with: |
| 52 | + fetch-depth: 0 # Full history for proper versioning |
| 53 | + |
| 54 | + - name: Set up Docker Buildx |
| 55 | + uses: docker/setup-buildx-action@v3 |
| 56 | + |
| 57 | + - name: Cache Docker layers |
| 58 | + uses: actions/cache@v3 |
| 59 | + with: |
| 60 | + path: /tmp/.buildx-cache |
| 61 | + key: ${{ runner.os }}-iso-buildx-${{ github.sha }} |
| 62 | + restore-keys: | |
| 63 | + ${{ runner.os }}-iso-buildx- |
| 64 | +
|
| 65 | + - name: Log in to GitHub Container Registry |
| 66 | + uses: docker/login-action@v3 |
| 67 | + with: |
| 68 | + registry: ghcr.io |
| 69 | + username: ${{ github.actor }} |
| 70 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + |
| 72 | + - name: Prepare build environment |
| 73 | + run: | |
| 74 | + # Create output directory for artifacts |
| 75 | + mkdir -p output |
| 76 | +
|
| 77 | + # Set up build parameters |
| 78 | + OWNER=$(echo ${{ github.repository_owner }} | tr '[A-Z]' '[a-z]') |
| 79 | +
|
| 80 | + # Get version from git |
| 81 | + if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then |
| 82 | + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' -e 's/^v//') |
| 83 | + else |
| 84 | + VERSION="${{ github.sha }}" |
| 85 | + fi |
| 86 | +
|
| 87 | + echo "OWNER=$OWNER" >> $GITHUB_ENV |
| 88 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 89 | +
|
| 90 | + # Set build arguments based on workflow inputs |
| 91 | + BUILD_ARGS="" |
| 92 | + if [[ -n "${{ github.event.inputs.kernel_version }}" ]]; then |
| 93 | + BUILD_ARGS="$BUILD_ARGS -k ${{ github.event.inputs.kernel_version }}" |
| 94 | + fi |
| 95 | + if [[ "${{ github.event.inputs.gui_option }}" == "no-desktop" ]]; then |
| 96 | + BUILD_ARGS="$BUILD_ARGS -g no-desktop" |
| 97 | + fi |
| 98 | +
|
| 99 | + echo "BUILD_ARGS=$BUILD_ARGS" >> $GITHUB_ENV |
| 100 | +
|
| 101 | + echo "Build parameters:" |
| 102 | + echo "OWNER=$OWNER" |
| 103 | + echo "VERSION=$VERSION" |
| 104 | + echo "BUILD_ARGS=$BUILD_ARGS" |
| 105 | +
|
| 106 | + - name: Build Docker image for ISO building |
| 107 | + uses: docker/build-push-action@v5 |
| 108 | + with: |
| 109 | + context: . |
| 110 | + file: ./Dockerfile |
| 111 | + load: true |
| 112 | + tags: clearndr-builder:latest |
| 113 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 114 | + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max |
| 115 | + |
| 116 | + - name: Create staging directories |
| 117 | + run: | |
| 118 | + # Ensure staging directories exist |
| 119 | + mkdir -p staging/dockers |
| 120 | +
|
| 121 | + # Check available disk space |
| 122 | + echo "Available disk space:" |
| 123 | + df -h |
| 124 | +
|
| 125 | + echo "Current directory contents:" |
| 126 | + ls -la |
| 127 | +
|
| 128 | + - name: Build ClearNDR ISO |
| 129 | + run: | |
| 130 | + echo "Starting ISO build process..." |
| 131 | + echo "Build arguments: $BUILD_ARGS" |
| 132 | +
|
| 133 | + # Make build script executable |
| 134 | + chmod +x build-iso-docker.sh |
| 135 | +
|
| 136 | + # Run the Docker-based ISO build |
| 137 | + ./build-iso-docker.sh $BUILD_ARGS |
| 138 | + env: |
| 139 | + DOCKER_BUILDKIT: 1 |
| 140 | + |
| 141 | + - name: Check build results |
| 142 | + run: | |
| 143 | + echo "Checking for generated ISO files..." |
| 144 | +
|
| 145 | + # List contents of output directory |
| 146 | + if [ -d "output" ]; then |
| 147 | + echo "Contents of output directory:" |
| 148 | + ls -la output/ |
| 149 | + fi |
| 150 | +
|
| 151 | + # Look for ISO files in current directory |
| 152 | + echo "ISO files in current directory:" |
| 153 | + find . -name "*.iso" -type f -exec ls -lh {} \; |
| 154 | +
|
| 155 | + # Check Stamus-Live-Build directory |
| 156 | + if [ -d "Stamus-Live-Build" ]; then |
| 157 | + echo "Contents of Stamus-Live-Build directory:" |
| 158 | + ls -la Stamus-Live-Build/ |
| 159 | + find Stamus-Live-Build/ -name "*.iso" -type f -exec ls -lh {} \; |
| 160 | + fi |
| 161 | +
|
| 162 | + # Check for any large files that might be the ISO |
| 163 | + echo "Large files (>100MB) that might be ISO:" |
| 164 | + find . -size +100M -type f -exec ls -lh {} \; |
| 165 | +
|
| 166 | + - name: Prepare ISO artifact |
| 167 | + run: | |
| 168 | + # Create artifacts directory |
| 169 | + mkdir -p artifacts |
| 170 | +
|
| 171 | + # Find and copy ISO files |
| 172 | + ISO_FOUND=false |
| 173 | +
|
| 174 | + # Look for ClearNDR.iso first |
| 175 | + if [ -f "ClearNDR.iso" ]; then |
| 176 | + cp ClearNDR.iso artifacts/ |
| 177 | + ISO_FOUND=true |
| 178 | + echo "Found ClearNDR.iso" |
| 179 | + fi |
| 180 | +
|
| 181 | + # Look in Stamus-Live-Build directory |
| 182 | + if [ -f "Stamus-Live-Build/ClearNDR.iso" ]; then |
| 183 | + cp Stamus-Live-Build/ClearNDR.iso artifacts/ |
| 184 | + ISO_FOUND=true |
| 185 | + echo "Found ClearNDR.iso in Stamus-Live-Build/" |
| 186 | + fi |
| 187 | +
|
| 188 | + # Look for live-image-amd64.hybrid.iso |
| 189 | + if [ -f "Stamus-Live-Build/live-image-amd64.hybrid.iso" ]; then |
| 190 | + cp Stamus-Live-Build/live-image-amd64.hybrid.iso artifacts/ClearNDR-${{ env.VERSION }}.iso |
| 191 | + ISO_FOUND=true |
| 192 | + echo "Found live-image-amd64.hybrid.iso" |
| 193 | + fi |
| 194 | +
|
| 195 | + # Look in output directory |
| 196 | + if [ -d "output" ]; then |
| 197 | + find output/ -name "*.iso" -type f -exec cp {} artifacts/ \; |
| 198 | + fi |
| 199 | +
|
| 200 | + if [ "$ISO_FOUND" = false ]; then |
| 201 | + echo "ERROR: No ISO file found!" |
| 202 | + echo "Available files:" |
| 203 | + find . -name "*.iso" -type f |
| 204 | + exit 1 |
| 205 | + fi |
| 206 | +
|
| 207 | + # Rename ISO with version and build info |
| 208 | + cd artifacts |
| 209 | + for iso in *.iso; do |
| 210 | + if [ "$iso" != "*.iso" ]; then # Check if glob matched anything |
| 211 | + # Get size and create info file |
| 212 | + size=$(ls -lh "$iso" | awk '{print $5}') |
| 213 | + echo "ISO: $iso" > "${iso}.info" |
| 214 | + echo "Size: $size" >> "${iso}.info" |
| 215 | + echo "Build Date: $(date)" >> "${iso}.info" |
| 216 | + echo "Git Commit: ${{ github.sha }}" >> "${iso}.info" |
| 217 | + echo "Build Args: ${{ env.BUILD_ARGS }}" >> "${iso}.info" |
| 218 | +
|
| 219 | + # If it's just ClearNDR.iso, rename it with version |
| 220 | + if [ "$iso" = "ClearNDR.iso" ]; then |
| 221 | + mv "$iso" "ClearNDR-${{ env.VERSION }}.iso" |
| 222 | + mv "${iso}.info" "ClearNDR-${{ env.VERSION }}.iso.info" |
| 223 | + fi |
| 224 | + fi |
| 225 | + done |
| 226 | +
|
| 227 | + echo "Final artifacts:" |
| 228 | + ls -la |
| 229 | +
|
| 230 | + - name: Upload ISO as artifact |
| 231 | + uses: actions/upload-artifact@v4 |
| 232 | + with: |
| 233 | + name: clearndr-iso-${{ env.VERSION }} |
| 234 | + path: artifacts/ |
| 235 | + retention-days: 90 |
| 236 | + compression-level: 0 # Don't compress ISO files further |
| 237 | + |
| 238 | + - name: Upload build logs |
| 239 | + uses: actions/upload-artifact@v4 |
| 240 | + if: always() # Upload logs even if build fails |
| 241 | + with: |
| 242 | + name: build-logs-${{ env.VERSION }} |
| 243 | + path: | |
| 244 | + build.log |
| 245 | + Stamus-Live-Build/build.log |
| 246 | + retention-days: 30 |
| 247 | + |
| 248 | + - name: Create Release |
| 249 | + if: github.event_name == 'release' |
| 250 | + uses: softprops/action-gh-release@v1 |
| 251 | + with: |
| 252 | + files: artifacts/* |
| 253 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 254 | + |
| 255 | + - name: Move cache |
| 256 | + run: | |
| 257 | + rm -rf /tmp/.buildx-cache |
| 258 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments