The personal finance app for everyone (by everyone)
Ruby
Bump Helm chart version in pre-release workflow (#792)
Juan José Mata51c7f7a3f04d
diff --git a/.github/workflows/helm-release.yaml b/.github/workflows/helm-release.yamlindex 8c28a49280..9fbd90c29e 100644--- a/.github/workflows/helm-release.yaml+++ b/.github/workflows/helm-release.yaml@@ -6,6 +6,8 @@ on:- mainpaths:- 'charts/**'+ tags:+ - 'v*'workflow_dispatch:jobs:@@ -36,13 +38,22 @@ jobs:id: versionrun: |# Generate version like: 0.0.0-nightly.20251213.173045- VERSION="0.0.0-nightly.$(date -u +'%Y%m%d.%H%M%S')"+ if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" == v* ]]; then+ VERSION="${GITHUB_REF_NAME#v}"+ else+ BASE_VERSION="$(git tag -l 'v*' | sed 's/^v//' | sort -V | tail -n 1)"+ if [[ -z "${BASE_VERSION}" ]]; then+ BASE_VERSION="0.0.0"+ fi+ VERSION="${BASE_VERSION}-nightly.$(date -u +'%Y%m%d.%H%M%S')"+ fiecho "version=$VERSION" >> $GITHUB_OUTPUTecho "Generated version: $VERSION"- name: Update Chart.yaml versionrun: |sed -i "s/^version:.*/version: ${{ steps.version.outputs.version }}/" charts/sure/Chart.yaml+ sed -i "s/^appVersion:.*/appVersion: \"${{ steps.version.outputs.version }}\"/" charts/sure/Chart.yamlcat charts/sure/Chart.yaml- name: Add Helm repositories@@ -83,5 +94,20 @@ jobs:git config user.name "$GIT_USER_NAME"git config user.email "$GIT_USER_EMAIL"git add .- git commit -m "Release nightly: ${{ steps.version.outputs.version }}"+ if git diff --cached --quiet; then+ echo "No Helm chart updates to publish."+ exit 0+ fi+ if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" == v* ]]; then+ git commit -m "Release chart for ${{ github.ref_name }}"+ else+ git commit -m "Release nightly: ${{ steps.version.outputs.version }}"+ figit push++ - name: Upload chart to GitHub Release+ if: startsWith(github.ref, 'refs/tags/v')+ uses: softprops/action-gh-release@v2+ with:+ tag_name: ${{ github.ref_name }}+ files: .cr-release-packages/*.tgzdiff --git a/.github/workflows/publish.yml b/.github/workflows/publish.ymlindex 2c3479071a..4cdbca01af 100644--- a/.github/workflows/publish.yml+++ b/.github/workflows/publish.yml@@ -349,12 +349,19 @@ jobs:- name: Bump pre-release versionrun: |VERSION_FILE="config/initializers/version.rb"+ CHART_FILE="charts/sure/Chart.yaml"# Ensure version file existsif [ ! -f "$VERSION_FILE" ]; thenecho "ERROR: Version file not found: $VERSION_FILE"exit 1fi++ # Ensure chart file exists+ if [ ! -f "$CHART_FILE" ]; then+ echo "ERROR: Chart file not found: $CHART_FILE"+ exit 1+ fi# Extract current versionCURRENT_VERSION=$(grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+-(alpha|beta|rc)\.[0-9]+' "$VERSION_FILE")@@ -394,12 +401,21 @@ jobs:echo "Updated version.rb:"grep "semver" "$VERSION_FILE"+ # Update Helm chart version and appVersion+ sed -i -E "s/^version: .*/version: ${NEW_VERSION}/" "$CHART_FILE"+ sed -i -E "s/^appVersion: .*/appVersion: \"${NEW_VERSION}\"/" "$CHART_FILE"++ # Verify the change+ echo "Updated Chart.yaml:"+ grep -E "^(version|appVersion):" "$CHART_FILE"+- name: Commit and push version bumprun: |git config user.name "github-actions[bot]"git config user.email "github-actions[bot]@users.noreply.github.com"git add config/initializers/version.rb+ git add charts/sure/Chart.yaml# Check if there are changes to commitif git diff --cached --quiet; then