Skip to content

Commit 717a49b

Browse files
committed
add scripts for adapting plugin.json
add ci step to check that plugin.json is not modified if one of the scripts is executed.
1 parent 5a208c6 commit 717a49b

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

.github/build/action.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,9 @@ runs:
3434
mv ./src/plugin.new.json ./src/plugin.json
3535
if: ${{ inputs.release == 'false' }}
3636

37-
- name: Adapt plugin id and name of plugin
37+
- name: Adapt README.md
3838
shell: bash
3939
run: |
40-
# rename plugin description
41-
jq ".info.description = \"Checkmk data source for Checkmk Cloud Edition\"" ./src/plugin.json > ./src/plugin.new.json
42-
mv ./src/plugin.new.json ./src/plugin.json
43-
# rename plugin name
44-
jq ".name = \"Checkmk for Cloud Edition\"" ./src/plugin.json > ./src/plugin.new.json
45-
mv ./src/plugin.new.json ./src/plugin.json
46-
# rename plugin id
47-
jq '.id = "checkmk-cloud-datasource"' ./src/plugin.json > ./src/plugin.new.json
48-
mv ./src/plugin.new.json ./src/plugin.json
49-
# rename README.md
5040
OLD_NAME="Checkmk data source"
5141
NEW_NAME="Checkmk data source for Checkmk Cloud Edition"
5242
# make sure we can actually find and replace OLD_NAME in README.md
@@ -57,13 +47,15 @@ runs:
5747
- name: Build signed plugin and test frontend
5848
shell: bash
5949
run: |
50+
# yarn build script will adapt src/plugin.json via utils/plugin_json*.sh
6051
yarn run build:cloud
6152
yarn run sign
6253
if: ${{ inputs.signed == 'true'}}
6354

6455
- name: Build unsigned plugin and test frontend
6556
shell: bash
6657
run: |
58+
# yarn build script will adapt src/plugin.json via utils/plugin_json*.sh
6759
yarn run build
6860
if: ${{ inputs.signed == 'false' }}
6961

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ on:
99
- cron: '38 0 * * *' # every day at randint(0, 60) minutes after midnight
1010

1111
jobs:
12+
test-plugin-json:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Install dependencies
18+
run: |
19+
sudo apt-get install jq
20+
21+
- name: plugin_json_to_unsigned.sh should not change src.plugin.json
22+
run: |
23+
# src/plugin.json and plugin_json_to_cloud.sh
24+
# should contain the same ids and strings
25+
# this test makes sure they stay in sync
26+
jq --sort-keys . src/plugin.json > /tmp/before.json
27+
bash utils/plugin_json_to_unsigned.sh
28+
jq --sort-keys . src/plugin.json > /tmp/after.json
29+
diff /tmp/before.json /tmp/after.json
30+
1231
build:
1332
runs-on: ubuntu-latest
1433
outputs:

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "3.0.1",
44
"description": "",
55
"scripts": {
6-
"build": "webpack -c ./webpack.config.ts --env production",
7-
"build:cloud": "BUILD_EDITION=CLOUD webpack -c ./webpack.config.ts --env production",
6+
"build": "bash utils/plugin_json_to_unsigned.sh && webpack -c ./webpack.config.ts --env production",
7+
"build:cloud": "bash utils/plugin_json_to_cloud.sh && BUILD_EDITION=CLOUD webpack -c ./webpack.config.ts --env production",
88
"dev": "webpack -w -c ./webpack.config.ts --env development",
99
"lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
1010
"lint:fix": "yarn lint --fix",

utils/plugin_json_to_cloud.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
jq ".info.description = \"Checkmk data source for Checkmk Cloud Edition\"" ./src/plugin.json > ./src/plugin.new.json
2+
mv ./src/plugin.new.json ./src/plugin.json
3+
4+
jq ".name = \"Checkmk for Cloud Edition\"" ./src/plugin.json > ./src/plugin.new.json
5+
mv ./src/plugin.new.json ./src/plugin.json
6+
7+
jq '.id = "checkmk-cloud-datasource"' ./src/plugin.json > ./src/plugin.new.json
8+
mv ./src/plugin.new.json ./src/plugin.json

utils/plugin_json_to_unsigned.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
jq ".info.description = \"Checkmk data source\"" ./src/plugin.json > ./src/plugin.new.json
2+
mv ./src/plugin.new.json ./src/plugin.json
3+
4+
jq ".name = \"Checkmk\"" ./src/plugin.json > ./src/plugin.new.json
5+
mv ./src/plugin.new.json ./src/plugin.json
6+
7+
jq '.id = "tribe-29-checkmk-datasource"' ./src/plugin.json > ./src/plugin.new.json
8+
mv ./src/plugin.new.json ./src/plugin.json

0 commit comments

Comments
 (0)