Skip to content

Commit 818b64a

Browse files
committed
redesigning plugin release
1 parent 22c9c58 commit 818b64a

File tree

2 files changed

+122
-31
lines changed

2 files changed

+122
-31
lines changed

.github/workflows/release.yml

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,40 +53,21 @@ jobs:
5353
with:
5454
repository: ${{ github.repository_owner }}/crane-plugins
5555
token: ${{ secrets.PLUGIN_RELEASE }}
56+
path: crane-plugins
57+
58+
- name: setup python
59+
uses: actions/setup-python@v2
60+
with:
61+
python-version: 3.8
5662

5763
- name: Updating index file and adding manifest
64+
shell: bash
5865
run: |
59-
cat << EOF >> index.yml
60-
OpenShiftPlugin-${{ github.event.inputs.version }}: https://github.com/${{ github.repository_owner }}/crane-plugins/raw/main/plugins/Openshift/OpenShiftPlugin-${{ github.event.inputs.version }}.yml
61-
EOF
62-
mkdir -p plugins/Openshift
63-
cat << EOF >> plugins/Openshift/OpenShiftPlugin-${{ github.event.inputs.version }}.yml
64-
name: OpenShiftPlugin
65-
shortDescription: OpenShiftPlugin
66-
description: this is OpenShiftPlugin
67-
version: ${{ github.event.inputs.version }}
68-
binaries:
69-
- os: linux
70-
arch: amd64
71-
uri: https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.version }}/amd64-linux-openshiftplugin-${{ github.event.inputs.version }}
72-
- os: darwin
73-
arch: amd64
74-
uri: https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.version }}/amd64-darwin-openshiftplugin-${{ github.event.inputs.version }}
75-
- os: darwin
76-
arch: arm64
77-
uri: https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.version }}/arm64-darwin-openshiftplugin-${{ github.event.inputs.version }}
78-
optionalFields:
79-
- flagName: "strip-default-pull-secrets"
80-
help: "Whether to strip Pod and BuildConfig default pull secrets (beginning with builder/default/deployer-dockercfg-) that aren't replaced by the map param pull-secret-replacement"
81-
example: "true"
82-
- flagName: "pull-secret-replacement"
83-
help: "Map of pull secrets to replace in Pods and BuildConfigs while transforming in format secret1=destsecret1,secret2=destsecret2[...]"
84-
example: "default-dockercfg-h4n7g=default-dockercfg-12345,builder-dockercfg-abcde=builder-dockercfg-12345"
85-
- flagName: "registry-replacement"
86-
help: "Map of image registry paths to swap on transform, in the format original-registry1=target-registry1,original-registry2=target-registry2..."
87-
example: "docker-registry.default.svc:5000=image-registry.openshift-image-registry.svc:5000,docker.io/foo=quay.io/bar"
88-
EOF
89-
66+
pip install pyyaml
67+
tree /home/runner/work/crane-plugin-openshift/crane-plugin-openshift/main
68+
cd crane-plugins
69+
python ~/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/main/.github/workflows/script.py "${{ github.event.inputs.version }}" "${{ github.repository_owner }}" "${{ github.repository }}"
70+
9071
- name: Create Pull Request against crane-plugins
9172
uses: peter-evans/create-pull-request@v3
9273
with:
@@ -96,3 +77,4 @@ jobs:
9677
body: Update index and add manifest to include version ${{ github.event.inputs.version }} of openshift plugin
9778
branch: OpenShiftPlugin
9879
base: main
80+
path: crane-plugins

