Skip to content

Commit 50a8564

Browse files
committed
redesigning plugin release
1 parent 22c9c58 commit 50a8564

File tree

2 files changed

+155
-31
lines changed

2 files changed

+155
-31
lines changed

.github/workflows/release.yml

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,40 +53,20 @@ 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+
cd crane-plugins
68+
python ~/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/main/.github/workflows/script.py "${{ github.event.inputs.version }}" "${{ github.repository_owner }}" "${{ github.repository }}"
69+
9070
- name: Create Pull Request against crane-plugins
9171
uses: peter-evans/create-pull-request@v3
9272
with:
@@ -96,3 +76,4 @@ jobs:
9676
body: Update index and add manifest to include version ${{ github.event.inputs.version }} of openshift plugin
9777
branch: OpenShiftPlugin
9878
base: main
79+
path: crane-plugins

.github/workflows/script.py

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
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.yaml"):
8+
file = open("index.yaml","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[2]})
17+
file = open("index.yaml","w")
18+
yaml.dump(index, file)
19+
file.close()
20+
21+
else:
22+
file = open("index.yaml","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.yaml'):
38+
39+
file = open("plugins/OpenShift/index.yaml","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+
'optionalFields': [
67+
{
68+
'flagName': "strip-default-pull-secrets",
69+
'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",
70+
'example': "true",
71+
},
72+
{
73+
'flagName': "pull-secret-replacement",
74+
'help': "Map of pull secrets to replace in Pods and BuildConfigs while transforming in format secret1=destsecret1,secret2=destsecret2[...]",
75+
'example': "default-dockercfg-h4n7g=default-dockercfg-12345,builder-dockercfg-abcde=builder-dockercfg-12345",
76+
},
77+
{
78+
'flagName': "registry-replacement",
79+
'help': "Map of image registry paths to swap on transform, in the format original-registry1=target-registry1,original-registry2=target-registry2...",
80+
'example': "docker-registry.default.svc:5000=image-registry.openshift-image-registry.svc:5000,docker.io/foo=quay.io/bar",
81+
},
82+
]
83+
}
84+
85+
file = open("plugins/OpenShift/index.yaml","w")
86+
87+
yaml.dump(index, file)
88+
file.close()
89+
90+
else:
91+
file = open("plugins/OpenShift/index.yaml","a+")
92+
93+
index = yaml.safe_load(file)
94+
95+
index = {}
96+
index['kind'] = 'Plugin'
97+
index['apiServer'] = 'konveyor.io/v1alpha1'
98+
index['versions'] = []
99+
100+
index['versions'].append({})
101+
index['versions'][0] = {
102+
'name': 'OpenShiftPlugin',
103+
'shortDescription': 'OpenShiftPlugin',
104+
'description': 'this is OpenShiftPlugin',
105+
'version': sys.argv[1],
106+
'binaries': [
107+
{
108+
'os': 'linux',
109+
'arch': 'amd64',
110+
'uri': "https://github.com/%s/releases/download/%s/amd64-linux-openshiftplugin-%s"%(sys.argv[3], sys.argv[1],sys.argv[1]),
111+
},
112+
{
113+
'os': 'darwin',
114+
'arch': 'amd64',
115+
'uri': "https://github.com/%s/releases/download/%s/amd64-darwin-openshiftplugin-%s"%(sys.argv[3], sys.argv[1],sys.argv[1]),
116+
},
117+
{
118+
'os': 'darwin',
119+
'arch': 'arm64',
120+
'uri': "https://github.com/%s/releases/download/%s/arm64-darwin-openshiftplugin-%s"%(sys.argv[3], sys.argv[1],sys.argv[1]),
121+
},
122+
],
123+
'optionalFields': [
124+
{
125+
'flagName': "strip-default-pull-secrets",
126+
'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",
127+
'example': "true",
128+
},
129+
{
130+
'flagName': "pull-secret-replacement",
131+
'help': "Map of pull secrets to replace in Pods and BuildConfigs while transforming in format secret1=destsecret1,secret2=destsecret2[...]",
132+
'example': "default-dockercfg-h4n7g=default-dockercfg-12345,builder-dockercfg-abcde=builder-dockercfg-12345",
133+
},
134+
{
135+
'flagName': "registry-replacement",
136+
'help': "Map of image registry paths to swap on transform, in the format original-registry1=target-registry1,original-registry2=target-registry2...",
137+
'example': "docker-registry.default.svc:5000=image-registry.openshift-image-registry.svc:5000,docker.io/foo=quay.io/bar",
138+
},
139+
]
140+
}
141+
142+
yaml.dump(index, file)
143+
file.close()

0 commit comments

Comments
 (0)