|
| 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: Cache Docker layers |
| 23 | + uses: actions/cache@v4 |
| 24 | + with: |
| 25 | + path: /tmp/.buildx-cache |
| 26 | + key: ${{ runner.os }}-docker-buildx-${{ github.sha }} |
| 27 | + restore-keys: | |
| 28 | + ${{ runner.os }}-docker-buildx- |
| 29 | +
|
| 30 | + - name: Set up QEMU |
| 31 | + uses: docker/setup-qemu-action@v3 |
| 32 | + |
| 33 | + - name: Set up Docker Buildx |
| 34 | + uses: docker/setup-buildx-action@v3 |
| 35 | + |
| 36 | + - name: Extract tag name (version) |
| 37 | + id: extract_tag |
| 38 | + run: echo "tag=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT" |
| 39 | + |
| 40 | + - name: Login to GitHub Container Registry |
| 41 | + uses: docker/login-action@v3 |
| 42 | + with: |
| 43 | + registry: ghcr.io |
| 44 | + username: ${{ github.actor }} |
| 45 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Build and push Docker image |
| 48 | + uses: docker/build-push-action@v5 |
| 49 | + with: |
| 50 | + context: . |
| 51 | + file: ./build/Dockerfile |
| 52 | + push: true |
| 53 | + platforms: linux/amd64,linux/arm64 |
| 54 | + tags: | |
| 55 | + ghcr.io/${{ github.repository }}:${{ steps.extract_tag.outputs.tag }} |
| 56 | + ghcr.io/${{ github.repository }}:latest |
| 57 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 58 | + cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 59 | + |
| 60 | + - name: Move Docker Build Cache |
| 61 | + run: | |
| 62 | + rm -rf /tmp/.buildx-cache |
| 63 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache || true |
| 64 | +
|
| 65 | + - name: Install Helm |
| 66 | + run: | |
| 67 | + curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash |
| 68 | +
|
| 69 | + - name: Update chart version |
| 70 | + run: | |
| 71 | + TAG=$(echo ${{ steps.extract_tag.outputs.tag }} | sed 's/^v//') |
| 72 | + sed -i "s/VERSION/${TAG}/g" charts/${CHART_NAME}/Chart.yaml |
| 73 | +
|
| 74 | + - name: Helm registry login |
| 75 | + run: | |
| 76 | + echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin |
| 77 | +
|
| 78 | + - name: Helm package chart |
| 79 | + run: | |
| 80 | + helm package charts/${CHART_NAME} --destination . |
| 81 | + |
| 82 | + - name: Helm push chart to GHCR |
| 83 | + run: | |
| 84 | + CHART_VERSION=$(yq e '.version' charts/${CHART_NAME}/Chart.yaml) |
| 85 | + CHART_PKG=${CHART_NAME}-${CHART_VERSION}.tgz |
| 86 | + helm push $CHART_PKG oci://ghcr.io/${{ github.repository_owner }}/charts |
0 commit comments