From 8e0fbb14ec7a9321681949d0d89a0fb48affee66 Mon Sep 17 00:00:00 2001 From: syui Date: Mon, 12 Feb 2024 10:18:52 +0900 Subject: [PATCH] add actions --- .github/workflows/release.yml | 50 +++++++++++++++++++++++++++++++++++ README.md | 1 - build.zsh | 44 +++++++++++++----------------- 3 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..182c464 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: release + +on: + push: + branches: + - main + schedule: + - cron: '0 0 * * *' + +permissions: + contents: write + +jobs: + release: + name: Release + runs-on: ubuntu-latest + container: + image: archlinux + options: --privileged + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Initialize + run: | + pacman -Syuu --noconfirm base-devel archiso docker git + git clone https://gitlab.archlinux.org/archlinux/archiso + cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/ + cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh + cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh + cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso + ./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/ + tar xf aios-bootstrap*.tar.gz + echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch\nServer = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist + sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf + arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init' + arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux' + arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq' + arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai' + tar -zcvf aios-bootstrap.tar.gz root.x86_64/ + tar -C ./root.x86_64 -c . | docker import - syui/aios + echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin + docker push syui/aios + + - name: Create new release + uses: softprops/action-gh-release@v1 + with: + name: Release latest + tag_name: latest + files: + aios-bootstrap.tar.gz diff --git a/README.md b/README.md index e008029..4a48c40 100644 --- a/README.md +++ b/README.md @@ -57,4 +57,3 @@ $ docker run --rm syui/aios cargo version cargo 1.75.0 ``` - diff --git a/build.zsh b/build.zsh index b6e676d..7f89432 100755 --- a/build.zsh +++ b/build.zsh @@ -1,30 +1,22 @@ #!/bin/zsh d=${0:a:h} -case $1 in - bsae) - a=baseline - ;; - *) - a=releng - ;; -esac +cd $d - -if ! ls $d/*.tar.gz;then - rm -rf $d/*.tar.gz +if ! ls ./*.tar.gz;then + rm -rf ./*.tar.gz fi -if [ -d $d/work ];then - rm -rf $d/work +if [ -d ./work ];then + rm -rf ./work fi -if [ -d $d/root.x86_64 ];then - rm -rf $d/root.x86_64 +if [ -d ./root.x86_64 ];then + rm -rf ./root.x86_64 fi -if [ -d $d/archiso ];then - rm -rf $d/archiso +if [ -d ./archiso ];then + rm -rf ./archiso fi git clone https://gitlab.archlinux.org/archlinux/archiso @@ -32,13 +24,15 @@ git clone https://gitlab.archlinux.org/archlinux/archiso # rm -rf $d/archlinux-docker # git clone https://gitlab.archlinux.org/archlinux/archlinux-docker -cp -rf $d/cfg/profiledef.sh $d/archiso/configs/$a/profiledef.sh -cp -rf $d/scpt/mkarchiso $d/archiso/archiso/mkarchiso +cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/ +cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh +cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh +cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso -$d/archiso/archiso/mkarchiso -v -o $d/ $d/archiso/configs/releng +./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng -if [ ! -d $d/root.x86_64 ];then - tar xf $d/aios-bootstrap*.tar.gz +if [ ! -d ./root.x86_64 ];then + tar xf ./aios-bootstrap*.tar.gz fi echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch\nServer = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist @@ -48,12 +42,10 @@ arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux' arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq' arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai' -# docker image + systemctl start docker -tar -C $d/root.x86_64 -c . | docker import - syui/aios +tar -C ./root.x86_64 -c . | docker import - syui/aios docker images -a docker run --rm syui/aios ai docker push syui/aios - -# docker run -it syui/aios zsh