Skip to content

Chart Release

Chart Release #20

name: Chart Release
on:
workflow_dispatch:
inputs:
plane-ce:
description: 'Build Plane CE'
type: boolean
default: false
plane-ee:
description: 'Build Plane EE'
type: boolean
default: false
env:
CR_CONFIGFILE: "${{ github.workspace }}/cr.yaml"
CR_TOOL_PATH: "${{ github.workspace }}/.cr-tool"
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GNUPGHOME: ${{ github.workspace }}/.gnupg
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
TARGET_BRANCH: "${{ github.ref_name }}"
CHART_NAME_CE: "plane-ce"
CHART_NAME_ENTERPRISE: "plane-enterprise"
MARK_AS_LATEST: true
MARK_AS_PRERELASE: false
PAGES_INDEX_PATH: ""
jobs:
setup:
if: ${{ github.event.inputs.plane-ce == 'true' || github.event.inputs.plane-ee == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v4
- name: Prepare GPG key #this step is for using exported keys and make your github runner
env:
CR_PASSPHRASE_FILE: ${{env.GNUPGHOME}}/gpg-passphrase
run: |
gpg --version
mkdir -p ${{env.GNUPGHOME}}
chmod 700 ${{env.GNUPGHOME}}
# Disable the use of the gpg-agent
echo "use-agent" >> ${{env.GNUPGHOME}}/gpg.conf
echo "pinentry-mode loopback" >> ${{env.GNUPGHOME}}/gpg.conf
echo "no-tty" >> ${{env.GNUPGHOME}}/gpg.conf
echo "no-autostart" >> ${{env.GNUPGHOME}}/gpg-agent.conf
echo "allow-loopback-pinentry" >> ${{env.GNUPGHOME}}/gpg-agent.conf
echo "${{env.GPG_PASSPHRASE}}" > ${{env.CR_PASSPHRASE_FILE}}
# Import the GPG key
echo "${{ env.GPG_PRIVATE_KEY }}" | gpg --batch --yes --pinentry-mode loopback --passphrase ${{ env.GPG_PASSPHRASE }} --import
# Re-create keyring in legacy format for Helm compatibility
gpg --export-secret-keys --passphrase ${{env.GPG_PASSPHRASE}} > ${{env.GNUPGHOME}}/secring.gpg
gpg --export --passphrase ${{env.GPG_PASSPHRASE}} > ${{env.GNUPGHOME}}/pubring.gpg
chmod 400 ${{env.GNUPGHOME}}/secring.gpg
- name: Remove unwanted charts
run: |
if [ "${{ github.event.inputs.plane-ce }}" = "false" ]; then
rm -rf charts/${{ env.CHART_NAME_CE }}
fi
if [ "${{ github.event.inputs.plane-ee }}" = "false" ]; then
rm -rf charts/${{ env.CHART_NAME_ENTERPRISE }}
fi
- name: Rename Chart
if: github.ref_name != 'master'
run: |
flatBranchName=$(echo "${{ env.TARGET_BRANCH }}" | sed 's/\//\-/g')
if [ "${{ github.event.inputs.plane-ce }}" = "true" ]; then
sed -i "s/name: \(.*\)/name: \1-${flatBranchName}/" charts/${{ env.CHART_NAME_CE }}/Chart.yaml
fi
if [ "${{ github.event.inputs.plane-ee }}" = "true" ]; then
sed -i "s/name: \(.*\)/name: \1-${flatBranchName}/" charts/${{ env.CHART_NAME_ENTERPRISE }}/Chart.yaml
fi
echo "MARK_AS_LATEST=false" >> $GITHUB_ENV
echo "MARK_AS_PRERELASE=true" >> $GITHUB_ENV
echo "PAGES_INDEX_PATH=${flatBranchName}" >> $GITHUB_ENV
- name: Release Charts
uses: mguptahub/chart-releaser-action@v1.6.2
with:
charts_dir: charts
config: cr.yaml
packages_with_index: false
skip_existing: true
mark_as_latest: ${{ env.MARK_AS_LATEST }}
prerelease: ${{ env.MARK_AS_PRERELASE }}
pages_index_path: ${{ env.PAGES_INDEX_PATH }}
env:
CR_TOKEN: ${{ env.CR_TOKEN }}
CR_KEY: ${{ env.GPG_KEY_NAME }}
CR_KEYRING: ${{env.GNUPGHOME}}/secring.gpg
CR_PASSPHRASE_FILE: ${{env.GNUPGHOME}}/gpg-passphrase
CR_SIGN: true
- id: publish-plane-enterprise
if: ${{ github.ref_name == 'master' && github.event.inputs.plane-ee == 'true' }}
name: Harbor Publish Plane-Enterprise
env:
CHART_REPO: ${{ env.CHART_NAME_ENTERPRISE }}
HELM_REPO: plane
CR_KEY: ${{ env.GPG_KEY_NAME }}
CR_PASSPHRASE_FILE: ${{env.GNUPGHOME}}/gpg-passphrase
CR_KEYRING: ${{env.GNUPGHOME}}/secring.gpg
run: |
mkdir -p tmp
helm registry login -u ${{ secrets.HARBOR_USERNAME }} -p ${{ secrets.HARBOR_TOKEN }} ${{ vars.HARBOR_REGISTRY }}
helm package --sign --key "$CR_KEY" --keyring "$CR_KEYRING" --passphrase-file "$CR_PASSPHRASE_FILE" charts/$CHART_REPO -u -d tmp
helm push tmp/${{ env.CHART_REPO }}-*.tgz oci://${{ vars.HARBOR_REGISTRY }}/${{env.HELM_REPO}}
rm -rf tmp
publish:
if: ${{ github.ref_name == 'master' }}
needs: setup
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
path: code
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: gh-pages
path: pages
- name: Configure Git
working-directory: pages
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Copy Readme
run: |
if [ "${{ github.event.inputs.plane-ce }}" = "true" ]; then
cp code/charts/plane-ce/README.md pages/content/plane-ce.md
fi
if [ "${{ github.event.inputs.plane-ee }}" = "true" ]; then
cp code/charts/plane-enterprise/README.md pages/content/plane-ee.md
fi
- name: Publish pages
working-directory: pages
run: |
git add .
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
# Commit and push the changes
git commit -m "Updated READMEs"
git push
fi