-
Notifications
You must be signed in to change notification settings - Fork 10
146 lines (143 loc) · 5.71 KB
/
publish_charm.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
name: Publish charm
on:
workflow_call:
inputs:
channel:
type: string
required: false
description: 'Destination Channel'
identifier:
type: string
description: >-
The matching integration test workflow job identifier, see identifier in the integration test workflow input.
default: ""
resource-mapping:
type: string
description: >-
Associate rock image names with corresponding resource names specified in the charm metadata.
If not defined, the suffix '-image' to the rock image name will be append.
For instance, a rock image named 'my-rock' will be uploaded as the charm OCI resource named 'my-rock-image'.
default: "{}"
working-directory:
type: string
description: The working directory for jobs
default: "./"
tag-prefix:
type: string
required: false
description: |
Tag prefix, useful when bundling multiple charms in the same repo.
charmcraft-channel:
description: Charmcraft channel to use for publishing the charm and resources
type: string
default: latest/stable
integration-test-workflow-file:
description: The filename of the integration test workflow file.
type: string
default: "integration_test.yaml"
workflow-run-id:
description: >-
Use the newly built charms and images in this workflow run as the new version to upload.
If these are not provided, the system will default to using charms and rocks from the most
recent successful integration test that matches the git tree ID.
type: string
default: ""
env:
REGISTRY: ghcr.io
OWNER: ${{ github.repository_owner }}
CHARMCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: "true"
ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: "true"
jobs:
select-channel:
runs-on: ubuntu-latest
outputs:
destination-channel: ${{ steps.select-channel.outputs.name }}
steps:
- name: Select charmhub channel
uses: canonical/charming-actions/channel@2.6.3
id: select-channel
publish-charm:
name: Publish charm to ${{ inputs.channel || needs.select-channel.outputs.destination-channel }}
runs-on: ubuntu-latest
needs: [select-channel]
outputs:
charm-directory: ${{ steps.publish.outputs.charm-directory }}
steps:
- uses: actions/checkout@v4.2.2
- run: sudo snap install charmcraft --channel ${{ inputs.charmcraft-channel }} --classic
# required to use skopeo embedded within rockcraft - otherwise a docker error
# "io: read/write on closed pipe" will happen
- run: sudo snap install rockcraft --classic
- uses: canonical/operator-workflows/internal/publish@main
id: publish
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
charmhub-token: ${{ secrets.CHARMHUB_TOKEN }}
identifier: ${{ inputs.identifier }}
resource-mapping: ${{ inputs.resource-mapping }}
working-directory: ${{ inputs.working-directory }}
workflow-file: ${{ inputs.integration-test-workflow-file }}
workflow-run-id: ${{ inputs.workflow-run-id }}
- name: Change directory
run: |
TEMP_DIR=$(mktemp -d)
cp -rp ./${{ steps.publish.outputs.charm-directory }}/. $TEMP_DIR
rm -rf .* * || :
cp -rp $TEMP_DIR/. .
rm -rf $TEMP_DIR
ls -lah
- name: Upload charm to charmhub
uses: canonical/charming-actions/upload-charm@2.6.3
with:
built-charm-path: ${{ steps.publish.outputs.charms }}
charmcraft-channel: ${{ inputs.charmcraft-channel }}
credentials: ${{ secrets.CHARMHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
channel: ${{ inputs.channel || needs.select-channel.outputs.destination-channel }}
tag-prefix: ${{ inputs.tag-prefix }}
upload-image: false
draft-publish-docs:
name: Draft publish docs
runs-on: ubuntu-24.04
needs: [publish-charm]
defaults:
run:
working-directory: ${{ needs.publish-charm.outputs.charm-directory }}
steps:
- uses: actions/checkout@v4.2.2
- name: Search for docs folder
id: docs-exist
run: echo "docs_exist=$([[ -d docs ]] && echo 'True' || echo 'False')" >> $GITHUB_OUTPUT
- name: Publish documentation
if: ${{ steps.docs-exist.outputs.docs_exist == 'True' && env.discourse_api_username != '' && env.discourse_api_key != '' }}
uses: canonical/discourse-gatekeeper@stable
env:
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
discourse_api_key: ${{ secrets.DISCOURSE_API_KEY }}
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
discourse_api_key: ${{ secrets.DISCOURSE_API_KEY }}
dry_run: true
github_token: ${{ secrets.GITHUB_TOKEN }}
charm_dir: ${{ needs.publish-charm.outputs.charm-directory }}
release-charm-libs:
name: Release charm libs
runs-on: ubuntu-24.04
needs: [ publish-charm ]
steps:
- uses: actions/checkout@v4.2.2
- name: Change directory
run: |
TEMP_DIR=$(mktemp -d)
cp -rp ./${{ needs.publish-charm.outputs.charm-directory }}/. $TEMP_DIR
rm -rf .* * || :
cp -rp $TEMP_DIR/. .
rm -rf $TEMP_DIR
- uses: canonical/charming-actions/release-libraries@2.6.3
name: Release libs
with:
credentials: ${{ secrets.CHARMHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}