|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: read |
| 13 | + packages: write |
| 14 | + env: |
| 15 | + REGISTRY: ghcr.io |
| 16 | + IMAGE_NAME: ${{ github.repository }} |
| 17 | + CHART_NAME: model-csi-driver |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: Set up QEMU |
| 23 | + uses: docker/setup-qemu-action@v3 |
| 24 | + |
| 25 | + - name: Set up Docker Buildx |
| 26 | + uses: docker/setup-buildx-action@v3 |
| 27 | + |
| 28 | + - name: Extract tag name (version) |
| 29 | + id: extract_tag |
| 30 | + run: echo "tag=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT" |
| 31 | + |
| 32 | + - name: Login to GitHub Container Registry |
| 33 | + uses: docker/login-action@v3 |
| 34 | + with: |
| 35 | + registry: ghcr.io |
| 36 | + username: ${{ github.actor }} |
| 37 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + |
| 39 | + - name: Build and push Docker image |
| 40 | + uses: docker/build-push-action@v5 |
| 41 | + with: |
| 42 | + context: . |
| 43 | + file: ./build/Dockerfile |
| 44 | + push: true |
| 45 | + tags: | |
| 46 | + ghcr.io/${{ github.repository }}:${{ steps.extract_tag.outputs.tag }} |
| 47 | + ghcr.io/${{ github.repository }}:latest |
| 48 | +
|
| 49 | + - name: Install Helm |
| 50 | + run: | |
| 51 | + curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash |
| 52 | +
|
| 53 | + - name: Update chart version |
| 54 | + run: | |
| 55 | + TAG=$(echo ${{ steps.extract_tag.outputs.tag }} | sed 's/^v//') |
| 56 | + sed -i "s/^$TAG$/version: ${TAG}/" charts/${CHART_NAME}/Chart.yaml |
| 57 | +
|
| 58 | + - name: Helm registry login |
| 59 | + run: | |
| 60 | + echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin |
| 61 | +
|
| 62 | + - name: Helm package chart |
| 63 | + run: | |
| 64 | + helm package charts/${CHART_NAME} --destination . |
| 65 | + |
| 66 | + - name: Helm push chart to GHCR |
| 67 | + run: | |
| 68 | + CHART_VERSION=$(yq e '.version' charts/${CHART_NAME}/Chart.yaml) |
| 69 | + CHART_PKG=${CHART_NAME}-${CHART_VERSION}.tgz |
| 70 | + helm push $CHART_PKG oci://ghcr.io/${{ github.repository_owner }}/charts |
0 commit comments