diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..0d3317f --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,60 @@ +on: [push] + +env: + RELEASE_START: 100 + +jobs: + build: + runs-on: [self-hosted, Linux, ARM64] + container: ayufan/rock64-dockerfiles:bookworm + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Configure ccache + run: echo "CCACHE_DIR=$RUNNER_TEMP/ccache" >> $GITHUB_ENV + - name: Configure version + run: echo "VERSION=$(cat VERSION).$(($RELEASE_START+$GITHUB_RUN_NUMBER))" >> $GITHUB_ENV + - name: Reset ccache statistics + run: ccache -M 0 -F 0 + - name: Cleanup old packages + run: rm -f *.tar.xz + - name: Install keyring + run: make keyring + - name: Build images + run: make all + - name: Release images + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -x + + export RELEASE_NAME="$VERSION" + export RELEASE_TITLE="$VERSION" + export DESCRIPTION="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + + github-release release \ + --tag "${RELEASE_NAME}" \ + --name "${RELEASE_TITLE}" \ + --user "${GITHUB_REPOSITORY%/*}" \ + --repo "${GITHUB_REPOSITORY#*/}" \ + --description "${DESCRIPTION}" \ + --target "${GITHUB_SHA}" \ + --draft + + sleep 3s # allow to update release + + for i in *.tar.xz; do + github-release upload \ + --tag "${RELEASE_NAME}" \ + --name "$(basename "${i}")" \ + --user "${GITHUB_REPOSITORY%/*}" \ + --repo "${GITHUB_REPOSITORY#*/}" \ + --file "${i}" + done + + github-release edit \ + --tag "${RELEASE_NAME}" \ + --name "${RELEASE_TITLE}" \ + --user "${GITHUB_REPOSITORY%/*}" \ + --repo "${GITHUB_REPOSITORY#*/}" \ + --description "${DESCRIPTION}" diff --git a/.gitignore b/.gitignore index eee2822..0c5dabe 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /tmp/ /*.tar /*.tar.xz +/*.deb \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 07faaca..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,55 +0,0 @@ -image: ayufan/rock64-dockerfiles:bookworm - -variables: - GITHUB_USER: ayufan-rock64 - GITHUB_REPO: linux-rootfs - - VERSION: ${CI_COMMIT_TAG} - RELEASE_NAME: "${CI_COMMIT_TAG}: gitlab-ci-linux-rootfs-${CI_PIPELINE_ID}" - PIPELINE_URL: $CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID - -stages: [draft, build, pre-release, release] - -before_script: - - 'export CHANGES=$(git tag -l --format="%(contents)" "$CI_COMMIT_TAG")' - - 'export DESCRIPTION=$(echo -e "${CHANGES}\n\n${PIPELINE_URL}")' - -draft: - stage: draft - only: [tags] - script: - - github-release release --tag "${VERSION}" --name "$RELEASE_NAME" --description "$DESCRIPTION" --target "$CI_COMMIT_SHA" --draft - -pre-release: - stage: pre-release - only: [tags] - environment: - name: pre-release - url: https://github.com/$GITHUB_USER/$GITHUB_REPO/releases/tag/$CI_COMMIT_TAG - script: - - github-release edit --tag "${VERSION}" --name "$RELEASE_NAME" --description "$DESCRIPTION" --pre-release - -release: - stage: release - only: [tags] - when: manual - environment: - name: release - url: https://github.com/$GITHUB_USER/$GITHUB_REPO/releases/tag/$CI_COMMIT_TAG - script: - - github-release edit --tag "${VERSION}" --name "$RELEASE_NAME" --description "$DESCRIPTION" - -.build: &build - stage: build - only: [tags] - script: - - make "$CI_JOB_NAME" - - github-release upload --tag "${VERSION}" --name "$(basename *.xz)" --file *.xz - - git clean -fdx - -.build_manual: &build_manual - <<: *build - when: manual - allow_failure: true - -debian-bookworm-minimal-arm64: *build diff --git a/Makefile b/Makefile index 82e12b4..8e21b4c 100644 --- a/Makefile +++ b/Makefile @@ -1,40 +1,32 @@ export VERSION ?= 0.1~dev -VARIANTS := $(patsubst configs/%,%,$(wildcard configs/*-*-*)) +VARIANTS := $(patsubst configs/%,%,$(wildcard configs/debian-*-*)) -all: \ - $(patsubst %,%-$(VERSION)-armhf.tar.xz,$(VARIANTS)) \ - $(patsubst %,%-$(VERSION)-arm64.tar.xz,$(VARIANTS)) +ARCHS := arm64 +TARGETS := $(foreach arch,$(ARCHS),$(patsubst %,%-$(VERSION)-$(arch).tar.xz,$(VARIANTS))) + +all: $(TARGETS) + +keyring: + bash -c 'dpkg -s ubuntu-keyring &>/dev/null || \ + ( wget -c http://mirrors.kernel.org/ubuntu/pool/main/u/ubuntu-keyring/ubuntu-keyring_2021.03.26_all.deb && \ + dpkg -i ubuntu-keyring_2021.03.26_all.deb && \ + rm ubuntu-keyring_2021.03.26_all.deb )' info: @echo $(VARIANTS) +targets: + @echo $(TARGETS) + %.xz: % xz -T 0 -f -3 $< %.tar: eatmydata -- bash build.sh "$@" \ - "$(shell basename "$@" -$(VERSION)-$(BUILD_ARCH).tar)" \ - "$(BUILD_MODE)" \ - "$(BUILD_SUITE)" \ - "$(BUILD_ARCH)" - -%-armhf.tar.xz: BUILD_ARCH=armhf -%-arm64.tar.xz: BUILD_ARCH=arm64 - -$(addsuffix -arm64, $(VARIANTS)): %-arm64: %-$(VERSION)-arm64.tar.xz - -debian-%.tar.xz: BUILD_MODE=debian -debian-bookworm-%.tar.xz: BUILD_SUITE=bookworm - -.PHONY: shell # run docker shell to build image -shell: - @echo Entering shell... - @docker run --rm \ - -it \ - -e HOME -v $(HOME):$(HOME) \ - --privileged \ - -h rock64-build-env \ - -v $(CURDIR):$(CURDIR) \ - -w $(CURDIR) \ - ayufan/rock64-dockerfiles:bookworm + "$(word 1,$(subst -, , $@))-$(word 2,$(subst -, , $@))-$(word 3,$(subst -, , $@))" \ + "$(word 1,$(subst -, , $@))" \ + "$(word 2,$(subst -, , $@))" \ + "$(word 5,$(subst -, , $(basename $@)))" + +$(foreach arch,$(ARCHS),$(addsuffix -$(arch), $(VARIANTS)): %-$(arch): %-$(VERSION)-$(arch).tar.xz) diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..ce609ca --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.8 \ No newline at end of file diff --git a/configs/debian-bullseye-minimal/.gitkeep b/configs/debian-bullseye-minimal/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/configs/debian-buster-minimal/.gitkeep b/configs/debian-buster-minimal/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/configs/ubuntu-focal-minimal/.gitkeep b/configs/ubuntu-focal-minimal/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/configs/ubuntu-jimmy-minimal/.gitkeep b/configs/ubuntu-jimmy-minimal/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/configs/ubuntu/package-lists/additional.list.chroot b/configs/ubuntu/package-lists/additional.list.chroot new file mode 100644 index 0000000..0cb3191 --- /dev/null +++ b/configs/ubuntu/package-lists/additional.list.chroot @@ -0,0 +1,23 @@ +dosfstools +curl +xz-utils +iw +rfkill +wpasupplicant +openssh-server +alsa-utils +nano +git +build-essential +vim +jq +ethtool +zram-config +wget +ca-certificates +software-properties-common +sudo +htop +ifupdown +bash +eatmydata diff --git a/configs/ubuntu/package-lists/base.list.chroot b/configs/ubuntu/package-lists/base.list.chroot new file mode 100644 index 0000000..535bd04 --- /dev/null +++ b/configs/ubuntu/package-lists/base.list.chroot @@ -0,0 +1,3 @@ +ubuntu-minimal +gnupg2 +gpg-agent diff --git a/dev-shell b/dev-shell new file mode 100755 index 0000000..540f26c --- /dev/null +++ b/dev-shell @@ -0,0 +1,21 @@ +#!/bin/bash + +CURDIR="$PWD" + +exec docker run \ + --rm \ + -it \ + -e HOME -v "${HOME}:${HOME}" \ + -e USER \ + -u "$(id -u):$(id -g)" \ + $(id -Gz | xargs -0 -n1 -I{} echo "--group-add={}") \ + -v /etc/passwd:/etc/passwd:ro \ + -v /dev:/dev \ + -v "${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}" \ + -e SSH_AUTH_SOCK \ + --privileged \ + -h rock64-build-env \ + -v "${CURDIR}:${CURDIR}" \ + -w "${CURDIR}" \ + ayufan/rock64-dockerfiles:bookworm \ + "$@"