Skip to content

Commit

Permalink
feat: allora-worker and cosmos-operator rpc node chart
Browse files Browse the repository at this point in the history
  • Loading branch information
chliddle committed Oct 24, 2024
1 parent 59369e4 commit 0f34eb0
Show file tree
Hide file tree
Showing 29 changed files with 1,775 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/chart-release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path');

module.exports = {
branches: ['main'],
tagFormat: '${CHART_NAME}-v${version}',
plugins: [
['@semantic-release/commit-analyzer', {
preset: 'conventionalcommits',
releaseRules: [
{ type: 'feat', release: 'minor' },
{ type: 'fix', release: 'patch' },
],
}],
'@semantic-release/release-notes-generator',
['@semantic-release/changelog', {
changelogFile: 'CHANGELOG.md',
}],
['@semantic-release/git', {
assets: ['CHANGELOG.md', 'Chart.yaml'],
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
}],
['@semantic-release/github', {
assets: [
{ path: '${CHART_NAME}-${nextRelease.version}.tgz', label: '${CHART_NAME} Chart' },
],
}],
],
prepare: [
{
path: '@semantic-release/exec',
cmd: 'sed -i "s/^version:.*$/version: ${nextRelease.version}/" Chart.yaml',
},
{
path: '@semantic-release/exec',
cmd: 'helm package . --version ${nextRelease.version} --app-version ${nextRelease.version}',
},
],
};
194 changes: 194 additions & 0 deletions .github/workflows/release-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
name: Release Charts and Deploy to GitHub Pages

on:
push:
branches:
- main

jobs:
check-changes:
runs-on: ubuntu-latest
outputs:
changes_detected: ${{ steps.check.outputs.changes_detected }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check for changes in Helm charts
id: check
run: |
# Find all directories containing Chart.yaml
chart_dirs=$(find ./charts -name Chart.yaml -exec dirname {} \;)
changes_detected=false
for dir in $chart_dirs; do
if git diff --quiet HEAD^ HEAD -- "$dir"; then
echo "No changes in $dir"
else
echo "Changes detected in $dir"
changes_detected=true
break
fi
done
echo "changes_detected=$changes_detected" >> $GITHUB_OUTPUT
release-charts:
needs: check-changes
if: needs.check-changes.outputs.changes_detected == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v3

- name: Add dependency repositories
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: npm install @semantic-release/git @semantic-release/changelog @semantic-release/exec conventional-changelog-conventionalcommits

- name: Release charts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p release
chart_dirs=$(find ./charts -name Chart.yaml -exec dirname {} \;)
for dir in $chart_dirs; do
echo "Checking for changes in ${dir}"
if git diff --quiet HEAD^ HEAD -- "${dir}"; then
echo "No changes in ${dir}, skipping release"
else
echo "Changes detected in ${dir}, releasing chart"
cd "${dir}"
export CHART_PATH=$(pwd)
export CHART_NAME=$(basename $(pwd))
npx semantic-release -e ../../.github/chart-release.config.js
helm package . --destination ../release/
cd $GITHUB_WORKSPACE
fi
done
- name: Upload release as artifact
uses: actions/upload-artifact@v3
with:
name: release
path: release

generate-index:
needs: release-charts
if: needs.check-changes.outputs.changes_detected == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Helm
uses: azure/setup-helm@v3

- name: Install yq
run: |
sudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Generate Helm repo index and README
run: |
mkdir -p ./release/images
cp -r docs/images/* ./release/images/
helm repo index ./release --url https://${{ github.repository_owner }}.github.io/cosmos-helm-charts/
# Get list of charts
charts=$(find ./charts -name Chart.yaml -exec dirname {} \; | sed 's/.\///')
# Generate chart info
chart_info=""
for chart in $charts; do
if [ -f "${chart}/Chart.yaml" ]; then
name=$(yq e '.name' ${chart}/Chart.yaml)
# Get the latest tag for this chart, sorting by version number
version=$(git tag -l "${name}-v*" | sort -V | tail -n 1)
version=${version#${name}-v}
description=$(yq e '.description' ${chart}/Chart.yaml)
chart_info+="<div class=\"chart\">"
chart_info+="<h3>${name}</h3>"
chart_info+="<p><strong>Version:</strong> ${version}</p>"
chart_info+="<p><strong>Description:</strong> ${description}</p>"
chart_info+="</div>"
fi
done
# Use the template to generate index.html
cp docs/index.html.template ./release/index.html
sed -i "s|{{GITHUB_REPOSITORY_OWNER}}|${GITHUB_REPOSITORY_OWNER}|g" ./release/index.html
sed -i "s|{{AVAILABLE_CHARTS}}|${chart_info}|g" ./release/index.html
- name: Upload release as artifact
uses: actions/upload-artifact@v3
with:
name: release
path: release

deploy:
needs: generate-index
if: needs.check-changes.outputs.changes_detected == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download release artifacts
uses: actions/download-artifact@v3
with:
name: release
path: release

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./release
force_orphan: true

verify-files:
needs: deploy
if: needs.check-changes.outputs.changes_detected == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download release artifacts
uses: actions/download-artifact@v3
with:
name: release
path: release

- name: Verify files
run: |
ls -l ./release
echo "Content of index.yaml:"
cat ./release/index.yaml
echo "Content of index.html:"
cat ./release/index.html
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test Charts

on:
pull_request:
branches: [main]

jobs:
discover-charts:
runs-on: ubuntu-latest
outputs:
chart_dirs: ${{ steps.set-chart-dirs.outputs.chart_dirs }}
steps:
- uses: actions/checkout@v3
- id: set-chart-dirs
run: |
CHART_DIRS=$(find ./charts -name Chart.yaml -exec dirname {} \; | jq -R -s -c 'split("\n")[:-1]')
echo "chart_dirs=$CHART_DIRS" >> $GITHUB_OUTPUT
test-charts:
needs: discover-charts
runs-on: ubuntu-latest
strategy:
matrix:
chart_dir: ${{ fromJson(needs.discover-charts.outputs.chart_dirs) }}
steps:
- uses: actions/checkout@v3

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0

- name: Run Helm lint
run: helm lint ${{ matrix.chart_dir }} -f ${{ matrix.chart_dir }}/examples/values.yaml

- name: Run Helm template
run: helm template ${{ matrix.chart_dir }} -f ${{ matrix.chart_dir }}/examples/values.yaml

- name: Install chart dependencies
run: |
if [ -f ${{ matrix.chart_dir }}/Chart.yaml ]; then
helm dependency update ${{ matrix.chart_dir }}
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 p2p.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 0f34eb0

Please sign in to comment.