|
9 | 9 | default: 'v0.1.0'
|
10 | 10 | source_ref:
|
11 | 11 | description: 'source ref to publish from. E.g.: main or release-x.y'
|
12 |
| - required: true |
13 | 12 | default: 'main'
|
| 13 | + required: true |
| 14 | + prerelease: |
| 15 | + required: false |
| 16 | + default: 'false' |
14 | 17 |
|
15 | 18 | jobs:
|
| 19 | + publish: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + permissions: |
| 22 | + id-token: write |
| 23 | + contents: read |
| 24 | + attestations: write |
| 25 | + packages: write |
| 26 | + env: |
| 27 | + REGISTRY: ghcr.io |
| 28 | + IMAGE_NAME: ${{ github.repository }} |
| 29 | + steps: |
| 30 | + - name: Checkout Code |
| 31 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 32 | + - name: Set up QEMU |
| 33 | + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 |
| 34 | + - name: Set up Docker Buildx |
| 35 | + uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 |
| 36 | + - name: Login to GHCR |
| 37 | + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 #v3.3.0 |
| 38 | + with: |
| 39 | + registry: ${{ env.REGISTRY }} |
| 40 | + username: ${{ github.actor }} |
| 41 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + - name: Generate images meta |
| 43 | + id: meta |
| 44 | + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 |
| 45 | + with: |
| 46 | + images: | |
| 47 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 48 | + tags: | |
| 49 | + type=raw,value=${{ github.event.inputs.version }} |
| 50 | + - name: Build and push |
| 51 | + id: build-push |
| 52 | + uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 #v6.10.0 |
| 53 | + with: |
| 54 | + provenance: true |
| 55 | + sbom: true |
| 56 | + push: true |
| 57 | + platforms: linux/amd64,linux/arm64 |
| 58 | + labels: ${{ steps.meta.outputs.labels }} |
| 59 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }} |
| 60 | + outputs: "type=registry,push=true" |
| 61 | + - name: Attest |
| 62 | + uses: actions/attest-build-provenance@c4fbc648846ca6f503a13a2281a5e7b98aa57202 # v2.0.1 |
| 63 | + id: attest |
| 64 | + with: |
| 65 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 66 | + subject-digest: ${{ steps.build-push.outputs.digest }} |
| 67 | + push-to-registry: true |
| 68 | + |
| 69 | + publish-chart: |
| 70 | + needs: publish |
| 71 | + runs-on: ubuntu-latest |
| 72 | + permissions: |
| 73 | + id-token: write |
| 74 | + contents: write |
| 75 | + attestations: write |
| 76 | + packages: write |
| 77 | + env: |
| 78 | + REGISTRY: ghcr.io |
| 79 | + CHART_DIR: charts |
| 80 | + steps: |
| 81 | + - name: Checkout Code |
| 82 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 83 | + - name: Install Helm |
| 84 | + uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 |
| 85 | + with: |
| 86 | + version: v3.12.0 |
| 87 | + - name: Login to GHCR |
| 88 | + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 #v3.3.0 |
| 89 | + with: |
| 90 | + registry: ${{ env.REGISTRY }} |
| 91 | + username: ${{ github.actor }} |
| 92 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + - name: Package chart |
| 94 | + id: package |
| 95 | + run: | |
| 96 | + helm package ${{ env.CHART_DIR }}/x-pdb --version=${{ github.event.inputs.version }} --app-version=${{ github.event.inputs.version }} |
| 97 | + echo "chart_file=$(ls *.tgz)" >> $GITHUB_OUTPUT |
| 98 | + - name: Push chart to GHCR |
| 99 | + id: push |
| 100 | + run: | |
| 101 | + helm push ${{ steps.package.outputs.chart_file }} oci://${{ env.REGISTRY }}/${{ github.repository }}/charts |& tee helm-push-output.log |
| 102 | + DIGEST=$(awk -F "[, ]+" '/Digest/{print $NF}' < helm-push-output.log) |
| 103 | + echo "digest=$DIGEST" >> $GITHUB_OUTPUT |
| 104 | + - name: Attest |
| 105 | + uses: actions/attest-build-provenance@c4fbc648846ca6f503a13a2281a5e7b98aa57202 # v2.0.1 |
| 106 | + id: attest |
| 107 | + with: |
| 108 | + subject-name: ${{ env.REGISTRY }}/${{ github.repository }}/charts/x-pdb |
| 109 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 110 | + push-to-registry: true |
| 111 | + - name: Publish Helm charts to GH Pages |
| 112 | + uses: stefanprodan/helm-gh-pages@0ad2bb377311d61ac04ad9eb6f252fb68e207260 # v1.7.0 |
| 113 | + with: |
| 114 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 115 | + charts_dir: ${{ env.CHART_DIR }} |
| 116 | + |
16 | 117 | release:
|
| 118 | + needs: [publish, publish-chart] |
17 | 119 | name: Create Release
|
18 | 120 | runs-on: ubuntu-latest
|
19 |
| - |
20 | 121 | steps:
|
21 | 122 | - name: Checkout
|
22 | 123 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
28 | 129 | with:
|
29 | 130 | tag_name: ${{ github.event.inputs.version }}
|
30 | 131 | target_commitish: ${{ github.event.inputs.source_ref }}
|
| 132 | + prerelease: ${{ github.event.inputs.prerelease }} |
31 | 133 | generate_release_notes: true
|
32 |
| - body: | |
33 |
| - Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}` |
34 | 134 | env:
|
35 | 135 | GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
0 commit comments