iso_build #45
This file contains 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: iso_build | |
on: | |
workflow_dispatch: | |
# schedule: | |
# - cron: '30 2 * * *' | |
jobs: | |
prepare-release: | |
runs-on: ubuntu-20.04 | |
steps: | |
- | |
uses: styfle/cancel-workflow-action@0.9.0 | |
with: | |
access_token: ${{ github.token }} | |
- | |
id: time | |
uses: nanzm/get-time-action@v1.1 | |
with: | |
format: 'DDMMYYYYHHmm' | |
outputs: | |
release_tag: ${{ steps.time.outputs.time }} | |
build-release: | |
runs-on: ubuntu-20.04 | |
needs: [prepare-release] | |
# runs as user and use sudo if needed | |
container: | |
image: archlinux:latest | |
options: --privileged | |
steps: | |
- | |
uses: styfle/cancel-workflow-action@0.9.0 | |
with: | |
access_token: ${{ github.token }} | |
- name: Build | |
id: build | |
run: | | |
pacman-key --init | |
pacman-key --populate | |
# Enable multilib | |
echo "[multilib]" >> /etc/pacman.conf | |
echo "Include = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf | |
# Chaotic-AUR | |
pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com | |
pacman-key --lsign-key 3056513887B78AEB | |
pacman -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' --noconfirm | |
echo "[chaotic-aur]" >> /etc/pacman.conf | |
echo "Include = /etc/pacman.d/chaotic-mirrorlist" >> /etc/pacman.conf | |
# Set timezone | |
ln -sf /usr/share/zoneinfo/Europe/Athens /etc/localtime | |
# Set locale | |
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen | |
# Set BUILD_DATE | |
export BUILD_DATE=$(date +'%d-%m-%Y') | |
# Make sure container is up-to-date | |
pacman -Syu --noconfirm | |
# Install necessary packages | |
pacman -S git github-cli go archiso pacman-contrib binutils make gcc pkg-config fakeroot sudo zip base-devel rustup --needed --noconfirm | |
# Create a builder user so makepkg doesn't run as root | |
sudo useradd builder -m | |
# Allow the builder user to run sudo without a password | |
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | |
# Become the builder | |
cd /home/builder | |
sudo -u builder bash << EOF | |
# Set up rust | |
rustup install stable | |
rustup default stable | |
# Paru (AUR helper) | |
git clone https://aur.archlinux.org/paru.git | |
cd paru | |
makepkg -si --noconfirm | |
cd .. | |
paru -Sy rate-mirrors-bin --noconfirm | |
# Find fastest mirrors | |
rate-mirrors --allow-root arch | sudo tee /etc/pacman.d/mirrorlist; paru -Syyu --noconfirm | |
# Clone ISO repo and enter it | |
mkdir build | |
cd build | |
git init | |
git remote add -f origin https://github.com/evangelospro/dotfiles | |
git config core.sparseCheckout true | |
echo "iso" >> .git/info/sparse-checkout | |
git config --global init.defaultBranch main | |
git pull origin main | |
ls -lasih | |
cd iso | |
ls -lasih . # check if iso folder is there | |
# Build ISO and rename to match BUILD_DATE | |
bash aur.sh enable | |
bash build-no-cache.sh | |
# Stop being the builder | |
exit | |
EOF | |
cd isoOUT | |
ISO_PATH=$(find . -type f -name "*.iso") | |
ISO_NAME=$(basename $ISO_PATH) | |
ISO_PKGS=$(find . -type f -name "*.txt") | |
# split the iso if larger than 2GB | |
split -b 1950M $ISO_PATH "${ISO_NAME%.*}.part" | |
\ls -lasih . | |
for part in $(\ls *.part*); do | |
sha256sum $part > "${part}.sha256" | |
done | |
\ls -lasih . | |
echo ISO_PATH=$ISO_PATH >> $GITHUB_ENV | |
echo ISO_PARTS=$(find . -type f -name "*.part*") >> $GITHUB_ENV | |
echo SHA256SUMS=$(find . -type f -name "*.sha256") >> $GITHUB_ENV | |
echo ISO_PKGS=$ISO_PKGS >> $GITHUB_ENV | |
- name: Upload Releases | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: | | |
*.part* | |
*.sha256 | |
- | |
name: Rollback | |
if: ${{ failure() || cancelled() }} | |
run: | | |
echo ${{ github.token }} | gh auth login --with-token | |
gh release delete ${{ needs.prepare-release.outputs.release_tag }} -y --repo ${{ github.repository }} |