|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY: ghcr.io |
| 9 | + IMAGE_NAME: ${{ github.repository }} |
| 10 | + CHART_NAME: eoapi-notifier |
| 11 | + |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + name: Release Docker and Helm |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + packages: write |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v5 |
| 23 | + |
| 24 | + - name: Extract version |
| 25 | + id: version |
| 26 | + run: | |
| 27 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 28 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 29 | +
|
| 30 | + - name: Set up Docker Buildx |
| 31 | + uses: docker/setup-buildx-action@v3 |
| 32 | + |
| 33 | + - name: Set up Helm |
| 34 | + uses: azure/setup-helm@v4 |
| 35 | + |
| 36 | + - name: Log in to registry |
| 37 | + uses: docker/login-action@v3 |
| 38 | + with: |
| 39 | + registry: ${{ env.REGISTRY }} |
| 40 | + username: ${{ github.actor }} |
| 41 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + |
| 43 | + - name: Extract Docker metadata |
| 44 | + id: meta |
| 45 | + uses: docker/metadata-action@v5 |
| 46 | + with: |
| 47 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 48 | + tags: | |
| 49 | + type=ref,event=tag |
| 50 | + type=raw,value=latest,enable={{is_default_branch}} |
| 51 | +
|
| 52 | + - name: Build and push Docker image |
| 53 | + uses: docker/build-push-action@v6 |
| 54 | + with: |
| 55 | + context: . |
| 56 | + platforms: linux/amd64,linux/arm64 |
| 57 | + push: true |
| 58 | + tags: ${{ steps.meta.outputs.tags }} |
| 59 | + labels: ${{ steps.meta.outputs.labels }} |
| 60 | + cache-from: type=gha |
| 61 | + cache-to: type=gha,mode=max |
| 62 | + |
| 63 | + - name: Update Chart.yaml |
| 64 | + run: | |
| 65 | + sed -i "s/^version:.*/version: ${{ steps.version.outputs.version }}/" helm-chart/${{ env.CHART_NAME }}/Chart.yaml |
| 66 | + sed -i "s/^appVersion:.*/appVersion: \"${{ steps.version.outputs.version }}\"/" helm-chart/${{ env.CHART_NAME }}/Chart.yaml |
| 67 | +
|
| 68 | + - name: Lint and package Helm chart |
| 69 | + run: | |
| 70 | + helm lint helm-chart/${{ env.CHART_NAME }} |
| 71 | + helm package helm-chart/${{ env.CHART_NAME }} --destination . |
| 72 | +
|
| 73 | + - name: Push Helm chart |
| 74 | + run: | |
| 75 | + echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ${{ env.REGISTRY }} --username ${{ github.actor }} --password-stdin |
| 76 | + helm push ${{ env.CHART_NAME }}-${{ steps.version.outputs.version }}.tgz oci://${{ env.REGISTRY }}/${{ github.repository_owner }}/charts |
0 commit comments