Add new files and put static version back to 1.0

This commit is contained in:
Chris Hunt 2024-08-13 10:31:16 +01:00
parent 4476528522
commit 8ddd8aabe0
No known key found for this signature in database
6 changed files with 105 additions and 4 deletions

View File

@ -91,7 +91,7 @@ Click on the **Actions** tab in the top menu and check whether workflows need en
| env.icon | The image to display for your registry. You can upload an image to `/site/public/` and reference that by https://domain.com/1.1/image.png or if you aren't using a {sub}domain by referencing it from https://username.github.io/repositoryname/1.1/image.png where image.png is the name of the image you uploaded. Alternatively just put the url of an image available on the web. If you just want to get the registry up and working, leave the default value in place until later. |
| env.listUrl | The link to the root of your site. For example https://username.github.io/repositoryname/ it should always include a trailing slash. |
| env.contactUrl | A link users can use to contact you on, such as your github issues page (right click the **Issues** tab in the top menu - next to the **Code** tab - and select `copy link address` and paste that in). |
| basePath | If you are using a domain or a subdomain, your basePath will just be `basePath: '/1.1',`, otherwise change the value to include what you chose for the repository name in step 2 `basePath: '/repositoryname/1.1',`. **The `1.1` will be replaced with the branch name automatically, so you should always keep it as 1.1.** |
| basePath | If you are using a domain or a subdomain, your basePath will just be `basePath: '/1.0',`, otherwise change the value to include what you chose for the repository name in step 2 `basePath: '/repositoryname/1.0',`. **The `1.0` will be replaced with the branch name automatically, so you should always keep it as 1.0.** |
### Commit changes
<img width="600" alt="image" src="https://user-images.githubusercontent.com/5698566/230355586-39f6b4a6-9e01-482d-bab1-f0c1a292de24.png">

View File

@ -17,11 +17,11 @@ for BRANCH in $(git branch --remotes --format '%(refname:lstrip=3)' | grep -Ev '
git checkout $BRANCH
node processing
cp -a public/. process
sed -i "s/1.1/$SANITIZED_BRANCH/" site/next.config.js
sed -i "s/1.0/$SANITIZED_BRANCH/" site/next.config.js
npm run deploy --prefix site
cp -a process/. public/ # Have to run it again because the deploy wipes the file and folders out
rm -rf process
sed -i "s/$SANITIZED_BRANCH/1.1/" site/next.config.js # Set it back to 1.1 so it can be changed again on the next loop
sed -i "s/$SANITIZED_BRANCH/1.0/" site/next.config.js # Set it back to 1.0 so it can be changed again on the next loop
mv public base/$SANITIZED_BRANCH
cp base/$SANITIZED_BRANCH/favicon.ico base/favicon.ico
done

View File

@ -0,0 +1,48 @@
const fs = require("fs");
const glob = require("glob");
const baseversion = '1.16'
const tag = ':develop'
const version = baseversion + '.x'
const tagversion = baseversion + '.0'
glob("../workspaces/**/workspace.json", async function (err, files) {
if (err) {
console.log(
"cannot read the folder, something goes wrong with glob",
err
);
}
for (const file of files) {
let filedata = fs.readFileSync(file);
let parsed = JSON.parse(filedata);
const current = parsed.compatibility[parsed.compatibility.length - 1]
const image = current.image.split(':')[0]
const exists = parsed.compatibility.findIndex(el => el.version === version)
let details = {
version,
image: image + tag,
uncompressed_size_mb: 0,
available_tags: [
'develop',
tagversion,
tagversion + '-rolling-weekly',
tagversion + '-rolling-daily'
]
}
if (exists === -1) {
parsed.compatibility.push(details)
fs.writeFileSync(file, JSON.stringify(parsed, null, 2));
}
}
});

View File

@ -0,0 +1,45 @@
const fs = require("fs");
const glob = require("glob");
const { execSync } = require('child_process');
glob("../workspaces/**/workspace.json", function (err, files) {
if (err) {
console.log(
"cannot read the folder, something goes wrong with glob",
err
);
}
let total = 0
for (const file of files) {
let filedata = fs.readFileSync(file);
let parsed = JSON.parse(filedata);
parsed.compatibility.forEach((element, index) => {
total++
if (element.uncompressed_size_mb === 0) {
execSync('docker image prune -a -f')
execSync('docker system prune --all --force --volumes')
let pull = execSync('docker pull ' + element.image)
// console.log(pull)
let inspect = execSync('docker inspect -f "{{ .Size }}" ' + element.image)
let size = Math.round(inspect / 1000000)
let remove = execSync('docker rmi ' + element.image)
console.log(remove)
parsed.compatibility[index].uncompressed_size_mb = size
console.log('Write file: ' + parsed.friendly_name + ' - ' + element.version + ': ' + size)
fs.writeFileSync(file, JSON.stringify(parsed, null, 2));
} else {
console.log(parsed.friendly_name + ' - ' + element.version + ': skipped')
}
})
}
console.log(total + ' entries processed')
});

View File

@ -40,6 +40,13 @@ glob("**/workspace.json", async function (err, files) {
let parsed = JSON.parse(filedata);
parsed.sha = hash.hash;
console.log(parsed.name + ' added')
parsed.compatibility.forEach((element, index) => {
if ('available_tags' in element) {
element.available_tags.forEach((el) => {
channels.add(el)
})
}
})
workspaces.push(parsed);
if (fs.existsSync(folder + "/" + parsed.image_src)) {
@ -60,6 +67,7 @@ glob("**/workspace.json", async function (err, files) {
contact_url: nextConfig.env.contactUrl || null,
modified: Date.now(),
workspaces: workspaces,
channels: [...channels]
};
let data = JSON.stringify(json);

View File

@ -10,7 +10,7 @@ const nextConfig = {
},
reactStrictMode: true,
swcMinify: true,
basePath: '/kasm-registry/1.1',
basePath: '/kasm-registry/1.0',
trailingSlash: true,
images: {
unoptimized: true,