Fix error when publishing charmcraft.yaml only charm
Since charmcraft 2.5, the files: metadata.yaml, actions.yaml, and config.yaml have been merged into charmcraft.yaml. The publishing job fails because it expects the metadata.yaml to be present. This change checks for which file to use. The keys looked up in metadata.yaml for this specific task have the same schema in charmcraft.yaml Change-Id: I94ea3b8230e5dbf7d2474410fba7acc5e0836a63
This commit is contained in:
parent
619976fe43
commit
86ac0fd58d
@ -19,10 +19,28 @@
|
||||
include_role:
|
||||
name: ensure-docker
|
||||
|
||||
- name: Get metadata.yaml information
|
||||
stat:
|
||||
path: "{{ zuul.executor.work_root+'/'+zuul.project.src_dir+'/charms/'+charm_build_name+'/metadata.yaml'"
|
||||
register: metadata_file
|
||||
|
||||
- name: Get charmcraft.yaml information
|
||||
stat:
|
||||
path: "zuul.executor.work_root+'/'+zuul.project.src_dir+'/charms/'+charm_build_name+'/charmcraft.yaml'"
|
||||
register: charmcraft_file
|
||||
|
||||
- name: Register resource file
|
||||
set_fact:
|
||||
resource_file: "{{ metadata_file.stat.exists | ternary(metadata_file.stat.path, charmcraft_file.stat.path) }}"
|
||||
|
||||
- name: Which metadata file is used
|
||||
debug:
|
||||
msg: "{{ resource_file }}"
|
||||
|
||||
- name: Upload oci-image to charmhub
|
||||
register: upload_oci_image_output
|
||||
vars:
|
||||
metadata: "{{ lookup('file', zuul.executor.work_root+'/'+zuul.project.src_dir+'/charms/'+charm_build_name+'/metadata.yaml') | from_yaml }}"
|
||||
metadata: "{{ lookup('file', resource_file) | from_yaml }}"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
shell: |
|
||||
@ -52,8 +70,7 @@
|
||||
# TODO: The below command can error out with a message that says
|
||||
# upload with that digest already exists. This case need to be handled.
|
||||
# More details https://github.com/canonical/charmcraft/issues/826
|
||||
command:
|
||||
charmcraft upload -v --name {{ charm_build_name }} {{ charm_build_name }}.charm
|
||||
command: charmcraft upload -v --name {{ charm_build_name }} {{ charm_build_name }}.charm
|
||||
retries: 3
|
||||
until: >
|
||||
("Revision" in upload_charm_output.stdout)
|
||||
@ -64,8 +81,7 @@
|
||||
|
||||
- name: Release charm
|
||||
register: release_charm_output
|
||||
command:
|
||||
charmcraft release {{ charm_build_name }} --revision {{ charm_revision }} --channel {{ publish_channel }} {{ resource_revision_flags | default("") }}
|
||||
command: charmcraft release {{ charm_build_name }} --revision {{ charm_revision }} --channel {{ publish_channel }} {{ resource_revision_flags | default("") }}
|
||||
retries: 3
|
||||
until: >
|
||||
("Revision" in release_charm_output.stdout)
|
||||
|
Loading…
x
Reference in New Issue
Block a user