Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.9 KB

release_charm.md

File metadata and controls

47 lines (38 loc) · 1.9 KB

Workflow file: release_charm.yaml

Usage

Add .yaml file to .github/workflows/

# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
name: Release to Charmhub

on:
  push:
    branches:
      - main

jobs:
  build:
    name: Build charm
    uses: canonical/data-platform-workflows/.github/workflows/[email protected]

  release:
    name: Release charm
    needs:
      - build
    uses: canonical/data-platform-workflows/.github/workflows/[email protected]
    with:
      channel: latest/edge
      artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
    secrets:
      charmhub-token: ${{ secrets.CHARMHUB_TOKEN }}
    permissions:
      contents: write  # Needed to create GitHub release

metadata.yaml required

This workflow requires the charm directory (directory with charmcraft.yaml) to contain a metadata.yaml file with the name key. If the charm uses OCI images (Kubernetes only), metadata.yaml must also contain the resources key. Syntax: https://juju.is/docs/sdk/metadata-yaml

"Unified charmcraft.yaml syntax" (where actions.yaml, charmcraft.yaml, config.yaml, and metadata.yaml are combined into a single charmcraft.yaml file) is not supported.

Rationale

It is simpler (for CI/CD tooling, developers, etc.) to have a consistent approach—either "unified charmcraft.yaml syntax" or separate files.

With "unified charmcraft.yaml syntax", charmcraft extracts the data back into actions.yaml, config.yaml, and metadata.yaml when packing the charm—but it removes comments from the YAML.

Benefits of separate files:

  • no difference in files between source repository and *.charm artifact that would be confusing to developers
  • comments in YAML files retained
  • charmcraft just copies the files into the *.charm artifact, instead of using more complicated logic to extract that information (which would create more surface area for bugs)