|
| 1 | +name: Release mongodb-community-database chart |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - "charts/mongodb-community-database/**" |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + packages: write |
| 18 | + id-token: write |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout Code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Configure Git |
| 27 | + run: | |
| 28 | + git config user.name "$GITHUB_ACTOR" |
| 29 | + git config user.email "[email protected]" |
| 30 | +
|
| 31 | + - name: Semantic Release |
| 32 | + uses: cycjimmy/semantic-release-action@v4 |
| 33 | + id: semantic_release |
| 34 | + with: |
| 35 | + dry_run: true |
| 36 | + branch: main |
| 37 | + tag_format: ${version} |
| 38 | + env: |
| 39 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + |
| 41 | + - name: Update Chart version |
| 42 | + id: chart_version |
| 43 | + if: steps.semantic_release.outputs.new_release_published == 'true' |
| 44 | + run: | |
| 45 | + sed -i 's/^version: .*/version: ${{ steps.semantic_release.outputs.new_release_git_tag }}/g' charts/mongodb-community-database/Chart.yaml |
| 46 | + echo "CHART_VERSION=${{ steps.semantic_release.outputs.new_release_git_tag }}" >> $GITHUB_OUTPUT |
| 47 | +
|
| 48 | + - name: Check if tag exists |
| 49 | + id: tag_exists |
| 50 | + if: steps.semantic_release.outputs.new_release_published == 'true' |
| 51 | + run: | |
| 52 | + TAG_EXISTS=true |
| 53 | + if ! [ $(git tag -l "v${{ steps.chart_version.outputs.CHART_VERSION }}") ]; then |
| 54 | + TAG_EXISTS=false |
| 55 | + fi |
| 56 | + echo TAG_EXISTS=$TAG_EXISTS >> $GITHUB_OUTPUT |
| 57 | +
|
| 58 | + - name: Run chart-releaser |
| 59 | + if: steps.tag_exists.outputs.TAG_EXISTS == 'false' |
| 60 | + |
| 61 | + with: |
| 62 | + charts_dir: charts |
| 63 | + config: .github/cr.yaml |
| 64 | + env: |
| 65 | + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 66 | + CR_SKIP_EXISTING: true |
| 67 | + |
| 68 | + - name: Login in to the Container registry |
| 69 | + if: steps.tag_exists.outputs.TAG_EXISTS == 'false' |
| 70 | + uses: docker/login-action@v3 |
| 71 | + with: |
| 72 | + registry: ghcr.io |
| 73 | + username: ${{ github.actor }} |
| 74 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + |
| 76 | + - name: Install Cosign |
| 77 | + if: steps.tag_exists.outputs.TAG_EXISTS == 'false' |
| 78 | + uses: sigstore/cosign-installer@v3 |
| 79 | + |
| 80 | + - name: Install Oras |
| 81 | + if: steps.tag_exists.outputs.TAG_EXISTS == 'false' |
| 82 | + uses: oras-project/setup-oras@v1 |
| 83 | + |
| 84 | + # ref: https://github.com/backstage/charts/blob/88240ce7a0726e3773ee0e4866fbe6325c15267b/.github/workflows/release.yml#L50 |
| 85 | + - name: Publish and Sign OCI Charts |
| 86 | + if: steps.tag_exists.outputs.TAG_EXISTS == 'false' |
| 87 | + run: | |
| 88 | + for chart in `find .cr-release-packages -name '*.tgz' -print`; do |
| 89 | + helm push ${chart} oci://ghcr.io/${GITHUB_REPOSITORY} |& tee helm-push-output.log |
| 90 | + file_name=${chart##*/} |
| 91 | + chart_name=${file_name%-*} |
| 92 | + digest=$(awk -F "[, ]+" '/Digest/{print $NF}' < helm-push-output.log) |
| 93 | + cosign sign -y "ghcr.io/${GITHUB_REPOSITORY}/${chart_name}@${digest}" |
| 94 | +
|
| 95 | + oras push "ghcr.io/${GITHUB_REPOSITORY}/${chart_name}:artifacthub.io" "./charts/${chart_name}/artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml" |
| 96 | + done |
| 97 | + env: |
| 98 | + COSIGN_EXPERIMENTAL: 1 |
0 commit comments