Skip to content

Commit a3f230a

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

File tree

1 file changed

+68
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)