chore: improve workflows #89
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release charts | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- "charts/**" | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
# default install latest (stable) | |
- name: Set up Helm | |
uses: azure/setup-helm@v4 | |
- name: Add repositories | |
run: | | |
for dir in $(ls -d charts/*/); do | |
helm dependency list $dir 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done | |
done | |
- name: Run chart-releaser | |
uses: helm/[email protected] | |
with: | |
charts_dir: charts | |
config: .github/cr.yaml | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_SKIP_EXISTING: true | |
- name: Login in to the Container registry | |
if: steps.tag_exists.outputs.TAG_EXISTS == 'false' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Cosign | |
if: steps.tag_exists.outputs.TAG_EXISTS == 'false' | |
uses: sigstore/cosign-installer@v3 | |
- name: Install Oras | |
if: steps.tag_exists.outputs.TAG_EXISTS == 'false' | |
uses: oras-project/setup-oras@v1 | |
# ref: https://github.com/backstage/charts/blob/88240ce7a0726e3773ee0e4866fbe6325c15267b/.github/workflows/release.yml#L50 | |
- name: Publish and Sign OCI Charts | |
if: steps.tag_exists.outputs.TAG_EXISTS == 'false' | |
run: | | |
for chart in `find .cr-release-packages -name '*.tgz' -print`; do | |
helm push ${chart} oci://ghcr.io/${GITHUB_REPOSITORY} |& tee helm-push-output.log | |
file_name=${chart##*/} | |
chart_name=${file_name%-*} | |
digest=$(awk -F "[, ]+" '/Digest/{print $NF}' < helm-push-output.log) | |
cosign sign -y "ghcr.io/${GITHUB_REPOSITORY}/${chart_name}@${digest}" | |
oras push "ghcr.io/${GITHUB_REPOSITORY}/${chart_name}:${{ steps.chart_version.outputs.CHART_VERSION }}" | |
done | |
env: | |
COSIGN_EXPERIMENTAL: 1 |