|
| 1 | +name: Release |
| 2 | + |
| 3 | +# On every v* tag push: |
| 4 | +# 1. Build and push a multi-arch container image to GHCR. |
| 5 | +# 2. Package and push the Helm chart to GHCR (OCI). |
| 6 | +# 3. Create a GitHub Release with the chart artifact. |
| 7 | +# |
| 8 | +# workflow_dispatch publishes image + chart without creating a GitHub Release. |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + tags: ["v*"] |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + version: |
| 16 | + description: "Version to release (without the leading v)" |
| 17 | + required: true |
| 18 | + default: "0.1.0" |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: write |
| 22 | + packages: write |
| 23 | + |
| 24 | +concurrency: |
| 25 | + group: release-${{ github.ref }} |
| 26 | + cancel-in-progress: false |
| 27 | + |
| 28 | +env: |
| 29 | + REGISTRY: ghcr.io |
| 30 | + IMAGE_NAME: hyperbyte-cloud/hyperbytedb-dashboard |
| 31 | + CHART_OCI_REPO: oci://ghcr.io/hyperbyte-cloud/charts |
| 32 | + |
| 33 | +jobs: |
| 34 | + versions: |
| 35 | + name: Compute versions |
| 36 | + runs-on: ubuntu-latest |
| 37 | + outputs: |
| 38 | + chart_version: ${{ steps.compute.outputs.chart_version }} |
| 39 | + image_tag: ${{ steps.compute.outputs.image_tag }} |
| 40 | + is_tag_release: ${{ steps.compute.outputs.is_tag_release }} |
| 41 | + steps: |
| 42 | + - name: Compute versions |
| 43 | + id: compute |
| 44 | + run: | |
| 45 | + set -eu |
| 46 | + if [ "${{ github.ref_type }}" = "tag" ]; then |
| 47 | + TAG="${{ github.ref_name }}" |
| 48 | + CHART_VERSION="${TAG#v}" |
| 49 | + IMAGE_TAG="$CHART_VERSION" |
| 50 | + IS_TAG_RELEASE=true |
| 51 | + else |
| 52 | + CHART_VERSION="${{ inputs.version }}" |
| 53 | + IMAGE_TAG="${{ inputs.version }}" |
| 54 | + IS_TAG_RELEASE=false |
| 55 | + fi |
| 56 | + echo "chart_version=$CHART_VERSION" >> "$GITHUB_OUTPUT" |
| 57 | + echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT" |
| 58 | + echo "is_tag_release=$IS_TAG_RELEASE" >> "$GITHUB_OUTPUT" |
| 59 | +
|
| 60 | + image: |
| 61 | + name: Publish container image |
| 62 | + needs: versions |
| 63 | + runs-on: ubuntu-latest |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - name: Set up QEMU |
| 68 | + uses: docker/setup-qemu-action@v3 |
| 69 | + with: |
| 70 | + platforms: arm64 |
| 71 | + |
| 72 | + - name: Set up Docker Buildx |
| 73 | + uses: docker/setup-buildx-action@v3 |
| 74 | + |
| 75 | + - name: Log in to GitHub Container Registry (PAT) |
| 76 | + if: vars.GHCR_AUTH == 'pat' |
| 77 | + uses: docker/login-action@v3 |
| 78 | + with: |
| 79 | + registry: ${{ env.REGISTRY }} |
| 80 | + username: ${{ secrets.GHCR_USERNAME }} |
| 81 | + password: ${{ secrets.GHCR_PAT }} |
| 82 | + |
| 83 | + - name: Log in to GitHub Container Registry (GITHUB_TOKEN) |
| 84 | + if: vars.GHCR_AUTH != 'pat' |
| 85 | + uses: docker/login-action@v3 |
| 86 | + with: |
| 87 | + registry: ${{ env.REGISTRY }} |
| 88 | + username: ${{ github.repository_owner }} |
| 89 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + |
| 91 | + - name: Build and push multi-arch image |
| 92 | + uses: docker/build-push-action@v6 |
| 93 | + env: |
| 94 | + IMAGE_TAG: ${{ needs.versions.outputs.image_tag }} |
| 95 | + IS_TAG_RELEASE: ${{ needs.versions.outputs.is_tag_release }} |
| 96 | + with: |
| 97 | + context: . |
| 98 | + platforms: linux/amd64,linux/arm64 |
| 99 | + push: true |
| 100 | + provenance: false |
| 101 | + tags: | |
| 102 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.versions.outputs.image_tag }} |
| 103 | + cache-from: type=gha |
| 104 | + cache-to: type=gha,mode=max |
| 105 | + |
| 106 | + - name: Tag latest |
| 107 | + if: needs.versions.outputs.is_tag_release == 'true' |
| 108 | + run: | |
| 109 | + set -eu |
| 110 | + IMAGE="${REGISTRY}/${IMAGE_NAME}" |
| 111 | + docker buildx imagetools create \ |
| 112 | + -t "${IMAGE}:latest" \ |
| 113 | + "${IMAGE}:${{ needs.versions.outputs.image_tag }}" |
| 114 | +
|
| 115 | + chart: |
| 116 | + name: Package & push Helm chart |
| 117 | + needs: [versions, image] |
| 118 | + runs-on: ubuntu-latest |
| 119 | + steps: |
| 120 | + - uses: actions/checkout@v4 |
| 121 | + |
| 122 | + - uses: azure/setup-helm@v4 |
| 123 | + |
| 124 | + - name: Install yq |
| 125 | + run: | |
| 126 | + curl -fsSL "https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64" -o /usr/local/bin/yq |
| 127 | + chmod +x /usr/local/bin/yq |
| 128 | +
|
| 129 | + - name: Log in to GHCR |
| 130 | + run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login "$REGISTRY" -u "${{ github.actor }}" --password-stdin |
| 131 | + |
| 132 | + - name: Stamp default image tag in values.yaml |
| 133 | + env: |
| 134 | + IMAGE_TAG: ${{ needs.versions.outputs.image_tag }} |
| 135 | + run: | |
| 136 | + yq -i '.image.tag = strenv(IMAGE_TAG)' deploy/chart/values.yaml |
| 137 | + echo "--- Stamped values.yaml ---" |
| 138 | + yq '.image' deploy/chart/values.yaml |
| 139 | +
|
| 140 | + - name: Lint chart |
| 141 | + run: helm lint deploy/chart |
| 142 | + |
| 143 | + - name: Package chart |
| 144 | + env: |
| 145 | + CHART_VERSION: ${{ needs.versions.outputs.chart_version }} |
| 146 | + run: | |
| 147 | + helm package deploy/chart \ |
| 148 | + --version "$CHART_VERSION" \ |
| 149 | + --app-version "$CHART_VERSION" \ |
| 150 | + --destination . |
| 151 | +
|
| 152 | + - name: Push chart to GHCR |
| 153 | + run: helm push hyperbytedb-dashboard-*.tgz "$CHART_OCI_REPO" |
| 154 | + |
| 155 | + - name: Upload chart artifact |
| 156 | + uses: actions/upload-artifact@v4 |
| 157 | + with: |
| 158 | + name: hyperbytedb-dashboard-chart |
| 159 | + path: hyperbytedb-dashboard-*.tgz |
| 160 | + if-no-files-found: error |
| 161 | + retention-days: 30 |
| 162 | + |
| 163 | + release: |
| 164 | + name: GitHub Release |
| 165 | + needs: [versions, chart] |
| 166 | + if: github.ref_type == 'tag' |
| 167 | + runs-on: ubuntu-latest |
| 168 | + steps: |
| 169 | + - uses: actions/download-artifact@v4 |
| 170 | + with: |
| 171 | + name: hyperbytedb-dashboard-chart |
| 172 | + |
| 173 | + - name: Create GitHub Release |
| 174 | + uses: softprops/action-gh-release@v2 |
| 175 | + with: |
| 176 | + tag_name: ${{ github.ref_name }} |
| 177 | + name: ${{ github.ref_name }} |
| 178 | + generate_release_notes: true |
| 179 | + files: hyperbytedb-dashboard-*.tgz |
| 180 | + body: | |
| 181 | + ## Container image |
| 182 | +
|
| 183 | + ```text |
| 184 | + ghcr.io/${{ env.IMAGE_NAME }}:${{ needs.versions.outputs.image_tag }} |
| 185 | + ghcr.io/${{ env.IMAGE_NAME }}:latest |
| 186 | + ``` |
| 187 | +
|
| 188 | + ## Helm install |
| 189 | +
|
| 190 | + ```sh |
| 191 | + helm install hyperbytedb-dashboard \ |
| 192 | + oci://ghcr.io/hyperbyte-cloud/charts/hyperbytedb-dashboard \ |
| 193 | + --version ${{ needs.versions.outputs.chart_version }} \ |
| 194 | + --namespace hyperbytedb --create-namespace \ |
| 195 | + --set hyperbytedb.url=http://hyperbytedb-proxy:8086 \ |
| 196 | + --set session.secret="$(openssl rand -base64 32)" |
| 197 | + ``` |
0 commit comments