Release Prefect Operator Helm Chart #13
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 Prefect Operator Helm Chart | |
"on": | |
workflow_dispatch: {} | |
workflow_call: {} | |
permissions: {} | |
jobs: | |
release: | |
permissions: | |
# GitHub considers creating releases and uploading assets as writing contents. | |
contents: write | |
runs-on: ubuntu-latest | |
outputs: | |
releaseVersion: ${{ steps.output_versions.outputs.releaseVersion }} | |
operatorVersion: ${{ steps.output_versions.outputs.operatorVersion }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# We set the chart release version here - the version schema | |
# is a SemVer adherent date-based versioning scheme that looks like: | |
# 2024.2.9125019 | |
# which equates to a release on 2/9/24 at 12:50:19 | |
- name: Get the version tags | |
id: get_version | |
run: | | |
# Enable pipefail so git command failures do not result in null versions downstream | |
set -x | |
echo "RELEASE_VERSION=$(date +'%Y.%-m.%-d%H%M%S')" >> $GITHUB_ENV | |
# This ensures that the latest tag we grab will be of the operator image, and not the helm chart | |
echo "OPERATOR_VERSION=$(\ | |
git ls-remote --tags --refs --sort="v:refname" \ | |
origin 'v[0-9].[0-9].[0-9]' | tail -n1 | sed 's/.*\///' | |
)" >> $GITHUB_ENV | |
- name: Output versions as GitHub Outputs | |
id: output_versions | |
run: | | |
echo "releaseVersion=$RELEASE_VERSION" >> $GITHUB_OUTPUT | |
echo "operatorVersion=$OPERATOR_VERSION" >> $GITHUB_OUTPUT | |
- name: Configure Git | |
run: | | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
- name: Set up Helm | |
uses: azure/setup-helm@v4 | |
- name: Prepare GPG key for signing | |
run: | | |
gpg_dir=/tmp/.gpg | |
mkdir "$gpg_dir" | |
keyring="$gpg_dir/secring.gpg" | |
# store the secret keyring in a .gpg file | |
base64 -d <<< "$GPG_KEYRING_BASE64" > "$keyring" | |
passphrase_file="$gpg_dir/passphrase" | |
# store passphrase in a file | |
echo "$GPG_PASSPHRASE" > "$passphrase_file" | |
echo "SIGN_PASSPHRASE_FILE=$passphrase_file" >> "$GITHUB_ENV" | |
echo "SIGN_KEYRING=$keyring" >> "$GITHUB_ENV" | |
env: | |
GPG_KEYRING_BASE64: "${{ secrets.GPG_KEYRING_BASE64 }}" | |
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}" | |
- name: Add dependency chart repos | |
run: | | |
helm repo add bitnami https://charts.bitnami.com/bitnami | |
- name: Package Operator helm chart | |
run: | | |
mkdir -p /tmp/chart | |
cd deploy/charts | |
# Update the operator version tag in values.yaml | |
sed -i "s/tag:.*$/tag: $IMAGE_VERSION/g" prefect-operator/values.yaml | |
helm package prefect-operator \ | |
--destination /tmp/chart \ | |
--dependency-update \ | |
--version $RELEASE_VERSION \ | |
--app-version v$IMAGE_VERSION \ | |
--sign --key '[email protected]' \ | |
--keyring $SIGN_KEYRING \ | |
--passphrase-file $SIGN_PASSPHRASE_FILE | |
- name: Update chart index | |
run: | | |
git stash # Stash changes to the values.yaml so checkout doesn't complain | |
git checkout gh-pages | |
helm repo index /tmp/chart --url https://prefecthq.github.io/prefect-operator/charts --merge ./index.yaml | |
- name: Commit and push | |
run: | | |
cp /tmp/chart/index.yaml . | |
cp /tmp/chart/prefect-operator-${RELEASE_VERSION}.* ./charts | |
git add ./index.yaml ./charts/prefect-operator-$RELEASE_VERSION.* ./charts/ | |
git commit -m "Release $RELEASE_VERSION" | |
git push origin gh-pages | |
- name: Create Github Release + Tag | |
run: | | |
gh release create $RELEASE_VERSION \ | |
--title $RELEASE_VERSION \ | |
--latest=false \ | |
--notes "Packaged with prefect-operator version \ | |
[v$IMAGE_VERSION](https://github.com/PrefectHQ/prefect-operator/releases/tag/v$IMAGE_VERSION)" | |
env: | |
GH_TOKEN: ${{ github.token }} | |
update_helm_chart_version_downstream: | |
name: Update Helm Chart version & image version in `cloud2-cluster-deployment` | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Run workflow | |
run: | | |
gh workflow run update-prefect-operator-versions.yaml \ | |
--repo prefecthq/cloud2-cluster-deployment \ | |
--ref main \ | |
-f image_version=${{ needs.release.outputs.operatorVersion }} \ | |
-f chart_version=${{ needs.release.outputs.releaseVersion }} \ | |
-f mode=release | |
env: | |
GH_TOKEN: ${{ secrets.CLOUD2_CLUSTER_DEPLOYMENT_ACTIONS_RW }} |