Skip to content

Commit

Permalink
change version in publish
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuancelin committed Dec 19, 2023
1 parent c1cbca4 commit 74d3297
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/publish_documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ name: publish-otoroshi-documentation
on:
workflow_dispatch:
inputs:
version:
description: "Current version"
version_from:
description: "Current version (ie. 16.12.0-dev)"
version_to:
description: "Published version (ie. 16.11.2)"

jobs:
release-otoroshi:
Expand Down Expand Up @@ -32,11 +34,12 @@ jobs:
id: run-doc-process
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_FROM: ${{ inputs.version_from }}
VERSION_TO: ${{ inputs.version_to }}
DISPLAY: :1
run: |
LOC=$(pwd)
# TODO: change version in files
# TODO: node ./scripts/release/change-doc-version-github-action.js
export WHERE=$(pwd)
node ./scripts/release/change-doc-version-github-action.js
sh ./scripts/doc.sh all
# TODO: git commit -am 'publish documentation'
# TODO: git push origin master
41 changes: 41 additions & 0 deletions scripts/release/change-doc-version-github-action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const path = require('path');
const fs = require('fs');

const files = [
{ file: './kubernetes/kustomize/overlays/cluster/deployment.yaml', replace: (from, to, source) => source.replace(`maif/otoroshi:${from}`, `maif/otoroshi:${to}`) },
{ file: './kubernetes/kustomize/overlays/cluster-baremetal/deployment.yaml', replace: (from, to, source) => source.replace(`maif/otoroshi:${from}`, `maif/otoroshi:${to}`) },
{ file: './kubernetes/kustomize/overlays/cluster-baremetal-daemonset/deployment.yaml', replace: (from, to, source) => source.replace(`maif/otoroshi:${from}`, `maif/otoroshi:${to}`) },
{ file: './kubernetes/kustomize/overlays/simple/deployment.yaml', replace: (from, to, source) => source.replace(`maif/otoroshi:${from}`, `maif/otoroshi:${to}`) },
{ file: './kubernetes/kustomize/overlays/simple-baremetal/deployment.yaml', replace: (from, to, source) => source.replace(`maif/otoroshi:${from}`, `maif/otoroshi:${to}`) },
{ file: './kubernetes/kustomize/overlays/simple-baremetal-daemonset/deployment.yaml', replace: (from, to, source) => source.replace(`maif/otoroshi:${from}`, `maif/otoroshi:${to}`) },
{
file: './manual/src/main/paradox/deploy/kubernetes.md',
replace: (from, to, source) => source.replace(`?ref=v${from}`, `?ref=v${to}`).replace(`maif/otoroshi:${from}`, `maif/otoroshi:${to}`)
},
{ file: './manual/src/main/paradox/code/openapi.json' },
{ file: './manual/src/main/paradox/getting-started.md' },
{ file: './manual/src/main/paradox/how-to-s/import-export-otoroshi-datastore.md' },
{ file: './manual/src/main/paradox/how-to-s/setup-otoroshi-cluster.md' },
{ file: './manual/src/main/paradox/includes/fetch-and-start.md' },
{ file: './manual/src/main/paradox/includes/initialize.md' },
{ file: './manual/src/main/paradox/index.md' },
{ file: './manual/src/main/paradox/install/get-otoroshi.md' },
{ file: './manual/src/main/paradox/topics/expression-language.md' },
{ file: './manual/src/main/paradox/snippets/build.gradle' },
{ file: './manual/src/main/paradox/snippets/build.sbt' },
{ file: './manual/src/main/paradox/snippets/fetch.sh' },
];

function changeVersion(where, from, to, exclude = []) {
console.log(`Changing version from '${from}' to '${to}'`)
files.filter(f => !(exclude.indexOf(f.file) > -1)).map(file => {
const filePath = path.resolve(where, file.file);
const content = fs.readFileSync(filePath, 'utf8');
console.log('Changing version in', filePath);
const replace = file.replace || ((f, t, s) => s.replace(new RegExp(f.replace(new RegExp('\\.', 'g'), '\\.'), 'g'), t));
const newContent = replace(from, to, content);
fs.writeFileSync(filePath, newContent);
});
}

changeVersion(process.env.WHERE, process.env.VERSION_FROM, process.env.VERSION_TO)

0 comments on commit 74d3297

Please sign in to comment.