fix: images dir (#22) #33
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: Build and Release Helm Chart | |
| on: | |
| push: | |
| branches: | |
| - main # Main branch updates | |
| tags: | |
| - 'v*' # v* tags for release | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: 'Branch or tag to build (e.g., main, v0.1.0)' | |
| required: false | |
| type: string | |
| default: 'main' | |
| sync_to_doc: | |
| description: 'Sync index.yaml to curvine-doc repository' | |
| required: true | |
| type: boolean | |
| default: false | |
| jobs: | |
| build-charts: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| chart: | |
| - name: curvine-csi | |
| path: curvine-csi | |
| - name: curvine-runtime | |
| path: curvine-runtime | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }} | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4.3.0 | |
| with: | |
| version: 'latest' | |
| - name: Extract tag/version information | |
| id: tag | |
| run: | | |
| # Handle tag push | |
| if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| TAG=${GITHUB_REF#refs/tags/} | |
| IS_TAG=true | |
| IS_MAIN_BRANCH=false | |
| # Handle main branch push | |
| elif [[ "$GITHUB_REF" == refs/heads/main ]]; then | |
| TAG="latest" | |
| IS_TAG=false | |
| IS_MAIN_BRANCH=true | |
| else | |
| echo "Error: Unexpected ref: $GITHUB_REF" | |
| exit 1 | |
| fi | |
| # Extract version from tag (remove 'v' prefix if present) | |
| if [[ "$TAG" == v* ]]; then | |
| VERSION=${TAG#v} | |
| elif [ "$IS_MAIN_BRANCH" == "true" ]; then | |
| # For main branch, will be set in next step after reading Chart.yaml | |
| VERSION="" | |
| else | |
| VERSION=$TAG | |
| fi | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "is_tag=$IS_TAG" >> $GITHUB_OUTPUT | |
| echo "is_main_branch=$IS_MAIN_BRANCH" >> $GITHUB_OUTPUT | |
| echo "Tag/Version: $TAG ($VERSION)" | |
| echo "Is Tag: $IS_TAG" | |
| echo "Is Main Branch: $IS_MAIN_BRANCH" | |
| - name: Prepare pre-release version for main branch | |
| if: steps.tag.outputs.is_main_branch == 'true' | |
| id: prerelease | |
| run: | | |
| # Read current version from Chart.yaml | |
| CURRENT_VERSION=$(grep '^version:' ${{ matrix.chart.path }}/Chart.yaml | awk '{print $2}' | tr -d '"') | |
| echo "Current Chart version for ${{ matrix.chart.name }}: $CURRENT_VERSION" | |
| # Extract base version (remove any pre-release suffix like -alpha.1, -dev+abc123, etc.) | |
| # Examples: 0.2.0 -> 0.2.0, 0.2.0-alpha.1 -> 0.2.0, 0.2.1-dev+abc123 -> 0.2.1 | |
| BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-.*//') | |
| echo "Base version: $BASE_VERSION" | |
| # Generate FIXED pre-release version for testing: use base version + -dev suffix (NO commit hash) | |
| # Format: BASE_VERSION-dev | |
| # This ensures the same version is always used for main branch, allowing it to be overwritten | |
| # Perfect for testing without polluting the version history | |
| PRE_RELEASE_VERSION="${BASE_VERSION}-dev" | |
| echo "Pre-release version (fixed for testing): $PRE_RELEASE_VERSION" | |
| echo "version=$PRE_RELEASE_VERSION" >> $GITHUB_OUTPUT | |
| # Update Chart.yaml with pre-release version | |
| # GitHub Actions runs on Linux, so use Linux sed syntax | |
| sed -i "s/^version:.*/version: $PRE_RELEASE_VERSION/" ${{ matrix.chart.path }}/Chart.yaml | |
| echo "Updated Chart.yaml version to: $PRE_RELEASE_VERSION" | |
| cat ${{ matrix.chart.path }}/Chart.yaml | |
| - name: Set final version | |
| id: version | |
| run: | | |
| if [ "${{ steps.tag.outputs.is_main_branch }}" == "true" ]; then | |
| FINAL_VERSION="${{ steps.prerelease.outputs.version }}" | |
| else | |
| FINAL_VERSION="${{ steps.tag.outputs.version }}" | |
| fi | |
| echo "version=$FINAL_VERSION" >> $GITHUB_OUTPUT | |
| echo "Final Chart Version: $FINAL_VERSION" | |
| - name: Validate Helm chart | |
| run: | | |
| cd ${{ matrix.chart.path }} | |
| helm lint . | |
| - name: Package Helm chart | |
| id: package | |
| run: | | |
| mkdir -p dist | |
| cd ${{ matrix.chart.path }} | |
| helm package . --destination ../dist | |
| cd ../dist | |
| CHART_FILE=$(ls *.tgz) | |
| echo "chart_file=dist/$CHART_FILE" >> $GITHUB_OUTPUT | |
| echo "chart_name=$CHART_FILE" >> $GITHUB_OUTPUT | |
| echo "Packaged chart for ${{ matrix.chart.name }}: $CHART_FILE" | |
| - name: Generate chart checksum | |
| id: checksum | |
| run: | | |
| cd dist | |
| DIGEST=$(sha256sum *.tgz | awk '{print $1}') | |
| echo "digest=$DIGEST" >> $GITHUB_OUTPUT | |
| echo "${{ matrix.chart.name }} Digest (SHA256): $DIGEST" | |
| - name: Upload chart artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.chart.name }}-${{ steps.tag.outputs.tag }} | |
| path: dist/*.tgz | |
| retention-days: 90 | |
| - name: Build Summary | |
| run: | | |
| echo "## Build Summary - ${{ matrix.chart.name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Chart**: ${{ matrix.chart.name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Tag/Version**: ${{ steps.tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Chart Version**: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Chart Package**: ${{ steps.package.outputs.chart_name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Digest (SHA256)**: ${{ steps.checksum.outputs.digest }}" >> $GITHUB_STEP_SUMMARY | |
| create-release: | |
| needs: build-charts | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract tag/version information | |
| id: tag | |
| run: | | |
| # Handle tag push | |
| if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| TAG=${GITHUB_REF#refs/tags/} | |
| IS_TAG=true | |
| IS_MAIN_BRANCH=false | |
| # Handle main branch push | |
| elif [[ "$GITHUB_REF" == refs/heads/main ]]; then | |
| TAG="latest" | |
| IS_TAG=false | |
| IS_MAIN_BRANCH=true | |
| else | |
| echo "Error: Unexpected ref: $GITHUB_REF" | |
| exit 1 | |
| fi | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "is_tag=$IS_TAG" >> $GITHUB_OUTPUT | |
| echo "is_main_branch=$IS_MAIN_BRANCH" >> $GITHUB_OUTPUT | |
| echo "Tag: $TAG" | |
| echo "Is Tag: $IS_TAG" | |
| echo "Is Main Branch: $IS_MAIN_BRANCH" | |
| - name: Download all chart artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| pattern: '*-${{ steps.tag.outputs.tag }}' | |
| merge-multiple: true | |
| - name: Generate unified checksums | |
| id: checksums | |
| run: | | |
| cd dist | |
| sha256sum *.tgz > checksums.txt | |
| echo "Generated unified checksums.txt:" | |
| cat checksums.txt | |
| - name: Determine release type | |
| id: release | |
| run: | | |
| IS_V_TAG=false | |
| if [[ "${{ steps.tag.outputs.tag }}" == v* ]]; then | |
| IS_V_TAG=true | |
| fi | |
| # v* tags create normal releases | |
| # main branch updates create/update "latest" release | |
| if [ "${{ steps.tag.outputs.is_tag }}" == "true" ] && [ "$IS_V_TAG" == "true" ]; then | |
| RELEASE_TYPE="tag" | |
| RELEASE_TAG="${{ steps.tag.outputs.tag }}" | |
| elif [ "${{ steps.tag.outputs.is_main_branch }}" == "true" ]; then | |
| RELEASE_TYPE="latest" | |
| RELEASE_TAG="latest" | |
| else | |
| RELEASE_TYPE="none" | |
| RELEASE_TAG="" | |
| fi | |
| echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT | |
| echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT | |
| echo "should_release=$([ "$RELEASE_TYPE" != "none" ] && echo "true" || echo "false")" >> $GITHUB_OUTPUT | |
| echo "Release Type: $RELEASE_TYPE" | |
| echo "Release Tag: $RELEASE_TAG" | |
| - name: Create/Update GitHub Release (v* tag) | |
| if: steps.release.outputs.release_type == 'tag' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.release.outputs.release_tag }} | |
| name: Release ${{ steps.release.outputs.release_tag }} | |
| body: | | |
| ## Helm Charts Release ${{ steps.release.outputs.release_tag }} | |
| ### Chart Information | |
| - **Tag**: ${{ steps.release.outputs.release_tag }} | |
| - **Commit**: ${{ github.sha }} | |
| This release includes two Helm charts: | |
| - **curvine-csi**: CSI Driver for Curvine storage | |
| - **curvine-runtime**: Curvine distributed cache system | |
| ### Installation | |
| #### Curvine Runtime | |
| ```bash | |
| helm repo add curvineio https://curvineio.github.io/curvine-doc/helm-charts | |
| helm repo update | |
| helm install curvine curvineio/curvine-runtime | |
| ``` | |
| #### Curvine CSI Driver | |
| ```bash | |
| helm repo add curvineio https://curvineio.github.io/curvine-doc/helm-charts | |
| helm repo update | |
| helm install curvine-csi curvineio/curvine-csi | |
| ``` | |
| ### Files | |
| - curvine-csi chart package | |
| - curvine-runtime chart package | |
| - checksums.txt (SHA256 checksums for both charts) | |
| files: | | |
| dist/*.tgz | |
| dist/checksums.txt | |
| draft: false | |
| prerelease: ${{ contains(steps.release.outputs.release_tag, '-') || contains(steps.release.outputs.release_tag, 'alpha') || contains(steps.release.outputs.release_tag, 'beta') || contains(steps.release.outputs.release_tag, 'rc') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create/Update GitHub Release (main branch -> latest) | |
| if: steps.release.outputs.release_type == 'latest' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: latest | |
| name: Latest Release (Testing - main branch) | |
| body: | | |
| ## Latest Helm Charts Release (For Testing Only) | |
| ⚠️ **This is a testing release that is overwritten on every push to `main` branch.** | |
| - Use this for development and testing purposes only | |
| - For production use, please use versioned releases (v*) | |
| - Chart versions are fixed (e.g., 0.0.0-dev) and overwrite previous builds | |
| ### Chart Information | |
| - **Branch**: main | |
| - **Commit**: ${{ github.sha }} | |
| - **Commit Message**: ${{ github.event.head_commit.message }} | |
| - **Build Time**: ${{ github.event.head_commit.timestamp }} | |
| This release includes two Helm charts: | |
| - **curvine-csi-dev**: CSI Driver for Curvine storage (testing version) | |
| - **curvine-runtime-dev**: Curvine distributed cache system (testing version) | |
| ### Installation | |
| Download and install manually from release assets below, or use: | |
| ```bash | |
| # Download specific chart | |
| wget https://github.com/CurvineIO/curvine-helm/releases/download/latest/curvine-runtime-*.tgz | |
| helm install curvine ./curvine-runtime-*.tgz | |
| ``` | |
| ### Files | |
| - curvine-csi chart package (version: *-dev) | |
| - curvine-runtime chart package (version: *-dev) | |
| - checksums.txt (SHA256 checksums for both charts) | |
| > **Note**: This release is automatically overwritten. Do not use in production! | |
| files: | | |
| dist/*.tgz | |
| dist/checksums.txt | |
| draft: false | |
| prerelease: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Release Summary | |
| run: | | |
| echo "## Release Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Release Type**: ${{ steps.release.outputs.release_type }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Release Tag**: ${{ steps.release.outputs.release_tag }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Is Tag**: ${{ steps.tag.outputs.is_tag }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Is Main Branch**: ${{ steps.tag.outputs.is_main_branch }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Packaged Charts" >> $GITHUB_STEP_SUMMARY | |
| ls -lh dist/*.tgz >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Checksums" >> $GITHUB_STEP_SUMMARY | |
| cat dist/checksums.txt >> $GITHUB_STEP_SUMMARY | |
| sync-to-helm-repo: | |
| needs: create-release | |
| # Only sync when manually triggered with sync_to_doc=true | |
| if: always() && needs.create-release.result == 'success' && github.event_name == 'workflow_dispatch' && inputs.sync_to_doc == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout curvine-doc repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: CurvineIO/curvine-doc | |
| token: ${{ secrets.CURVINE_DOC_TOKEN }} | |
| path: curvine-doc | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4.3.0 | |
| with: | |
| version: 'latest' | |
| - name: Extract version/tag information | |
| id: version | |
| run: | | |
| # Determine the release tag based on trigger type | |
| if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| # For tag push: use the tag name | |
| TAG=${GITHUB_REF#refs/tags/} | |
| VERSION=${TAG#v} | |
| elif [[ "$GITHUB_REF" == refs/heads/main ]]; then | |
| # For main branch: use "latest" as release tag | |
| TAG="latest" | |
| VERSION="latest" | |
| elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| # For manual trigger: determine from inputs.ref | |
| REF="${{ inputs.ref }}" | |
| if [[ "$REF" == v* ]]; then | |
| TAG="$REF" | |
| VERSION="${REF#v}" | |
| elif [[ "$REF" == "main" ]] || [[ -z "$REF" ]]; then | |
| TAG="latest" | |
| VERSION="latest" | |
| else | |
| # For other branches, use latest | |
| TAG="latest" | |
| VERSION="latest" | |
| fi | |
| else | |
| TAG="latest" | |
| VERSION="latest" | |
| fi | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Release tag: $TAG" | |
| echo "Version: $VERSION" | |
| - name: Download old index.yaml from curvine-doc | |
| run: | | |
| mkdir -p temp-charts | |
| cd temp-charts | |
| # Try to download existing index.yaml | |
| echo "Downloading existing index.yaml from curvine-doc..." | |
| curl -fsSL https://curvineio.github.io/curvine-doc/helm-charts/index.yaml -o old-index.yaml || { | |
| echo "No existing index.yaml found, will create new one" | |
| touch old-index.yaml | |
| } | |
| if [ -s old-index.yaml ]; then | |
| echo "Existing index.yaml found:" | |
| head -20 old-index.yaml | |
| else | |
| echo "Creating new index.yaml" | |
| fi | |
| - name: Download current release charts | |
| run: | | |
| cd temp-charts | |
| RELEASE_TAG="${{ steps.version.outputs.tag }}" | |
| echo "Downloading charts from release: $RELEASE_TAG" | |
| # Download using GitHub CLI | |
| gh release download "$RELEASE_TAG" \ | |
| --repo CurvineIO/curvine-helm \ | |
| --pattern "*.tgz" | |
| echo "Downloaded charts:" | |
| ls -lh *.tgz | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate merged index.yaml with Release URLs | |
| run: | | |
| cd temp-charts | |
| RELEASE_TAG="${{ steps.version.outputs.tag }}" | |
| # Check if old-index.yaml exists and is not empty | |
| if [ -s old-index.yaml ]; then | |
| echo "Merging with existing index.yaml..." | |
| # Generate index.yaml with Release URLs and merge with old index | |
| helm repo index . \ | |
| --url "https://github.com/CurvineIO/curvine-helm/releases/download/${RELEASE_TAG}" \ | |
| --merge old-index.yaml | |
| else | |
| echo "Creating new index.yaml (no existing index found)..." | |
| # Generate new index.yaml without merging | |
| helm repo index . \ | |
| --url "https://github.com/CurvineIO/curvine-helm/releases/download/${RELEASE_TAG}" | |
| fi | |
| echo "Generated index.yaml (first 100 lines):" | |
| head -100 index.yaml | |
| echo "" | |
| echo "Entries count:" | |
| grep -c "version:" index.yaml || echo "0" | |
| - name: Copy index.yaml to curvine-doc | |
| run: | | |
| mkdir -p curvine-doc/static/helm-charts | |
| cp temp-charts/index.yaml curvine-doc/static/helm-charts/index.yaml | |
| echo "✅ Copied merged index.yaml to curvine-doc/static/helm-charts/" | |
| - name: Commit and push to curvine-doc | |
| run: | | |
| cd curvine-doc | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add static/helm-charts/index.yaml | |
| # Check if there are changes to commit | |
| if git diff --staged --quiet; then | |
| echo "No changes to index.yaml" | |
| else | |
| COMMIT_MSG="chore(helm): update index.yaml from release ${{ steps.version.outputs.tag }} | |
| Auto-generated by GitHub Actions | |
| Source: CurvineIO/curvine-helm@${{ github.sha }} | |
| Release: ${{ steps.version.outputs.tag }} | |
| This index.yaml includes all historical versions with URLs pointing to GitHub Releases." | |
| git commit -m "$COMMIT_MSG" | |
| git push | |
| echo "✅ Successfully pushed index.yaml to curvine-doc repository" | |
| fi | |
| - name: Sync Summary | |
| run: | | |
| echo "## Helm Repository Sync Complete" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Version**: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Release Tag**: ${{ steps.version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Status**: ✅ Synced successfully" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Architecture" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Charts Storage**: GitHub Releases (curvine-helm)" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Index Location**: curvine-doc/static/helm-charts/index.yaml" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Chart URLs**: Point to GitHub Releases" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### URLs" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Index**: https://curvineio.github.io/curvine-doc/helm-charts/index.yaml" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Charts**: https://github.com/CurvineIO/curvine-helm/releases" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Usage" >> $GITHUB_STEP_SUMMARY | |
| echo '```bash' >> $GITHUB_STEP_SUMMARY | |
| echo "helm repo add curvineio https://curvineio.github.io/curvine-doc/helm-charts" >> $GITHUB_STEP_SUMMARY | |
| echo "helm repo update" >> $GITHUB_STEP_SUMMARY | |
| echo "helm search repo curvineio" >> $GITHUB_STEP_SUMMARY | |
| echo "helm install curvine curvineio/curvine-runtime" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |