Build customized NixOS LiveCD ISO #201
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: "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@v2 | |
with: | |
fetch-depth: 0 | |
- 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 dcompass 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"] | |
target: ["imgs.x1c7"] | |
runs-on: ubuntu-latest | |
steps: | |
- 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@v2 | |
with: | |
# Nix Flakes doesn't work on shallow clones | |
fetch-depth: 0 | |
- name: Install nixFlake | |
uses: cachix/install-nix-action@v20 | |
- uses: cachix/cachix-action@v12 | |
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@v12 | |
with: | |
name: dcompass | |
skipPush: true | |
- 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 | |
- name: Publish | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: '*.iso' | |
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 }} |