try task + build

This commit is contained in:
Jason Swank 2024-06-10 22:20:47 -04:00
parent f43022c3e4
commit afe1b6175c
2 changed files with 22 additions and 13 deletions

View File

@ -1,30 +1,24 @@
image: alpine/edge
secrets:
- 0ee986ff-5686-43cd-ac3a-1fe5b2e5dd8f
- f523ee29-5ef8-490f-8903-43ad7c49060b
- f523ee29-5ef8-490f-8903-43ad7c49060b
- 130adee5-3a8f-4035-8cad-e3d044be2961
sources:
- https://git.sr.ht/~jswank/alpine-cli
packages:
- podman
- just
- go-task
- runit
tasks:
# cgroups need to be running in order to run podman
- prep: |
sudo rc-service cgroups start
sleep 1
# build the image using the just recipe
# - sudo (-u root) is required to run podman without more setup
- build: |
cd alpine-cli
sudo --preserve-env just build
sudo --preserve-env go-task build
# publish the image using the just recipe
# - set environment variables from the ~/.envdir directory. see
# http://smarden.org/runit/chpst.8.html for details on chpst
@ -32,6 +26,6 @@ tasks:
# - sudo --preserve-env is required to pass environment variables
- publish: |
cd alpine-cli
chpst -e ~/.envdir sudo --preserve-env just registry_pass_var=GH_PAT publish
chpst -e ~/.envdir sudo --preserve-env just registry=docker.io registry_pass_var=DH_PAT publish
chpst -e ~/.envdir sudo --preserve-env just registry=quay.io registry_pass_var=QUAY_PAT publish
chpst -e ~/.envdir sudo --preserve-env go-task publish
# chpst -e ~/.envdir sudo --preserve-env just registry=docker.io registry_pass_var=DH_PAT publish
# chpst -e ~/.envdir sudo --preserve-env just registry=quay.io registry_pass_var=QUAY_PAT publish

View File

@ -1,8 +1,11 @@
version: '3'
env:
IMAGE: jswank/alpine-cli
NAME: alpine-cli
TAG: latest
vars:
TAG:
sh: 'grep ^FROM Dockerfile | cut -d: -f2'
tasks:
default:
cmds:
@ -13,3 +16,15 @@ tasks:
- (podman manifest exists {{.IMAGE}}:{{.TAG}} && podman manifest rm {{.IMAGE}}:{{.TAG}}) || true
- podman manifest create {{.IMAGE}}:{{.TAG}}
- podman build --platform linux/amd64,linux/arm64 --manifest {{.IMAGE}}:{{.TAG}} {{.CLI_ARGS}} -f Dockerfile ctx
publish:
desc: publish the image
cmds:
- podman tag {{.IMAGE}}:{{.TAG}} {{.REGISTRY}}/{{.IMAGE}}:{{.ALT_TAG}}
- echo "${{.REGISTRY_PASS_VAR}}" | podman login {{.REGISTRY}} -u {{.REGISTRY_USER}} --password-stdin
- podman manifest push {{.REGISTRY}}/{{.IMAGE}}:{{.ALT_TAG}}
- podman logout {{.REGISTRY}}
vars:
REGISTRY_PASS_VAR: GH_PAT
REGISTRY: ghcr.io
REGISTRY_USER: jswank
ALT_TAG: '{{.TAG}}'