Skip to content

Commit a4109ba

Browse files
committed
github: Add workflow to draft plugin releases
Signed-off-by: Evangelos Skopelitis <[email protected]>
1 parent b096ca6 commit a4109ba

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Create plugin release draft
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
plugin:
7+
description: 'The plugin name (e.g., flux)'
8+
required: true
9+
type: string
10+
version:
11+
description: 'The plugin version (e.g., 0.1.0)'
12+
required: true
13+
type: string
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout cpde
20+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
24+
with:
25+
node-version: '20'
26+
27+
- name: Build plugin tarball
28+
id: build_tarball
29+
run: |
30+
PLUGIN="${{ github.event.inputs.plugin }}"
31+
cd $PLUGIN
32+
npm install
33+
npm run build
34+
OUTPUT=$(npx @kinvolk/headlamp-plugin package | tail -n2)
35+
TARBALL=$(echo "$OUTPUT" | head -n1 | sed -E 's/Created tarball: "([^"]+)".*/\1/')
36+
CHECKSUM=$(echo "$OUTPUT" | tail -n1 | sed -E 's/Tarball checksum \(sha256\): (.*)/\1/')
37+
echo "tarball_path=$TARBALL" >> $GITHUB_ENV
38+
echo "checksum=$CHECKSUM" >> $GITHUB_ENV
39+
40+
- name: Create release draft and push tarball
41+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
42+
with:
43+
draft: true
44+
token: ${{ secrets.GITHUB_TOKEN }}
45+
name: "${{ github.event.inputs.plugin }} ${{ github.event.inputs.version }}"
46+
body: Draft release for ${{ github.event.inputs.plugin }} version ${{ github.event.inputs.version }}
47+
files: ${{ steps.build_tarball.outputs.tarball_path }}
48+
env:
49+
GITHUB_TOKEN: ${{ github.repository }}
50+
51+
- name: Update ArtifactHub pkg file
52+
env:
53+
PLUGIN: ${{ github.event.inputs.plugin }}
54+
VERSION: ${{ github.event.inputs.version }}
55+
TAR_PATH: ${{ steps.build_tarball.outputs.tarball_path }}
56+
CHECKSUM: ${{ steps.build_tarball.outputs.checksum }}
57+
run: |
58+
PKG_FILE="${PLUGIN}/artifacthub-pkg.yml"
59+
TAR_URL="https://github.com/headlamp-k8s/plugins/releases/download/${PLUGIN}-${VERSION}/$(basename $TAR_PATH)"
60+
sed -i "s|^\(headlamp/plugin/archive-url:\).*|\1 \"$TAR_URL\"|g" "$PKG_FILE"
61+
sed -i "s|^\(headlamp/plugin/archive-checksum:\).*|\1 \"SHA256:$CHECKSUM\"|g" "$PKG_FILE"
62+
63+
echo "ArtifactHub pkg file updated. Please review the changes below and commit manually:"
64+
git diff "$PKG_FILE"
65+

0 commit comments

Comments
 (0)