feat: Add installer-pre-upgrade chart and integrate it into the main … #33
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release-tag-installer | |
| on: | |
| push: | |
| tags: ["[0-9]+.[0-9]+.[0-9]+"] | |
| jobs: | |
| package: | |
| runs-on: ubuntu-latest | |
| # Define the MODULE variable here so it is available to all steps | |
| env: | |
| MODULE: installer | |
| steps: | |
| # 1. CHECKOUT MUST BE FIRST | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Required to fetch all tags for the git commands below | |
| - name: Authenticate with GitHub App | |
| id: authenticate | |
| uses: tibdex/github-app-token@v1 | |
| with: | |
| app_id: ${{ secrets.APP_ID }} | |
| private_key: ${{ secrets.PRIVATE_KEY }} | |
| - name: Extract and Store Trimmed Repository Name | |
| run: | | |
| REPO_CHART_NAME="${{ github.repository }}" | |
| REPO_APP_NAME=$(echo "$REPO_CHART_NAME" | sed 's/-chart$//') | |
| # Check if the trimmed repo exists | |
| HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ | |
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/$REPO_APP_NAME") | |
| if [[ "$HTTP_STATUS" -eq 200 ]]; then | |
| echo "Using trimmed repository name: $REPO_APP_NAME" | |
| echo "REPO_APP_NAME=$REPO_APP_NAME" >> $GITHUB_ENV | |
| else | |
| echo "Trimmed repository not found. Falling back to original repository name." | |
| echo "REPO_APP_NAME=$REPO_CHART_NAME" >> $GITHUB_ENV | |
| fi | |
| - name: Extract App Version from Remote Repo | |
| run: | | |
| set -euo pipefail | |
| echo "=== Target Remote Repo: ${{ env.REPO_APP_NAME }} ===" | |
| # Construct the remote URL using the App Token for authentication | |
| # We use the computed REPO_APP_NAME (e.g., owner/installer) | |
| REMOTE_URL="https://x-access-token:${{ steps.authenticate.outputs.token }}@github.com/${{ env.REPO_APP_NAME }}.git" | |
| echo "=== querying remote tags for pattern: ${{ env.MODULE }}/* ===" | |
| # Use git ls-remote to list tags from the remote repo without cloning it. | |
| # --sort='-v:refname' ensures we get the highest version first. | |
| # We filter specifically for tags matching "refs/tags/installer/*" | |
| LATEST_TAG_REF=$(git ls-remote --tags --refs --sort='-v:refname' "$REMOTE_URL" "refs/tags/${{ env.MODULE }}/*" | head -n 1) | |
| if [ -z "$LATEST_TAG_REF" ]; then | |
| echo "No tags found matching pattern in remote repo!" | |
| echo "Using fallback..." | |
| APP_VERSION="0.0.1" | |
| else | |
| # The output format is: "hash refs/tags/installer/0.6.3" | |
| # We strip everything up to the last slash to get "0.6.3" | |
| APP_VERSION=${LATEST_TAG_REF##*/} | |
| echo "Found tag: $APP_VERSION" | |
| fi | |
| echo "=== Final APP_VERSION ===" | |
| echo "APP_VERSION=$APP_VERSION" | |
| echo "APP_VERSION=$APP_VERSION" >> "$GITHUB_ENV" | |
| - name: Print Version | |
| run: | | |
| # Use the env variable, not the steps output | |
| echo APP_VERSION:${{ env.APP_VERSION }} | |
| echo CHART_VERSION:${{ github.ref_name }} | |
| - name: Replace CHART_VERSION in chart/Chart.yaml | |
| run: sed -i 's/CHART_VERSION/${{ github.ref_name }}/g' ./chart/Chart.yaml | |
| - name: Replace APP_VERSION in Chart.yaml | |
| run: sed -i 's/APP_VERSION/${{ env.APP_VERSION }}/g' ./chart/Chart.yaml | |
| # Assuming this file exists in your repo | |
| - name: Replace CHART_VERSION in pre-upgrade-chart | |
| run: sed -i 's/CHART_VERSION/${{ github.ref_name }}/g' ./${{ env.MODULE }}-pre-upgrade-chart/Chart.yaml | |
| - name: Prepare charts_dir | |
| run: | | |
| # Create a directory to hold the charts | |
| mkdir -p _charts_to_publish | |
| # Copy the main chart | |
| cp -R chart _charts_to_publish/${{ env.MODULE }}-chart | |
| # Copy the pre-upgrade chart | |
| cp -R ${{ env.MODULE }}-pre-upgrade-chart _charts_to_publish/ | |
| - name: Publish Helm chart | |
| uses: stefanprodan/helm-gh-pages@master | |
| with: | |
| token: ${{ steps.authenticate.outputs.token }} | |
| # This must match the directory created in the previous step | |
| charts_dir: _charts_to_publish | |
| charts_url: https://charts.krateo.io | |
| owner: krateoplatformops | |
| repository: helm-charts | |
| branch: gh-pages |