-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
104 lines (92 loc) · 2.49 KB
/
Taskfile.yml
File metadata and controls
104 lines (92 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# https://taskfile.dev
version: "3"
vars:
DISTRO:
sh: /bin/grep -oP '^ID=\s*\K.*$' /etc/os-release
TOOLS:
map:
bsdtar:
arch: libarchive
ubuntu: libarchive-tools
sqfs2tar:
arch: squashfs-tools-ng
ubuntu: squashfs-tools-ng
NAME: ghcr.io/evilhamsterman/vyos
tasks:
_check_tools:
desc: Ensure required tools are installed
internal: true
cmds:
- for:
var: TOOLS
cmd: ! type {{.KEY}}
_install_tools_ubuntu:
internal: true
cmds:
- apt-get update
- apt-get install -y {{ range .TOOLS }} {{.ubuntu}} {{end}}
_install_tools_arch:
internal: true
cmds:
- yay -Sy --noconfirm {{ range .TOOLS }} {{.arch}} {{end}}
_install_tools_cachyos:
internal: true
cmd:
task: _install_tools_arch
clean:
sources:
- "*.iso"
status:
- "! test -f rootfs.tar"
- "! test -d live"
cmds:
- rm -f rootfs.tar
- rm -rf live
install_tools:
desc: Install needed tools
cmd:
task: "_install_tools_{{.DISTRO}}"
extract_rootfs:
desc: Extracts the squashfs filesystem into a tar file
vars:
ISO:
sh: /bin/ls -1 vyos*-generic-amd64.iso 2> /dev/null | head -n1
sources:
- "*.iso"
preconditions:
- sh: stat vyos*-generic-amd64.iso
msg: VYOS ISO not found. Please download one from https://vyos.net/get/
status:
- test -f rootfs.tar
cmds:
- task: clean
- bsdtar -xf {{.ISO}} live/filesystem.squashfs
- sqfs2tar live/filesystem.squashfs > rootfs.tar 2> /dev/null
build:
desc: Build the VYOS container
vars:
LABEL:
sh: /bin/ls -1 vyos*-generic-amd64.iso 2> /dev/null | head -n1 | grep -oP '(?<=vyos-).*(?=-generic-amd64\.iso)'
TYPE: '{{if not (contains "rolling" .LABEL)}}stream{{else}}rolling{{end}}'
TAGS: '-t {{$.NAME}}:{{.LABEL}}{{ if (eq .TYPE "stream") }}-stream{{end}} -t {{.NAME}}:latest -t {{.NAME}}:{{.TYPE}}'
ARGS: '{{default "" .ARGS}}'
sources:
- "*.iso"
deps:
- task: extract_rootfs
cmd: docker build {{.TAGS}} {{.ARGS}} .
push:
desc: Push the VYOS container to GHCR
cmd:
task: build
vars:
ARGS: --push
local-tags:
desc: Create local tags of vyos images for shorter names
vars:
TAGS:
sh: docker image ls -f reference={{.NAME}} --format {{"{{.Tag}}"}}
cmds:
- for:
var: TAGS
cmd: docker tag "{{.NAME}}:{{.ITEM}}" "vyos:{{.ITEM}}"