WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

update-peerdb-release-version.yml #52

update-peerdb-release-version.yml

update-peerdb-release-version.yml #52

name: update-peerdb-release-version.yml
on:
workflow_dispatch:
inputs:
version:
description: 'Latest PeerDB release version to update in the chart. Add the v prefix. E.g. `v0.22.1`. Leave it to `latest` to pull and use the latest PeerDB release version.'
required: true
default: 'latest'
schedule:
# Run every Monday at 14:30 UTC
- cron: '00 15 * * 1'
jobs:
update-peerdb-release-version:
runs-on: ubuntu-latest
env:
PR_BRANCH: automated/peerdb-release-version-update
PR_LABEL: automated/peerdb-release-version-update
PR_TITLE: "feat: upgrade PeerDB release version in enterprise charts"
PEERDB_INPUT_VERSION: ${{ github.event.inputs.version || 'latest' }}
steps:
- name: validate version input
run: |
if [[ ! "${{ env.PEERDB_INPUT_VERSION }}" =~ ^v.* && ! "${{ env.PEERDB_INPUT_VERSION }}" = "latest" ]]; then
echo "Error: Version must start with 'v' or be 'latest'."
exit 1
fi
echo "PEERDB_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Pull latest PeerDB release version
if: ${{ env.PEERDB_INPUT_VERSION == 'latest' }}
run: |
set -eo pipefail
LATEST_PEERDB_VERSION=$(curl -sf https://api.github.com/repos/peerdb-io/peerdb/releases/latest | jq -r '.tag_name')
echo "PEERDB_VERSION=${LATEST_PEERDB_VERSION}" >> $GITHUB_ENV
- name: Prefix with stable-
run: |
echo "STABLE_PEERDB_VERSION=stable-${{ env.PEERDB_VERSION }}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
with:
token: '${{ secrets.DEVOPS_BOT_GITHUB_TOKEN }}'
- name: Update PeerDB version
id: update-peerdb-version
run: |
set -eo pipefail
sed -i -E 's:(^PEERDB_VERSION=).*?($):\1${{ env.STABLE_PEERDB_VERSION }}\2:g' .env.template
yq -e -i '.appVersion = strenv(PEERDB_VERSION)' peerdb/Chart.yaml
yq -e -i '.appVersion = strenv(PEERDB_VERSION)' peerdb-catalog/Chart.yaml
yq -e -i '.peerdb.version = strenv(STABLE_PEERDB_VERSION)' peerdb/values.yaml
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
- name: Get next version
if: ${{ steps.update-peerdb-version.outputs.changes == 'true' }}
uses: reecetech/[email protected]
id: version
with:
scheme: semver
increment: patch
- name: Update Chart version
if: ${{ steps.update-peerdb-version.outputs.changes == 'true' }}
run: |
set -eo pipefail
yq -e -i '.version = "${{ steps.version.outputs.version }}"' peerdb/Chart.yaml
yq -e -i '.version = "${{ steps.version.outputs.version }}"' peerdb-catalog/Chart.yaml
- name: Update helm-docs for both charts
if: ${{ steps.update-peerdb-version.outputs.changes == 'true' }}
run: |
docker run -v "$PWD:/helm-docs" -u $(id -u) jnorwood/helm-docs:latest -c peerdb -d > peerdb/README.md
docker run -v "$PWD:/helm-docs" -u $(id -u) jnorwood/helm-docs:latest -c peerdb-catalog -d > peerdb-catalog/README.md
- name: Commit changes
if: ${{ steps.update-peerdb-version.outputs.changes == 'true' }}
run: |
git config --global user.name "DevOps Bot"
git config --global user.email "[email protected]"
git add -u .
git checkout -b "${{ env.PR_BRANCH }}"
git fetch || true
git commit -m "feat: upgrade PeerDB release version to ${{ github.event.inputs.version }}"
git push -u origin "${{ env.PR_BRANCH }}" --force-with-lease
PR_ID=$(gh pr list --label "${PR_LABEL}" --head "${PR_BRANCH}" --json number | jq -r '.[0].number // ""')
if [ "$PR_ID" == "" ]; then
PR_ID=$(gh pr create -l "$PR_LABEL" -t "$PR_TITLE" --body "")
fi
echo 'This PR updates the PeerDB release version to `${{ env.PEERDB_VERSION }}` and the chart version to `${{ steps.version.outputs.version }}`.' > pr_body.txt
echo 'Please review and merge it to update the charts.' >> pr_body.txt
gh pr edit "$PR_ID" --body "$(cat pr_body.txt)"
gh pr merge "$PR_ID" --squash --auto
env:
GITHUB_TOKEN: ${{ secrets.DEVOPS_BOT_GITHUB_TOKEN }}