|
| 1 | +# Copyright The Linux Foundation and each contributor to LFX. |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +name: Publish Tagged Release |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - v* |
| 10 | + |
| 11 | +env: |
| 12 | + COSIGN_VERSION: v2.5.3 |
| 13 | + HELM_VERSION: v3.18.4 |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + publish: |
| 20 | + name: Publish Tagged Release |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + packages: write |
| 25 | + outputs: |
| 26 | + app_version: ${{ steps.prepare.outputs.app_version }} |
| 27 | + chart_name: ${{ steps.prepare.outputs.chart_name }} |
| 28 | + chart_version: ${{ steps.prepare.outputs.chart_version }} |
| 29 | + steps: |
| 30 | + - name: Checkout repository |
| 31 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 32 | + |
| 33 | + - name: Prepare versions and chart name |
| 34 | + id: prepare |
| 35 | + run: | |
| 36 | + set -euo pipefail |
| 37 | + APP_VERSION=$(echo ${{ github.ref_name }} | sed 's/v//g') |
| 38 | + CHART_NAME="$(yq '.name' charts/*/Chart.yaml)" |
| 39 | + CHART_VERSION="$(yq '.version' charts/*/Chart.yaml)" |
| 40 | + { |
| 41 | + echo "app_version=$APP_VERSION" |
| 42 | + echo "chart_name=$CHART_NAME" |
| 43 | + echo "chart_version=$CHART_VERSION" |
| 44 | + } >> "$GITHUB_OUTPUT" |
| 45 | +
|
| 46 | + - name: Setup Go |
| 47 | + uses: actions/setup-go@v5 |
| 48 | + with: |
| 49 | + go-version-file: go.mod |
| 50 | + |
| 51 | + - name: Setup Ko |
| 52 | + uses: ko-build/setup-ko@v0.8 |
| 53 | + with: |
| 54 | + version: v0.17.1 |
| 55 | + |
| 56 | + - name: Build and publish query service image |
| 57 | + run: | |
| 58 | + ko build github.com/linuxfoundation/lfx-v2-query-service/cmd \ |
| 59 | + -B \ |
| 60 | + --platform linux/amd64,linux/arm64 \ |
| 61 | + -t ${{ github.ref_name }} \ |
| 62 | + -t ${{ steps.prepare.outputs.app_version }} \ |
| 63 | + -t latest \ |
| 64 | + --sbom spdx |
| 65 | +
|
| 66 | + release-helm-chart: |
| 67 | + needs: publish |
| 68 | + runs-on: ubuntu-24.04 |
| 69 | + permissions: |
| 70 | + contents: write |
| 71 | + packages: write |
| 72 | + id-token: write |
| 73 | + outputs: |
| 74 | + digest: ${{ steps.publish-ghcr.outputs.digest }} |
| 75 | + image_name: ${{ steps.publish-ghcr.outputs.image_name }} |
| 76 | + steps: |
| 77 | + - name: Checkout repository |
| 78 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 79 | + |
| 80 | + - name: Publish Chart to GHCR |
| 81 | + id: publish-ghcr |
| 82 | + uses: linuxfoundation/lfx-public-workflows/.github/actions/helm-chart-oci-publisher@c465d6571fa0b8be9d551d902955164ea04a00af # main |
| 83 | + with: |
| 84 | + name: ${{ needs.publish.outputs.chart_name }} |
| 85 | + repository: ${{ github.repository }}/chart |
| 86 | + chart_version: ${{ needs.publish.outputs.chart_version }} |
| 87 | + app_version: ${{ needs.publish.outputs.app_version }} |
| 88 | + registry: ghcr.io |
| 89 | + registry_username: ${{ github.actor }} |
| 90 | + registry_password: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + |
| 92 | + - name: Install Cosign |
| 93 | + uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2 |
| 94 | + with: |
| 95 | + cosign-release: "${{ env.COSIGN_VERSION }}" |
| 96 | + |
| 97 | + - name: Login to GitHub |
| 98 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 |
| 99 | + with: |
| 100 | + registry: ghcr.io |
| 101 | + username: ${{ github.actor }} |
| 102 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + |
| 104 | + - name: Sign the Helm chart in GHCR |
| 105 | + env: |
| 106 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + run: | |
| 108 | + set -euo pipefail |
| 109 | + cosign sign --yes '${{ steps.publish-ghcr.outputs.image_name }}@${{ steps.publish-ghcr.outputs.digest }}' |
| 110 | +
|
| 111 | + create-ghcr-helm-provenance: |
| 112 | + needs: |
| 113 | + - release-helm-chart |
| 114 | + permissions: |
| 115 | + actions: read |
| 116 | + id-token: write |
| 117 | + packages: write |
| 118 | + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0 |
| 119 | + with: |
| 120 | + image: ${{ needs.release-helm-chart.outputs.image_name }} |
| 121 | + digest: ${{ needs.release-helm-chart.outputs.digest }} |
| 122 | + registry-username: ${{ github.actor }} |
| 123 | + secrets: |
| 124 | + registry-password: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments