8686 build :
8787 desc : Build the project; docker images, compiled binaries, etc.
8888 vars :
89+ PUBLISH : ' {{ ' {{.PUBLISH | default "false"}}' }}'
8990 TIMESTAMP :
9091 sh : ' {{ ' {{.RUN_SCRIPT}}' }} {{ '{{.SCRIPTS_DIR}}' }}/get_rfc3339_timestamp.py'
9192 EPOCH :
@@ -98,12 +99,12 @@ tasks:
9899 OUTPUT_FILE : ' {{ ' {{.IMAGE_NAME | replace "/" "_"}}' }}_latest_{{ '{{.PLATFORM_SUFFIX}}' }}.tar'
99100 DESCRIPTION : ' {{ cookiecutter.project_short_description }}'
100101 cmds :
101- # First build: load if same platform, output to file if cross-platform
102+ # First build: load if same platform, output to file if cross-platform, or push if PUBLISH is true
102103 - |
103104 docker buildx build \
104105 --platform {{ '{{.BUILD_PLATFORM}}' }} \
105106 --pull \
106- {{ '{{if eq .PLATFORM .LOCAL_PLATFORM}}' }}--load{{ ' {{else}}' }}-o type=oci,dest="{{ '{{.OUTPUT_FILE}}' }}"{{ ' {{end}}' }} \
107+ {{ '{{if eq .PUBLISH "true"}}' }}--push{{ "{{else if eq . PLATFORM .LOCAL_PLATFORM}}" }}--load{{ " {{else}}" }}-o type=oci,dest="{{ '{{.OUTPUT_FILE}}' }}"{{ " {{end}}" }} \
107108 {{ '{{if eq .GITHUB_ACTIONS "true"}}' }}--cache-from type=gha --cache-to type=gha,mode=max{{ '{{end}}' }} \
108109 --build-arg NAME="{{ '{{.PROJECT_SLUG}}' }}" \
109110 --build-arg DESCRIPTION="{{ '{{.DESCRIPTION}}' }}" \
@@ -243,29 +244,16 @@ tasks:
243244
244245 publish :
245246 desc : Publish the project artifacts; docker images, compiled binaries, etc.
246- vars :
247- INPUT_FILE :
248- # Find the latest tar file for cross-platform builds
249- sh : ' {{ ' {{if and (ne .LOCAL_PLATFORM .PLATFORM) (ne .PLATFORM "all")}}' }}ls {{ '{{.IMAGE_NAME | replace "/" "_"}}' }}_*_{{ '{{.PLATFORM | replace "/" "_" | replace "," "_"}}' }}.tar 2>/dev/null | sort -r | head -1{{ '{{end}}' }}'
250- preconditions :
251- - sh : which docker
252- msg : " docker is required for publishing"
247+ requires :
248+ vars :
249+ - VERSION
253250 cmds :
254- - |
255- {{ '{{if or (eq .LOCAL_PLATFORM .PLATFORM) (eq .PLATFORM "all")}}' }}
256- docker push {{ '{{.IMAGE_NAME}}:{{.VERSION}}' }}
257- docker push {{ '{{.IMAGE_NAME}}:latest' }}
258- {{ '{{else}}' }}
259- echo "Publishing cross-platform image from {{ '{{.INPUT_FILE}}' }}"
260- docker run --rm \
261- -v "$(pwd):/src" \
262- -w /src \
263- quay.io/skopeo/stable:latest \
264- copy oci-archive:{{ '{{.INPUT_FILE}}' }} docker://{{ '{{.IMAGE_NAME}}:{{.VERSION}}' }}
265- docker run --rm \
266- -v "$(pwd):/src" \
267- -w /src \
268- quay.io/skopeo/stable:latest \
269- copy oci-archive:{{ '{{.INPUT_FILE}}' }} docker://{{ '{{.IMAGE_NAME}}:latest' }}
270- {{ '{{end}}' }}
251+ - task : build
252+ vars :
253+ PUBLISH : ' true'
254+ VERSION : ' {{ ' {{.VERSION}}' }}'
255+ PLATFORM : ' {{ ' {{.PLATFORM | default "all"}}' }}'
256+ DOCKER_BUILDX_CUSTOM_ARGS : ' {{ ' {{.DOCKER_BUILDX_CUSTOM_ARGS | default ""}}' }}'
257+ DOCKER_BUILDX_CUSTOM_TAGS : ' {{ ' {{.DOCKER_BUILDX_CUSTOM_TAGS | default ""}}' }}'
258+ DOCKER_BUILDX_CUSTOM_CONTEXT : ' {{ ' {{.DOCKER_BUILDX_CUSTOM_CONTEXT}}' }}'
271259{%- endif %}
0 commit comments