Upload charm before OCI images in publish charm job

Currently the publish-charm task uploads the OCI
image resources and then the charm. If a charm
introduces a new OCI image resource then this
workflow wont work as charmhub is not aware of
the new resource. Uploading charm first will
enable charmhub to understand the new resource.

Change tasks to upload charm first and then the OCI
image resources.

Change-Id: I70de4f19558c62caeaa8821a3bbd9cac1fd96c0d
This commit is contained in:
Hemanth Nakkina 2024-04-20 14:01:46 +05:30
parent 28f6c50c74
commit 67770abb84
No known key found for this signature in database
GPG Key ID: 2E4970F7B143168E

View File

@ -46,6 +46,22 @@
set_fact:
metadata: "{{ metadata_file.content | b64decode | from_yaml }}"
- name: Upload charm to charmhub
register: upload_charm_output
args:
chdir: "{{ zuul.project.src_dir }}"
# 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
retries: 3
until: >
("Revision" in upload_charm_output.stdout)
- name: Extract Charm revision
set_fact:
charm_revision: "{{ upload_charm_output.stdout | regex_search('Revision ([0-9]+)', '\\1', multiline=True) | first }}"
- name: Upload oci-image to charmhub
register: upload_oci_image_output
args:
@ -70,22 +86,6 @@
resource_revision_flags: "{{ resource_revision_flags | default('') + ' --resource ' + item.item.key + ':' + (item.stdout | regex_search('Revision ([0-9]+)', '\\1', multiline=True) | first) }}"
with_items: "{{ upload_oci_image_output.results }}"
- name: Upload charm to charmhub
register: upload_charm_output
args:
chdir: "{{ zuul.project.src_dir }}"
# 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
retries: 3
until: >
("Revision" in upload_charm_output.stdout)
- name: Extract Charm revision
set_fact:
charm_revision: "{{ upload_charm_output.stdout | regex_search('Revision ([0-9]+)', '\\1', multiline=True) | first }}"
- name: Release charm
register: release_charm_output
command: charmcraft release {{ charm_build_name }} --revision {{ charm_revision }} --channel {{ publish_channel }} {{ resource_revision_flags | default("") }}