Skip to content

CI / Release

CI / Release #66

Workflow file for this run

name: Lint and publish puppetserver helm chart
on:
workflow_dispatch:
inputs:
helmRepoURL:
description: "URL for helm repo"
required: true
default: https://puppetlabs.github.io/puppetserver-helm-chart
githubRepo:
description: "username/repo for the github repo hosting the gh-pages branch"
required: true
default: puppetlabs/puppetserver-helm-chart
jobs:
lint-and-publish:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HELM_REPO_URL: ${{ github.event.inputs.helmRepoURL }}
GITHUB_REPO: ${{ github.event.inputs.githubRepo }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Fetch history
run: git fetch --prune --unshallow
- uses: azure/setup-helm@v3.4
- name: lint
run: |
helm lint .
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Set the version
run: |
echo "version=$(grep '^version:' Chart.yaml| awk '{print $2}')" >> $GITHUB_ENV
- name: Package the chart
run: |
helm package . --destination .release-packages --dependency-update
- name: Prep release notes
run: |
release_notes=`sed -n '/^## \['v${{ env.version }}'\]/,/^## /p' CHANGELOG.md | sed -n '/^- /p'`
echo "RELEASE NOTES: $release_notes"
echo "$release_notes" > body.md
release_name=`echo "$release_notes"| head -1 | sed 's/^- //'`
echo "release_name=$release_name" >> $GITHUB_ENV
- name: Make the release
id: create_release
uses: actions/create-release@v1
with:
tag_name: v${{ env.version }}
release_name: ${{ env.release_name }}
body_path: body.md
- name: upload artifacts to the release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./.release-packages/puppetserver-${{ env.version }}.tgz
asset_name: puppetserver-${{ env.version }}.tgz
asset_content_type: application/gzip
- name: update ghpages
run: |
gh_pages_worktree=$(mktemp -d)
git worktree add "$gh_pages_worktree" gh-pages
cp .release-packages/puppetserver-${{ env.version }}.tgz $gh_pages_worktree
cp CHANGELOG.md README.md LICENSE CODEOWNERS $gh_pages_worktree
find "$gh_pages_worktree" -type f ! -name "puppetserver-${{ env.version }}.tgz" -name 'puppetserver*.tgz' -delete
helm repo index $gh_pages_worktree --url $HELM_REPO_URL --merge "$gh_pages_worktree/index.yaml"
pushd "$gh_pages_worktree" > /dev/null
git add index.yaml puppetserver-${{ env.version }}.tgz
git commit --message "puppetserver-${{ env.version }} release"
git checkout 'puppetserver*.tgz' # reset the files removed to make the index accurate
git commit --all --message "Sync files from master branch" ||:
repo_url="https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPO"
git push "$repo_url" gh-pages
popd > /dev/null