Skip to content

Commit

Permalink
feat: update app version script
Browse files Browse the repository at this point in the history
  • Loading branch information
aeppling committed Sep 17, 2024
1 parent 633c569 commit f5c50f2
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/appversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,22 @@ jobs:
- name: print new latest kexa version
run: echo ${{ steps.get_latest_release.outputs.release }}

- name: Run Javascript to update local files
uses: actions/setup-node@v4
with:
node-version: '20'
run: |
npm install
node update-app-version.js "${{ steps.get_latest_release.outputs.release }}"
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}

- name: Commit and push changes to dev
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add charts/kexa-chart/Chart.yaml
git commit -m "chore(release): update Chart.yaml appversion"
git push origin dev
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
43 changes: 43 additions & 0 deletions update-app-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// YAML TO JSON
// CHANGE APP VERSION
// THEN JSON TO YAML AND WRITE TO FILE

const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');

const newVersion = process.argv[2];

if (!newVersion) {
console.error('Error: No version specified.');
process.exit(1);
}

const chartFilePath = 'charts/kexa-chart/Chart.yaml';

if (!fs.existsSync(chartFilePath)) {
console.error(`Error: ${chartFilePath} not found.`);
process.exit(1);
}

let fileContent = fs.readFileSync(chartFilePath, 'utf8');
let chartData;

try {
chartData = yaml.load(fileContent);
} catch (e) {
console.error('Error parsing YAML:', e);
process.exit(1);
}

if (chartData.version) {
chartData.appVersion = newVersion;
console.log(`Updating version to ${newVersion}`);
} else {
console.error('Version field not found in Chart.yaml.');
process.exit(1);
}

const updatedYaml = yaml.dump(chartData);
fs.writeFileSync(chartFilePath, updatedYaml, 'utf8');
console.log(`Updated ${chartFilePath} to version ${newVersion}`);
2 changes: 1 addition & 1 deletion update-chart-version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// YAML TO JSON
// CHANGE VERSION
// CHANGE CHART VERSION
// THEN JSON TO YAML AND WRITE TO FILE

const fs = require('fs');
Expand Down

0 comments on commit f5c50f2

Please sign in to comment.