.github/workflows/script.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import os
2+
import yaml
3+
import sys
4+
5+
os.makedirs('plugins/OpenShift', exist_ok=True)
6+
7+
if os.path.exists("index.yml"):
8+
file = open("index.yml","r")
9+
not_present = 1
10+
index = yaml.safe_load(file)
11+
for plugin in index['plugins']:
12+
if plugin['name'] == 'OpenShiftPlugin':
13+
not_present = 0
14+
break
15+
if not_present:
16+
index['plugins'].append({"name": "OpenShiftPlugin", "path": "https://github.com/%s/crane-plugins/raw/main/plugins/OpenShift/index.yaml"%sys.argv[1]})
17+
file = open("index.yml","w")
18+
yaml.dump(index, file)
19+
file.close()
20+
21+
else:
22+
file = open("index.yml","a+")
23+
24+
index = yaml.safe_load(file)
25+
26+
index = {}
27+
index['kind'] = 'PluginIndex'
28+
index['apiServer'] = 'konveyor.io/v1alpha1'
29+
index['plugins'] = []
30+
31+
index['plugins'].append({"name": "OpenShiftPlugin", "path": "https://github.com/%s/crane-plugins/raw/main/plugins/OpenShift/index.yaml"%sys.argv[2]})
32+
33+
yaml.dump(index, file)
34+
file.close()
35+
36+
# create or append in plugin index
37+
if os.path.exists('plugins/OpenShift/index.yml'):
38+
39+
file = open("plugins/OpenShift/index.yml","r")
40+
41+
index = yaml.safe_load(file)
42+
43+
index['versions'].append({})
44+
index['versions'][-1] = {
45+
'name': 'OpenShiftPlugin',
46+
'shortDescription': 'OpenShiftPlugin',
47+
'description': 'this is OpenShiftPlugin',
48+
'version': sys.argv[1],
49+
'binaries': [
50+
{
51+
'os': 'linux',
52+
'arch': 'amd64',
53+
'uri': "https://github.com/%s/releases/download/%s/amd64-linux-openshiftplugin-%s"%(sys.argv[3], sys.argv[1],sys.argv[1]),
54+
},
55+
{
56+
'os': 'darwin',
57+
'arch': 'amd64',
58+
'uri': "https://github.com/%s/releases/download/%s/amd64-darwin-openshiftplugin-%s"%(sys.argv[3], sys.argv[1],sys.argv[1]),
59+
},
60+
{
61+
'os': 'darwin',
62+
'arch': 'arm64',
63+
'uri': "https://github.com/%s/releases/download/%s/arm64-darwin-openshiftplugin-%s"%(sys.argv[3], sys.argv[1],sys.argv[1]),
64+
},
65+
],
66+
}
67+
68+
file = open("plugins/OpenShift/index.yml","w")
69+
70+
yaml.dump(index, file)
71+
file.close()
72+
73+
else:
74+
file = open("plugins/OpenShift/index.yml","a+")
75+
76+
index = yaml.safe_load(file)
77+
78+
index = {}
79+
index['kind'] = 'Plugin'
80+
index['apiServer'] = 'konveyor.io/v1alpha1'
81+
index['versions'] = []
82+
83+
index['versions'].append({})
84+
index['versions'][0] = {
85+
'name': 'OpenShiftPlugin',
86+
'shortDescription': 'OpenShiftPlugin',
87+
'description': 'this is OpenShiftPlugin',
88+
'version': sys.argv[1],
89+
'binaries': [
90+
{
91+
'os': 'linux',
92+
'arch': 'amd64',
93+
'uri': "https://github.com/%s/releases/download/%s/amd64-linux-openshiftplugin-%s"%(sys.argv[3], sys.argv[1],sys.argv[1]),
94+
},
95+
{
96+
'os': 'darwin',
97+
'arch': 'amd64',
98+
'uri': "https://github.com/%s/releases/download/%s/amd64-darwin-openshiftplugin-%s"%(sys.argv[3], sys.argv[1],sys.argv[1]),
99+
},
100+
{
101+
'os': 'darwin',
102+
'arch': 'arm64',
103+
'uri': "https://github.com/%s/releases/download/%s/arm64-darwin-openshiftplugin-%s"%(sys.argv[3], sys.argv[1],sys.argv[1]),
104+
},
105+
],
106+
}
107+
108+
yaml.dump(index, file)
109+
file.close()

0 commit comments

Comments
 (0)