Skip to content

Commit

Permalink
Merge pull request #33 from kexa-io/dev
Browse files Browse the repository at this point in the history
feat: App version auto-update
  • Loading branch information
aeppling authored Sep 17, 2024
2 parents 5fae54b + 563cb07 commit 773e90f
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 82 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/appversion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Update App version

on:
push:
branches:
- dev

jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: dev

- name: Get latest release of Kexa
uses: rez0n/actions-github-release@794c12f5e8d629e6ca329cf2e2daeb0f0ce6a3ce
id: get_latest_release
with:
token: ${{ secrets.GIT_TOKEN }}
repository: "kexa-io/Kexa"
type: "stable"

- name: print new latest kexa version
run: echo ${{ steps.get_latest_release.outputs.release }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Run Javascript to update local files
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 }}
33 changes: 0 additions & 33 deletions .github/workflows/release.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/versioning.yaml

This file was deleted.

12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ If you do not want to use the cronjob, and just need a one time run:

## Create your secrets

Kexa need configuration file (that define which rule to use and which addon to use) to run,
as well as the credentials for the addons you will use.

Most of addon's credentials are passed in .env file, only Kubernetes addon require
a specific credential type, described below.

Refer to the official Kexa documentation to learn more about addons authentication.
Refer to the official Kexa documentation to learn more about addons authentication
and Kexa configuration.


*Upload your Kexa configuration (default.json)*
```bash
kubectl create secret generic kexa-configuration-secret --from-file=default.json=default.json
```

*For most addons credentials*
```bash
Expand Down
2 changes: 1 addition & 1 deletion charts/kexa-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: kexa
description: A Helm chart that installs PostgreSQL and Grafana
version: 1.4.2
appVersion: '1.0'
appVersion: 1.16.4
icon: https://kexa.io/kexa-no-background-color.png
dependencies:
- name: postgresql
Expand Down
19 changes: 0 additions & 19 deletions charts/kexa-chart/files/config/default.json

This file was deleted.

4 changes: 2 additions & 2 deletions charts/kexa-chart/templates/kexa-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ spec:
restartPolicy: Never
volumes:
- name: kexa-config-volume
configMap:
name: kexa-configuration-files
secret:
secretName: kexa-configuration-secret
- name: kexa-env-volume
secret:
secretName: kexa-environment-secret
Expand Down
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 773e90f

Please sign in to comment.