-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
129 lines (106 loc) · 3.68 KB
/
justfile
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
args := ""
gitRoot := `git rev-parse --show-toplevel`
goUpdates :="false"
labels := ""
progress := if args != "" { "auto" } else { "plain" }
tags := ""
# renovate: datasource=docker depName=quay.io/fedora-ostree-desktops/silverblue
tagFedoraLatestVersion := "41"
_default:
@just --list --list-heading $'' --list-prefix $''
# run go updates for the given project (USE WITH CAUTION)
go-update project version="latest":
#!/usr/bin/env bash
echo "=> go update: {{ project }}"
pushd "{{ project }}" >/dev/null || exit 1
if [[ ! -f "go.mod" ]]; then
echo "‼️ ERROR: no go.mod in {{ project }}"
exit 1
fi
[ -x "$(command -v gobrew)" ] || exit 1
gobrew use "{{ version }}"
# remove the go version, let the mod update it
sed -i '/^go\s.*$/d' go.mod
go get -u
go mod tidy
popd >/dev/null || exit 1
# init go.work | https://go.dev/doc/tutorial/workspaces
go-work target="":
#!/usr/bin/env bash
pushd {{ gitRoot }} >/dev/null
if [[ ! -f "go.work" ]]; then # only create go.work if not exists
echo "=> go work init"
go work init
fi
if [[ -n "{{ target }}" ]]; then # generate just for the given target
echo "=> use: {{ target }}"
go work use {{ target }}
else # generate go.work with all dirs containing go.mod
for _GO_MOD_DIR in $(find . -type f -name go.mod | xargs dirname); do
echo "=> use: ${_GO_MOD_DIR}"
go work use "${_GO_MOD_DIR}"
done
fi
# run `dagger develop` for all Dagger modules, or the given module
develop mod="":
#!/usr/bin/env bash
set -e
_DAGGER_MODS="{{ mod }}"
if [[ -z "${_DAGGER_MODS}" ]]; then
mapfile -t _DAGGER_MODS < <(find . -type f -name dagger.json -print0 | xargs -0 dirname)
fi
for _DAGGER_MOD in "${_DAGGER_MODS[@]}"; do
echo "=> ${_DAGGER_MOD}: dagger develop"
pushd "${_DAGGER_MOD}" >/dev/null || exit
_DAGGER_MOD_SOURCE="$(dagger config --silent --json | jq -r '.source')"
# NOTE: use with caution!
# Dagger is opinionated about the go version compatibility. It will barf
# if the go version is greater than supported
if [[ "{{ goUpdates }}" = "true" ]]; then
_DAGGER_GO_MOD="${_DAGGER_MOD}/${_DAGGER_MOD_SOURCE}"
echo "=> ${_DAGGER_GO_MOD}: go update"
just -f "{{ gitRoot }}/justfile" go-update "${_DAGGER_GO_MOD}"
fi
dagger develop
# remove generated bits we don't want
rm -f LICENSE
just -f "{{ gitRoot }}/justfile" go-work "${_DAGGER_MOD}"
popd >/dev/null || exit 1
done
echo "=> dagger-develop: done"
# initialize a new Dagger module
[no-exit-message]
init module:
#!/usr/bin/env bash
set -euo pipefail
test ! -d {{module}} \
|| (echo "Module \"{{module}}\" already exists" && exit 1)
mkdir -p {{module}}
cd {{module}} && dagger init --sdk go --name {{module}} --source .
dagger develop -m {{module}}
[no-exit-message]
install target module:
pushd {{ target }}
dagger install {{ module }}
popd
update-scottames-daggerverse version mod="":
#!/usr/bin/env bash
set -euo pipefail
_DAGGER_MODS="{{ mod }}"
if [[ -z "${_DAGGER_MODS}" ]]; then
mapfile -t _DAGGER_MODS < <(find . -type f -name dagger.json -print0 | xargs -0 dirname)
fi
for _DAGGER_MOD in "${_DAGGER_MODS[@]}"; do
echo "=> ${_DAGGER_MOD} @ {{ version }}"
pushd "${_DAGGER_MOD}"
for mod_to_update in $( dagger config --silent --json \
| jq -r '.dependencies | .[].source' | grep 'scottames/daggerverse' \
| cut -d'@' -f1)
do
echo "=> update: ${mod_to_update}"
dagger install "${mod_to_update}@{{ version }}"
done
popd
done
import 'atomic/justfile'
import 'toolbox/fedora/justfile'