outline-server/third_party/Taskfile.yml
2026-05-11 13:11:30 +02:00

50 lines
2 KiB
YAML

version: '3'
requires:
vars: [OUTPUT_BASE]
tasks:
prometheus:debug:
cmds:
- echo {{.GOOS}}
prometheus:download-*-*:
desc: Download and extract prometheus binary
vars:
VERSION: '3.5.3'
GOOS: '{{index .MATCH 0}}'
GOARCH: '{{index .MATCH 1}}'
TEMPFILE: {sh: mktemp}
SHA256: '{{printf "%v/%v" .GOOS .GOARCH | get
(dict
"linux/amd64" "8c30b9d99664e39b0363c0ba54fab30a7958e9d3de27246bf26ed85e6cfb8946"
"linux/arm64" "11457bc76cab34f5ac05ba05fb80cfca1e8be7e4b31ae7c054879ce1066cb9a5"
"darwin/amd64" "408eec9f1138ad5d30509038b2e8ae798ed2910e7faaa0e7f61ca22db222aaf5"
"darwin/arm64" "1883df59fbea254b2e3f112feb6406533be7c062aef20f5d0b40b9e9acdb77e2"
)
}}'
TARGET_DIR: '{{joinPath .OUTPUT_BASE "prometheus" .GOOS .GOARCH}}'
TARGET: '{{joinPath .TARGET_DIR "prometheus"}}'
generates: ['{{.TARGET}}']
sources: ['Taskfile.yml']
preconditions:
- {sh: "[[ '{{.GOOS}}' =~ 'linux|darwin' ]]", msg: "invalid GOOS {{.GOOS}}"}
- {sh: "[[ '{{.GOARCH}}' =~ 'amd64|arm64' ]]", msg: "invalid GOARCH {{.GOARCH}}"}
cmds:
- node '{{joinPath .ROOT_DIR "src/build/download_file.mjs"}}' --url='https://github.com/prometheus/prometheus/releases/download/v{{.VERSION}}/prometheus-{{.VERSION}}.{{.GOOS}}-{{.GOARCH}}.tar.gz' --out='{{.TEMPFILE}}' --sha256='{{.SHA256}}'
- defer: rm -f '{{.TEMPFILE}}'
- mkdir -p '{{.TARGET_DIR}}'
- tar -zx -f '{{.TEMPFILE}}' --strip-components=1 -C '{{.TARGET_DIR}}' 'prometheus-{{.VERSION}}.{{.GOOS}}-{{.GOARCH}}/prometheus'
- chmod +x '{{.TARGET}}'
prometheus:copy-*-*:
desc: Copy prometheus binary to target directory
requires:
vars: [TARGET_DIR]
vars:
GOOS: '{{index .MATCH 0}}'
GOARCH: '{{index .MATCH 1}}'
cmds:
- task: prometheus:download-{{.GOOS}}-{{.GOARCH}}
- mkdir -p '{{.TARGET_DIR}}'
- cp -R '{{joinPath .OUTPUT_BASE "prometheus" .GOOS .GOARCH}}'/* '{{.TARGET_DIR}}/'