Skip to content

Merge pull request #17 from github/add-policy-chart #18

Merge pull request #17 from github/add-policy-chart

Merge pull request #17 from github/add-policy-chart #18

Workflow file for this run

name: Release
on:
push:
tags:
- policy-controller-v*
- policies-v*
jobs:
release:
runs-on: ubuntu-latest
permissions:
attestations: write
contents: read
id-token: write
packages: write
env:
REGISTRY: ghcr.io
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Extract Helm chart name and version
id: release-details
run: |
# tag names are in the format <chart-name>-v<semantic-version>
# so we need to extract the chart name
chart_name=$(echo -n ${{ github.ref_name }} | awk -F'-v' '{print $1}')
echo chart_name=$chart_name >> $GITHUB_OUTPUT
# extract the version from the tag name
version=$(echo -n ${{ github.ref_name }} | sed "s/^$chart_name-//")
echo chart_version=$version >> $GITHUB_OUTPUT
- name: Package Helm chart
run: helm package charts/${{ steps.release-details.outputs.chart_name }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push packaged chart to GHCR
run: helm push ${{ github.ref_name }}.tgz oci://${{ env.REGISTRY }}/${{ github.repository }}
- uses: imjasonh/setup-crane@00c9e93efa4e1138c9a7a5c594acd6c75a2fbf0c # v0.3
- name: Get pushed chart digest
id: get-digest
run: |
digest=$(crane digest ${{ env.REGISTRY }}/${{ github.repository }}/${{ steps.release-details.outputs.chart_name }}:${{ steps.release-details.outputs.chart_version }})
echo digest=$digest >> $GITHUB_OUTPUT
- name: Attest
uses: actions/attest-build-provenance@173725a1209d09b31f9d30a3890cf2757ebbff0d # v1.1.2
with:
subject-name: ${{ env.REGISTRY }}/${{ github.repository }}/${{ steps.release-details.outputs.chart_name }}
subject-digest: ${{ steps.get-digest.outputs.digest }}
push-to-registry: true