Skip to content

Commit

Permalink
Merge pull request #21 from kexa-io/dev
Browse files Browse the repository at this point in the history
fix: versioning workflow semantic + helm releaser
  • Loading branch information
aeppling authored Sep 17, 2024
2 parents 5087521 + ef554df commit b553941
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 16 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/fullrelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release Workflow (Semantic + Helm)

on:
push:
branches:
- main

jobs:
semantic-release:
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Prep plugins
run: |
npm install -D @semantic-release/changelog @semantic-release/git @semantic-release/exec
- name: Run semantic release
id: ver
run: npx semantic-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

helm-release:
needs: semantic-release
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Helm
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
config: "cr.yaml"
3 changes: 0 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Release Charts

on:
workflow_dispatch:
push:
branches:
- main

jobs:
release:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/versioning.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Release

on:
push:
branches:
- main
workflow_dispatch:

jobs:
release:
Expand Down
9 changes: 4 additions & 5 deletions charts/kexa-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
apiVersion: v2
name: "helm-kexa-grafana-postgres"
name: helm-kexa-grafana-postgres
description: A Helm chart that installs PostgreSQL and Grafana
version: 1.4.0
appVersion: "1.0"
appVersion: '1.0'
icon: https://kexa.io/kexa-no-background-color.png

dependencies:
- name: postgresql
version: 15.0.0
repository: "https://charts.bitnami.com/bitnami"
repository: https://charts.bitnami.com/bitnami
- name: grafana
version: 8.5.1
repository: "https://grafana.github.io/helm-charts"
repository: https://grafana.github.io/helm-charts
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@
{
"publishCmd": "echo ::set-output name=nextVer::${nextRelease.version}"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "node update-chart-version.js ${nextRelease.version}"
}
]
]
},
"dependencies": {
"js-yaml": "^4.1.0"
}
}
42 changes: 42 additions & 0 deletions update-chart-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// YAML TO JSON
// CHANGE 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.version = 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}`);

0 comments on commit b553941

Please sign in to comment.