Skip to content

Commit e67d1fd

Browse files
committed
plugin releases
1 parent 8de1344 commit e67d1fd

2 files changed

Lines changed: 40 additions & 53 deletions

File tree

.github/workflows/cockpit-plugins.yml

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ on:
1111
tags:
1212
- "*"
1313
workflow_dispatch:
14-
inputs:
15-
publish_ref:
16-
description: Release/tag name to publish plugin bundles under
17-
required: false
18-
1914
permissions:
2015
contents: write
2116

@@ -125,18 +120,17 @@ jobs:
125120
puts "s3_ref=#{defaults.fetch("terrarium_cockpit_s3_ref")}"
126121
RUBY
127122
128-
- name: Resolve publish ref
129-
id: ref
123+
- name: Resolve plugin release refs
124+
id: release_refs
130125
env:
131-
INPUT_PUBLISH_REF: ${{ github.event.inputs.publish_ref }}
126+
ZFS_REF: ${{ steps.refs.outputs.zfs_ref }}
127+
S3_REF: ${{ steps.refs.outputs.s3_ref }}
132128
run: |
133-
if [ -n "${INPUT_PUBLISH_REF}" ]; then
134-
echo "value=${INPUT_PUBLISH_REF}" >> "${GITHUB_OUTPUT}"
135-
elif [ "${GITHUB_REF_TYPE}" = "tag" ]; then
136-
echo "value=${GITHUB_REF_NAME}" >> "${GITHUB_OUTPUT}"
137-
else
138-
echo "value=cockpit-plugins-main" >> "${GITHUB_OUTPUT}"
139-
fi
129+
sanitize() {
130+
printf '%s' "$1" | tr -cs 'A-Za-z0-9._-' '-'
131+
}
132+
echo "zfs_release=cockpit-plugin-zfs-$(sanitize "${ZFS_REF}")" >> "${GITHUB_OUTPUT}"
133+
echo "s3_release=cockpit-plugin-s3-$(sanitize "${S3_REF}")" >> "${GITHUB_OUTPUT}"
140134
141135
- name: Prepare release assets
142136
env:
@@ -148,20 +142,38 @@ jobs:
148142
}
149143
ZFS_REF_SAFE="$(sanitize "${ZFS_REF}")"
150144
S3_REF_SAFE="$(sanitize "${S3_REF}")"
151-
mkdir -p release-assets
145+
mkdir -p release-assets/zfs release-assets/s3
152146
for BASENAME in \
153147
"cockpit-plugin-zfs-${ZFS_REF_SAFE}-linux-amd64.tar.gz" \
154-
"cockpit-plugin-zfs-${ZFS_REF_SAFE}-linux-arm64.tar.gz" \
148+
"cockpit-plugin-zfs-${ZFS_REF_SAFE}-linux-arm64.tar.gz"
149+
do
150+
cp "artifacts/${BASENAME%.tar.gz}/${BASENAME}" "release-assets/zfs/${BASENAME}"
151+
done
152+
for BASENAME in \
155153
"cockpit-plugin-s3-${S3_REF_SAFE}-linux-amd64.tar.gz" \
156154
"cockpit-plugin-s3-${S3_REF_SAFE}-linux-arm64.tar.gz"
157155
do
158-
cp "artifacts/${BASENAME%.tar.gz}/${BASENAME}" "release-assets/${BASENAME}"
156+
cp "artifacts/${BASENAME%.tar.gz}/${BASENAME}" "release-assets/s3/${BASENAME}"
159157
done
160158
161-
- name: Publish plugin bundles
159+
- name: Publish cockpit-zfs bundles
160+
uses: softprops/action-gh-release@v2
161+
with:
162+
tag_name: ${{ steps.release_refs.outputs.zfs_release }}
163+
target_commitish: ${{ github.sha }}
164+
name: ${{ steps.release_refs.outputs.zfs_release }}
165+
files: |
166+
release-assets/zfs/*.tar.gz
167+
prerelease: false
168+
overwrite_files: true
169+
170+
- name: Publish cockpit-s3 bundles
162171
uses: softprops/action-gh-release@v2
163172
with:
164-
tag_name: ${{ steps.ref.outputs.value }}
173+
tag_name: ${{ steps.release_refs.outputs.s3_release }}
174+
target_commitish: ${{ github.sha }}
175+
name: ${{ steps.release_refs.outputs.s3_release }}
165176
files: |
166-
release-assets/*.tar.gz
167-
prerelease: ${{ steps.ref.outputs.value == 'cockpit-plugins-main' || contains(steps.ref.outputs.value, '-') }}
177+
release-assets/s3/*.tar.gz
178+
prerelease: false
179+
overwrite_files: true

ansible/roles/cockpit_plugins/tasks/main.yml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,12 @@
1313
}.get(ansible_architecture, '')
1414
}}
1515
16-
- name: Resolve exact Terrarium git tag
17-
ansible.builtin.command: git -C {{ terrarium_repo_dir }} describe --tags --exact-match
18-
register: terrarium_cockpit_plugin_repo_tag
19-
failed_when: false
20-
changed_when: false
21-
22-
- name: Resolve Terrarium git branch
23-
ansible.builtin.command: git -C {{ terrarium_repo_dir }} branch --show-current
24-
register: terrarium_cockpit_plugin_repo_branch
25-
failed_when: false
26-
changed_when: false
27-
28-
- name: Choose Cockpit plugin bundle release ref
29-
ansible.builtin.set_fact:
30-
terrarium_cockpit_plugin_bundle_ref: >-
31-
{{
32-
terrarium_cockpit_plugin_repo_tag.stdout
33-
if terrarium_cockpit_plugin_repo_tag.rc == 0 and terrarium_cockpit_plugin_repo_tag.stdout | length > 0
34-
else (
35-
terrarium_cockpit_plugin_bundle_main_ref
36-
if terrarium_cockpit_plugin_repo_branch.rc == 0 and terrarium_cockpit_plugin_repo_branch.stdout == 'main'
37-
else ''
38-
)
39-
}}
40-
4116
- name: Compute sanitized Cockpit plugin refs
4217
ansible.builtin.set_fact:
4318
terrarium_cockpit_zfs_ref_safe: "{{ terrarium_cockpit_zfs_ref | regex_replace('[^A-Za-z0-9._-]+', '-') }}"
4419
terrarium_cockpit_s3_ref_safe: "{{ terrarium_cockpit_s3_ref | regex_replace('[^A-Za-z0-9._-]+', '-') }}"
20+
terrarium_cockpit_zfs_bundle_release: "cockpit-plugin-zfs-{{ terrarium_cockpit_zfs_ref | regex_replace('[^A-Za-z0-9._-]+', '-') }}"
21+
terrarium_cockpit_s3_bundle_release: "cockpit-plugin-s3-{{ terrarium_cockpit_s3_ref | regex_replace('[^A-Za-z0-9._-]+', '-') }}"
4522

4623
- name: Compute versioned Cockpit plugin bundle filenames
4724
ansible.builtin.set_fact:
@@ -62,27 +39,25 @@
6239

6340
- name: Download prebuilt cockpit-zfs bundle
6441
ansible.builtin.get_url:
65-
url: "https://github.com/{{ terrarium_cockpit_plugin_bundle_repo }}/releases/download/{{ terrarium_cockpit_plugin_bundle_ref }}/{{ terrarium_cockpit_zfs_bundle_filename }}"
66-
dest: "/tmp/{{ terrarium_cockpit_plugin_bundle_ref }}-{{ terrarium_cockpit_zfs_bundle_filename }}"
42+
url: "https://github.com/{{ terrarium_cockpit_plugin_bundle_repo }}/releases/download/{{ terrarium_cockpit_zfs_bundle_release }}/{{ terrarium_cockpit_zfs_bundle_filename }}"
43+
dest: "/tmp/{{ terrarium_cockpit_zfs_bundle_release }}-{{ terrarium_cockpit_zfs_bundle_filename }}"
6744
mode: "0644"
6845
register: terrarium_cockpit_zfs_bundle_download
6946
failed_when: false
7047
when:
7148
- terrarium_cockpit_plugin_bundle_enabled
7249
- terrarium_cockpit_plugin_bundle_arch | length > 0
73-
- terrarium_cockpit_plugin_bundle_ref | length > 0
7450

7551
- name: Download prebuilt cockpit-s3 bundle
7652
ansible.builtin.get_url:
77-
url: "https://github.com/{{ terrarium_cockpit_plugin_bundle_repo }}/releases/download/{{ terrarium_cockpit_plugin_bundle_ref }}/{{ terrarium_cockpit_s3_bundle_filename }}"
78-
dest: "/tmp/{{ terrarium_cockpit_plugin_bundle_ref }}-{{ terrarium_cockpit_s3_bundle_filename }}"
53+
url: "https://github.com/{{ terrarium_cockpit_plugin_bundle_repo }}/releases/download/{{ terrarium_cockpit_s3_bundle_release }}/{{ terrarium_cockpit_s3_bundle_filename }}"
54+
dest: "/tmp/{{ terrarium_cockpit_s3_bundle_release }}-{{ terrarium_cockpit_s3_bundle_filename }}"
7955
mode: "0644"
8056
register: terrarium_cockpit_s3_bundle_download
8157
failed_when: false
8258
when:
8359
- terrarium_cockpit_plugin_bundle_enabled
8460
- terrarium_cockpit_plugin_bundle_arch | length > 0
85-
- terrarium_cockpit_plugin_bundle_ref | length > 0
8661

8762
- name: Determine whether prebuilt cockpit-zfs bundle is usable
8863
ansible.builtin.set_fact:

0 commit comments

Comments
 (0)