Build HackerOS #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build HackerOS | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| edition: | |
| description: "Edycja HackerOS do zbudowania (tylko przy ręcznym uruchomieniu)" | |
| required: false | |
| default: "official" | |
| type: choice | |
| options: | |
| - official | |
| - all | |
| - monthly | |
| - gaming | |
| - cybersecurity | |
| - blue | |
| - hwde | |
| - hydra | |
| - cybersecurity-default | |
| - lts | |
| - gnome | |
| - xfce | |
| - atomic | |
| - nvidia | |
| push: | |
| branches: [ "official", "cybersecurity" ] | |
| env: | |
| # Wersja Lua do zbudowania ze źródeł (na dzień pisania tego workflow Lua 5.5 | |
| # nie ma jeszcze paczki w repozytoriach Ubuntu, więc kompilujemy ją ręcznie). | |
| LUA_VERSION: "5.5.0" | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| editions: ${{ steps.set-matrix.outputs.editions }} | |
| edition_input: ${{ steps.set-matrix.outputs.edition_input }} | |
| steps: | |
| - name: Wyznaczenie listy edycji do zbudowania | |
| id: set-matrix | |
| run: | | |
| # Edycje "official" | |
| OFFICIAL_EDITIONS='["official","gaming","blue","hwde","hydra","lts","gnome","xfce","atomic","nvidia"]' | |
| # Edycje "cybersecurity" - od teraz budowane na TYM SAMYM branchu co | |
| # reszta (helpers/cybersecurity i helpers/cybersecurity-default żyją | |
| # w repo obok pozostałych helpers/*, nie na osobnym branchu). | |
| CYBERSECURITY_EDITIONS='["cybersecurity","cybersecurity-default"]' | |
| ALL_EDITIONS='["official","gaming","cybersecurity","blue","hwde","hydra","cybersecurity-default","lts","gnome","xfce","atomic","nvidia"]' | |
| # Opcja "monthly" (uruchamiana ręcznie raz w miesiącu) - buduje tylko | |
| # official, cybersecurity i nvidia. | |
| MONTHLY_EDITIONS='["official","cybersecurity","nvidia"]' | |
| EDITION_INPUT="${{ github.event.inputs.edition }}" | |
| echo "edition_input=$EDITION_INPUT" >> "$GITHUB_OUTPUT" | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| EDITION="${{ github.event.inputs.edition }}" | |
| if [ -z "$EDITION" ]; then | |
| EDITION="official" | |
| fi | |
| if [ "$EDITION" = "all" ]; then | |
| # Opcja "all" - buduje każdą edycję osobno, każda na czystym | |
| # (świeżym) środowisku runnera, jedna po drugiej. | |
| echo "editions=$ALL_EDITIONS" >> "$GITHUB_OUTPUT" | |
| elif [ "$EDITION" = "monthly" ]; then | |
| # Opcja "monthly" - miesięczny build: official + cybersecurity + nvidia. | |
| echo "editions=$MONTHLY_EDITIONS" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "editions=[\"$EDITION\"]" >> "$GITHUB_OUTPUT" | |
| fi | |
| elif [ "${{ github.ref_name }}" = "cybersecurity" ]; then | |
| # Push na branch "cybersecurity" - budujemy tylko edycje cybersecurity. | |
| echo "editions=$CYBERSECURITY_EDITIONS" >> "$GITHUB_OUTPUT" | |
| else | |
| # Push na branch "official" - budujemy wszystkie edycje "official" | |
| # (cybersecurity* trzeba zbudować ręcznie przez workflow_dispatch | |
| # albo push na branch "cybersecurity"). | |
| echo "editions=$OFFICIAL_EDITIONS" >> "$GITHUB_OUTPUT" | |
| fi | |
| build: | |
| needs: setup | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 360 | |
| strategy: | |
| fail-fast: false | |
| # Każda edycja buduje się na osobnym, czystym runnerze GitHub Actions | |
| # (świeże środowisko dla każdej pozycji macierzy), więc kolejne | |
| # buildy nie dziedziczą żadnego stanu po poprzednich. | |
| matrix: | |
| edition: ${{ fromJson(needs.setup.outputs.editions) }} | |
| steps: | |
| - name: Checkout repozytorium | |
| uses: actions/checkout@v4 | |
| with: | |
| # POPRAWKA: cybersecurity / cybersecurity-default nie są już | |
| # przypięte do osobnego brancha "cybersecurity" - build-hackeros-cybersecurity* | |
| # i helpers/cybersecurity* żyją w tym samym repo/branchu co reszta, | |
| # więc dla wszystkich edycji checkoutujemy zwyczajnie ten | |
| # branch/commit, który wyzwolił bieżący workflow run. | |
| ref: ${{ github.ref }} | |
| - name: Odczyt wersji z config.hk | |
| id: version | |
| run: | | |
| VERSION=$(awk -F'=>' '/version[[:space:]]*=>/ { gsub(/[[:space:]]/, "", $NF); print $NF }' config.hk | head -n1) | |
| if [ -z "$VERSION" ]; then | |
| echo "Nie udało się odczytać wersji z ./config.hk (oczekiwany format: 'version => X.Y' pod [metadata])" >&2 | |
| exit 1 | |
| fi | |
| echo "Wersja odczytana z config.hk: $VERSION" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Aktualizacja listy pakietów | |
| run: sudo apt-get update | |
| - name: Instalacja podstawowych narzędzi | |
| run: | | |
| sudo apt-get install -y --no-install-recommends \ | |
| tar \ | |
| git \ | |
| curl \ | |
| ca-certificates \ | |
| build-essential \ | |
| make \ | |
| gcc \ | |
| libreadline-dev | |
| - name: Instalacja Pythona 3.13 (deadsnakes PPA) | |
| run: | | |
| sudo apt-get install -y software-properties-common | |
| sudo add-apt-repository -y ppa:deadsnakes/ppa | |
| sudo apt-get update | |
| sudo apt-get install -y python3.13 python3.13-venv python3.13-dev | |
| - name: Budowa i instalacja Lua ${{ env.LUA_VERSION }} ze źródeł | |
| run: | | |
| curl -fL -o "lua-${LUA_VERSION}.tar.gz" \ | |
| "https://www.lua.org/ftp/lua-${LUA_VERSION}.tar.gz" | |
| tar -xzf "lua-${LUA_VERSION}.tar.gz" | |
| cd "lua-${LUA_VERSION}" | |
| make linux -j"$(nproc)" | |
| sudo make install | |
| cd .. | |
| # Domyślny "make install" Lua instaluje binarki jako `lua`/`luac` | |
| # (bez numeru wersji), a nasz workflow oraz build.lua wywołują | |
| # jawnie `lua5.5`. Tworzymy symlinki, żeby `lua5.5`/`luac5.5` | |
| # wskazywały na świeżo zbudowaną instalację. | |
| sudo ln -sf "$(command -v lua)" /usr/local/bin/lua5.5 | |
| sudo ln -sf "$(command -v luac)" /usr/local/bin/luac5.5 | |
| hash -r | |
| lua5.5 -v | |
| - name: Instalacja live-build (najnowsza wersja ze źródeł Debian Live Team) i narzędzi do tworzenia obrazu ISO | |
| run: | | |
| sudo apt-get install -y --no-install-recommends \ | |
| debootstrap \ | |
| debian-archive-keyring \ | |
| squashfs-tools \ | |
| xorriso \ | |
| isolinux \ | |
| syslinux-common \ | |
| syslinux-efi \ | |
| dosfstools \ | |
| mtools \ | |
| grub-pc-bin \ | |
| grub-efi-amd64-bin \ | |
| grub-efi-ia32-bin \ | |
| mtd-utils \ | |
| build-essential \ | |
| devscripts \ | |
| debhelper \ | |
| po4a | |
| # Pakiet "live-build" z repozytoriów Ubuntu jest zamrożony na | |
| # bardzo starej gałęzi 3.0~a57 (z ok. 2012 roku) i nie ma wielu | |
| # opcji obecnych w aktualnym live-build (np. --debootstrap-options). | |
| # Budujemy najnowszą wersję wprost ze źródeł Debian Live Team | |
| # (ta sama gałąź, z której pochodzi pakiet w Debianie - obecnie | |
| # w testing/unstable), żeby mieć aktualne zachowanie i opcje. | |
| rm -rf /tmp/live-build-src | |
| git clone --depth 1 https://salsa.debian.org/live-team/live-build.git /tmp/live-build-src | |
| cd /tmp/live-build-src | |
| dpkg-buildpackage -b -uc -us | |
| cd .. | |
| sudo apt-get remove -y live-build || true | |
| sudo dpkg -i live-build_*.deb | |
| lb --version | |
| - name: Instalacja hackeros-builder (tylko edycja cybersecurity-default) | |
| if: matrix.edition == 'cybersecurity-default' | |
| run: | | |
| # hackeros-builder to osobne narzędzie (nie live-build) używane | |
| # wyłącznie przez build/build-hackeros-cybersecurity-default do | |
| # zbudowania jednocześnie kontenera OCI oraz ISO na podstawie | |
| # config/config.hk. Zakładamy, że binarka releasu nazywa się | |
| # "hackeros-builder" i jest publikowana jako "latest" release w | |
| # repo HackerOS-Linux-System/hackeros-builder - jeśli nazwa | |
| # assetu/repo jest inna, ten krok trzeba dostosować. | |
| curl -fL -o /usr/local/bin/hackeros-builder \ | |
| "https://github.com/HackerOS-Linux-System/hackeros-builder/releases/latest/download/hackeros-builder" | |
| chmod +x /usr/local/bin/hackeros-builder | |
| hackeros-builder --version || true | |
| - name: Uruchomienie build.lua (edycja - ${{ matrix.edition }}) | |
| env: | |
| # Sekret GitHub Actions o nazwie "cybersecurity-default" (token | |
| # classic z uprawnieniami do org HackerOS-Linux-System) - używany | |
| # wyłącznie przez build/build-hackeros-cybersecurity-default do | |
| # wypełnienia [auth] -> token w config/config.hk. | |
| CYBERSECURITY_DEFAULT_TOKEN: ${{ secrets.CYBERSECURITY_DEFAULT_TOKEN }} | |
| run: | | |
| chmod +x build.lua | |
| if [ "${{ matrix.edition }}" = "official" ]; then | |
| lua5.5 build.lua | |
| else | |
| lua5.5 build.lua --${{ matrix.edition }} | |
| fi | |
| - name: Wyszukanie zbudowanych obrazów ISO | |
| id: find_iso | |
| run: | | |
| echo "iso_found=$(find . -maxdepth 3 -iname '*.iso' | head -n1)" >> "$GITHUB_OUTPUT" | |
| - name: Zmiana nazwy obrazu ISO | |
| id: rename_iso | |
| if: steps.find_iso.outputs.iso_found != '' | |
| run: | | |
| SRC="${{ steps.find_iso.outputs.iso_found }}" | |
| DEST="HackerOS-V${{ steps.version.outputs.version }}-${{ matrix.edition }}.iso" | |
| mv -- "$SRC" "$DEST" | |
| echo "Zmieniono nazwę: $SRC -> $DEST" | |
| echo "iso_path=$DEST" >> "$GITHUB_OUTPUT" | |
| - name: Wygenerowanie sum kontrolnych obrazu ISO (SHA256 / SHA512) | |
| id: checksums | |
| if: steps.find_iso.outputs.iso_found != '' | |
| run: | | |
| ISO="${{ steps.rename_iso.outputs.iso_path }}" | |
| sha256sum "$ISO" > "${ISO}.sha256sum" | |
| sha512sum "$ISO" > "${ISO}.sha512sum" | |
| echo "--- ${ISO}.sha256sum ---" | |
| cat "${ISO}.sha256sum" | |
| echo "--- ${ISO}.sha512sum ---" | |
| cat "${ISO}.sha512sum" | |
| - name: Wgranie ISO jako artefaktu builda | |
| if: steps.find_iso.outputs.iso_found != '' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: HackerOS-V${{ steps.version.outputs.version }}-${{ matrix.edition }} | |
| path: | | |
| ${{ steps.rename_iso.outputs.iso_path }} | |
| ${{ steps.rename_iso.outputs.iso_path }}.sha256sum | |
| ${{ steps.rename_iso.outputs.iso_path }}.sha512sum | |
| if-no-files-found: warn | |
| package-all: | |
| needs: [setup, build] | |
| if: needs.setup.outputs.edition_input == 'all' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repozytorium (do odczytu wersji z config.hk) | |
| uses: actions/checkout@v4 | |
| - name: Odczyt wersji z config.hk | |
| id: version | |
| run: | | |
| VERSION=$(awk -F'=>' '/version[[:space:]]*=>/ { gsub(/[[:space:]]/, "", $NF); print $NF }' config.hk | head -n1) | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Pobranie wszystkich zbudowanych obrazów ISO | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: "HackerOS-V*-*" | |
| path: all-isos | |
| merge-multiple: true | |
| - name: Spakowanie wszystkich ISO do jednego archiwum ZIP | |
| run: | | |
| cd all-isos | |
| ls -la | |
| zip -X "../HackerOS-V${{ steps.version.outputs.version }}-all.zip" *.iso *.sha256sum *.sha512sum | |
| - name: Wgranie zbiorczego archiwum ZIP jako artefaktu builda | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: HackerOS-V${{ steps.version.outputs.version }}-all | |
| path: HackerOS-V${{ steps.version.outputs.version }}-all.zip | |
| if-no-files-found: error |