Skip to content

Commit

Permalink
workflow: compile and auto-release
Browse files Browse the repository at this point in the history
  • Loading branch information
ayufan committed Nov 11, 2023
1 parent ddbbbee commit 70e62c4
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 82 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
on:
push:
workflow_dispatch:

env:
RELEASE_START: 100

jobs:
build:
runs-on: [self-hosted, Linux, ARM64]
container:
image: ayufan/rock64-dockerfiles:bookworm
options: --privileged
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure version
run: echo "VERSION=$(cat VERSION).$(($RELEASE_START+$GITHUB_RUN_NUMBER))" >> $GITHUB_ENV
- 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}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/tmp/
/*.tar
/*.tar.xz
/*.deb
55 changes: 0 additions & 55 deletions .gitlab-ci.yml

This file was deleted.

46 changes: 19 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,31 @@ export VERSION ?= 0.1~dev

VARIANTS := $(patsubst configs/%,%,$(wildcard configs/*-*-*))

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)
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.8
Empty file.
5 changes: 5 additions & 0 deletions configs/.broken/ubuntu-focal-minimal/archives/apt.list.binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
Empty file.
5 changes: 5 additions & 0 deletions configs/.broken/ubuntu-jimmy-minimal/archives/apt.list.binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
23 changes: 23 additions & 0 deletions configs/.broken/ubuntu/package-lists/additional.list.chroot
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions configs/.broken/ubuntu/package-lists/base.list.chroot
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ubuntu-minimal
gnupg2
gpg-agent
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions dev-shell
Original file line number Diff line number Diff line change
@@ -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 \
"$@"

0 comments on commit 70e62c4

Please sign in to comment.