Skip to content
name: Update Chart version on Release
on:
release:
types: [published]
env:
CHART_FILE: "charts/mongodb-profiler-exporter/Chart.yaml"
RELEASE_TAG: "${{ github.event.release.tag_name }}"
jobs:
update-chart-appversion:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Check Tag
id: check-tag
run: |
if [[ "${{ github.event.release.tag_name }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "match=true" >> $GITHUB_ENV
else
echo "match=false" >> $GITHUB_ENV
fi
- name: Update version in Chart.yaml
if: env.match == 'true'
run: |
sed -i.bak "s/^version: .*/version: ${RELEASE_TAG}/" "$CHART_FILE"
sed -i.bak "s/^appVersion: .*/appVersion: ${RELEASE_TAG}/" "$CHART_FILE"
- name: Commit and push changes
if: env.match == 'true'
run: |
git config user.name "release"
git config user.email "[email protected]"
git add "${CHART_FILE}"
git commit -m "Update version to ${RELEASE_TAG}"
- name: Push changes
if: env.match == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}