Skip to content

build: fix disko script #353

build: fix disko script

build: fix disko script #353

Workflow file for this run

name: "Build customized NixOS LiveCD ISO"
on:
push:
schedule:
- cron: '30 1 * * 1'
jobs:
create-release:
if: (startsWith(github.event.head_commit.message, 'build:') || (github.event_name == 'schedule'))
name: Create release
runs-on: ubuntu-latest
outputs:
date: ${{ steps.current_time.outputs.formattedTime }}
log-num: ${{ steps.get_log.outputs.log-num }}
steps:
- uses: actions/checkout@v3
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current_time
with:
format: YYYYMMDD_HHmm
utcOffset: "+08:00"
- name: Get log
id: get_log
run: |
echo "log-num=$(git --no-pager log --since yesterday --pretty=format:%h%x09%an%x09%ad%x09%s --date short | grep -c '')" >> $GITHUB_OUTPUT
- name: Create release
id: create_release
if: ${{steps.get_log.outputs.log-num > 0}}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: build-${{ steps.current_time.outputs.formattedTime }}
release_name: Automated build ${{ steps.current_time.outputs.formattedTime }}
buildiso:
name: Build ISO for ${{ matrix.target }}
if: (startsWith(github.event.head_commit.message, 'build:') || (github.event_name == 'schedule'))
needs: create-release
strategy:
fail-fast: false
matrix:
target: ["imgs.x1c7", "imgs.deck", "imgs.tb14" ]
# GitHub Action may not have enough space to build the deck image.
# target: ["imgs.x1c7"]
runs-on: ubuntu-latest
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
# Reserved for /tmp
root-reserve-mb: 20480
swap-size-mb: 4096
temp-reserve-mb: 100
build-mount-path: '/nix'
build-mount-path-ownership: 'root:root'
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current_time
with:
format: YYYYMMDD_HHmm
utcOffset: "+08:00"
- name: Checkout
uses: actions/checkout@v3
- name: Install nixFlake
uses: cachix/install-nix-action@v27
- uses: cachix/cachix-action@v14
with:
name: lexuge
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# Don't push source or .iso files as they are pointless to take up precious cache space.
pushFilter: '(-source$|nixpkgs\.tar\.gz$|\.iso$|-squashfs.img$|crate-$)'
- uses: cachix/cachix-action@v14
with:
name: dcompass
skipPush: true
# NOTE: Don't update automatically, it breaks build
# - name: Update flake.lock, show drv, and calculate the hashes
# id: update
# run: |
# nix flake update
- name: Build LiveCD ISO image
id: iso
run: |
nix build ".#${{ matrix.target }}"
cp "result/iso/$(ls "$(readlink result)/iso/")" ./${{ matrix.target }}.iso
echo "iso-checksum=$(sha512sum ./${{ matrix.target }}.iso|cut -d " " -f 1)" >> $GITHUB_OUTPUT
split -a 3 -b 2047M --numeric-suffixes=1 ./${{ matrix.target }}.iso ${{ matrix.target }}.
rm ./${{ matrix.target }}.iso
- name: Publish
uses: softprops/action-gh-release@v1
with:
files: '${{ matrix.target }}*'
append_body: true
body: |
The SHA-512 checksum of image ${{ matrix.target }} is ${{ steps.iso.outputs.iso-checksum }}.
tag_name: build-${{ needs.create-release.outputs.date }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
remove-release:
name: Clean up release(s)
if: (startsWith(github.event.head_commit.message, 'build:') || (github.event_name == 'schedule'))
needs: buildiso
runs-on: ubuntu-latest
steps:
- name: Clean-up releases
uses: dev-drprasad/[email protected]
with:
keep_latest: 7
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}