|
| 1 | +name: Build ShredOS |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + defconfig: |
| 10 | + description: 'Defconfig to build' |
| 11 | + required: true |
| 12 | + default: 'shredos_defconfig' |
| 13 | + type: choice |
| 14 | + options: |
| 15 | + - shredos_defconfig |
| 16 | + - shredos_lite_defconfig |
| 17 | + - shredos_iso_extra_defconfig |
| 18 | + - shredos_i686_lite_defconfig |
| 19 | + - shredos_iso_extra_i686_lite_defconfig |
| 20 | + - all |
| 21 | + |
| 22 | +jobs: |
| 23 | + determine-matrix: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 27 | + steps: |
| 28 | + - id: set-matrix |
| 29 | + run: | |
| 30 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 31 | + # Tag push: build all configs |
| 32 | + echo 'matrix={"defconfig":["shredos_defconfig","shredos_lite_defconfig","shredos_iso_extra_defconfig","shredos_i686_lite_defconfig","shredos_iso_extra_i686_lite_defconfig"]}' >> "$GITHUB_OUTPUT" |
| 33 | + elif [ "${{ inputs.defconfig }}" = "all" ]; then |
| 34 | + echo 'matrix={"defconfig":["shredos_defconfig","shredos_lite_defconfig","shredos_iso_extra_defconfig","shredos_i686_lite_defconfig","shredos_iso_extra_i686_lite_defconfig"]}' >> "$GITHUB_OUTPUT" |
| 35 | + else |
| 36 | + echo 'matrix={"defconfig":["${{ inputs.defconfig }}"]}' >> "$GITHUB_OUTPUT" |
| 37 | + fi |
| 38 | +
|
| 39 | + build: |
| 40 | + needs: determine-matrix |
| 41 | + runs-on: ubuntu-latest |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: ${{ fromJson(needs.determine-matrix.outputs.matrix) }} |
| 45 | + steps: |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Free disk space |
| 50 | + run: | |
| 51 | + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc |
| 52 | + sudo apt-get clean |
| 53 | + df -h / |
| 54 | +
|
| 55 | + - name: Install build dependencies |
| 56 | + run: | |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install -y \ |
| 59 | + bash \ |
| 60 | + bc \ |
| 61 | + binutils \ |
| 62 | + build-essential \ |
| 63 | + bzip2 \ |
| 64 | + cpio \ |
| 65 | + diffutils \ |
| 66 | + file \ |
| 67 | + findutils \ |
| 68 | + gawk \ |
| 69 | + gcc \ |
| 70 | + g++ \ |
| 71 | + git \ |
| 72 | + gzip \ |
| 73 | + libelf-dev \ |
| 74 | + libncurses5-dev \ |
| 75 | + libssl-dev \ |
| 76 | + make \ |
| 77 | + mtools \ |
| 78 | + patch \ |
| 79 | + perl \ |
| 80 | + python3 \ |
| 81 | + rsync \ |
| 82 | + sed \ |
| 83 | + syslinux \ |
| 84 | + syslinux-utils \ |
| 85 | + tar \ |
| 86 | + unzip \ |
| 87 | + wget \ |
| 88 | + which \ |
| 89 | + xorriso \ |
| 90 | + xz-utils |
| 91 | +
|
| 92 | + - name: Fix architecture in version.txt |
| 93 | + run: | |
| 94 | + VERSION_FILE="board/shredos/fsoverlay/etc/shredos/version.txt" |
| 95 | + if [[ "${{ matrix.defconfig }}" == *"i686"* ]]; then |
| 96 | + sed -i 's/x86-64/i686/g' "$VERSION_FILE" |
| 97 | + else |
| 98 | + sed -i 's/i686/x86-64/g' "$VERSION_FILE" |
| 99 | + fi |
| 100 | + echo "Version: $(cat $VERSION_FILE)" |
| 101 | +
|
| 102 | + - name: Build ShredOS (${{ matrix.defconfig }}) |
| 103 | + run: | |
| 104 | + make ${{ matrix.defconfig }} |
| 105 | + make -j$(nproc) |
| 106 | + timeout-minutes: 180 |
| 107 | + |
| 108 | + - name: Rename images with suffix |
| 109 | + run: | |
| 110 | + cd output/images |
| 111 | + CONFIG="${{ matrix.defconfig }}" |
| 112 | +
|
| 113 | + # Add _lite suffix |
| 114 | + if [[ "$CONFIG" == *"lite"* ]]; then |
| 115 | + for f in shredos*.{iso,img} 2>/dev/null; do |
| 116 | + [ -f "$f" ] || continue |
| 117 | + base="${f%.*}" |
| 118 | + ext="${f##*.}" |
| 119 | + [[ "$f" != *"_lite"* ]] && mv -v "$f" "${base}_lite.${ext}" |
| 120 | + done |
| 121 | + fi |
| 122 | +
|
| 123 | + # Add _plus-partition suffix |
| 124 | + if [[ "$CONFIG" == *"extra"* ]]; then |
| 125 | + for f in shredos*.{iso,img} 2>/dev/null; do |
| 126 | + [ -f "$f" ] || continue |
| 127 | + base="${f%.*}" |
| 128 | + ext="${f##*.}" |
| 129 | + [[ "$f" != *"_plus-partition"* ]] && mv -v "$f" "${base}_plus-partition.${ext}" |
| 130 | + done |
| 131 | + fi |
| 132 | +
|
| 133 | + # Generate SHA1 checksums |
| 134 | + for f in shredos*.{iso,img} 2>/dev/null; do |
| 135 | + [ -f "$f" ] && sha1sum "$f" > "$f.sha1" |
| 136 | + done |
| 137 | +
|
| 138 | + ls -lh shredos* 2>/dev/null || echo "No images found" |
| 139 | +
|
| 140 | + - name: Upload artifacts |
| 141 | + uses: actions/upload-artifact@v4 |
| 142 | + with: |
| 143 | + name: shredos-${{ matrix.defconfig }} |
| 144 | + path: | |
| 145 | + output/images/shredos*.img |
| 146 | + output/images/shredos*.iso |
| 147 | + output/images/shredos*.sha1 |
| 148 | + if-no-files-found: error |
| 149 | + |
| 150 | + release: |
| 151 | + needs: build |
| 152 | + if: startsWith(github.ref, 'refs/tags/v') |
| 153 | + runs-on: ubuntu-latest |
| 154 | + permissions: |
| 155 | + contents: write |
| 156 | + steps: |
| 157 | + - name: Download all artifacts |
| 158 | + uses: actions/download-artifact@v4 |
| 159 | + with: |
| 160 | + path: dist |
| 161 | + merge-multiple: true |
| 162 | + |
| 163 | + - name: List release files |
| 164 | + run: | |
| 165 | + echo "Files to release:" |
| 166 | + find dist -type f | sort |
| 167 | +
|
| 168 | + - name: Get version from tag |
| 169 | + id: version |
| 170 | + run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" |
| 171 | + |
| 172 | + - name: Create GitHub Release |
| 173 | + uses: softprops/action-gh-release@v2 |
| 174 | + with: |
| 175 | + name: ShredOS ${{ steps.version.outputs.tag }} |
| 176 | + body: | |
| 177 | + ## ShredOS ${{ steps.version.outputs.tag }} |
| 178 | +
|
| 179 | + ### Downloads |
| 180 | +
|
| 181 | + | File | Description | |
| 182 | + |------|-------------| |
| 183 | + | `shredos-*_x86-64_*.img` | 64-bit USB image (burn with Rufus/dd) | |
| 184 | + | `shredos-*_x86-64_*.iso` | 64-bit ISO (burn with Rufus to USB, or to CD/DVD) | |
| 185 | + | `shredos-*_x86-64_*_lite.*` | 64-bit lite (for systems with 512MB RAM) | |
| 186 | + | `shredos-*_x86-64_*_plus-partition.*` | 64-bit ISO with extra writable partition | |
| 187 | + | `shredos-*_i686_*` | 32-bit versions | |
| 188 | + | `*.sha1` | SHA1 checksums | |
| 189 | +
|
| 190 | + ### Burning to USB with Rufus (Windows) |
| 191 | + 1. Download the `.iso` file |
| 192 | + 2. Open [Rufus](https://rufus.ie/) |
| 193 | + 3. Select your USB drive |
| 194 | + 4. Select the downloaded `.iso` file |
| 195 | + 5. Click Start |
| 196 | +
|
| 197 | + ### Burning to USB with dd (Linux/macOS) |
| 198 | + ``` |
| 199 | + sudo dd if=shredos-*.img of=/dev/sdX bs=4M status=progress |
| 200 | + ``` |
| 201 | +
|
| 202 | + --- |
| 203 | + **Full Changelog**: https://github.com/${{ github.repository }}/commits/${{ steps.version.outputs.tag }} |
| 204 | + files: dist/**/* |
| 205 | + draft: false |
| 206 | + prerelease: false |
0 commit comments