V2 Draft New Release #6
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: V2 Draft New Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version for new draft (e.g. v0.1.0)' | |
required: true | |
env: | |
GITHUB_USER: seldondev | |
KUSTOMIZE_VERSION: 4.5.5 | |
HELM_VERSION: v3.8.1 | |
jobs: | |
draft-release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Output Inputs | |
run: echo "${{ toJSON(github.event.inputs) }}" | |
- name: Checkout Git Commit | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Validate workflow inputs | |
shell: bash | |
run: | | |
set -e | |
RELEASE_BRANCH=${GITHUB_REF_NAME} | |
RELEASE_TAG="${{ github.event.inputs.version }}" | |
# Ensure that we do not run on master | |
if [ "${RELEASE_BRANCH}" == "master" ] || [ "${RELEASE_BRANCH}" == "v2" ]; then | |
echo "::error::Cannot run this workflow on master branch" | |
exit 1 | |
fi | |
# TODO: validate that RELEASE BRANCH is for the release line | |
# Release tag version must match v<major>.<minor>.<patch> and optional -rcX suffix | |
if ! echo "${RELEASE_TAG}" | egrep '^v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)*$'; then | |
echo "::error::Target version '${RELEASE_TAG}' is not valid release tag." >&2 | |
exit 1 | |
fi | |
# Ensure that release does not yet exist | |
if git rev-parse ${RELEASE_TAG}; then | |
echo "::error::Release tag ${RELEASE_TAG} already exists. Stopping draft process." | |
exit 1 | |
fi | |
# Save env variables for later steps | |
echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_ENV | |
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV | |
- name: Configure Git | |
run: | | |
git config --global user.name "${GITHUB_USER}" | |
git config --global user.email "${GITHUB_USER}@users.noreply.github.com" | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 14 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
cache: false | |
- name: Setup Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: "${{ env.HELM_VERSION }}" | |
- name: Setup Kustomize | |
run: | | |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- ${KUSTOMIZE_VERSION} | |
sudo mv kustomize /usr/local/bin/ | |
- name: Set versions in helm charts and yaml manifests | |
run: | | |
make NEW_VERSION=${RELEASE_TAG#v} set-versions | |
git add k8s/helm-charts && git commit -m "Setting version for helm charts" || echo "Nothing to commit" | |
git add k8s/yaml && git commit -m "Setting version for yaml manifests" || echo "Nothing to commit" | |
# - name: Prepare artifacts | |
# run: | | |
# make prep-artifacts | |
# - name: Upload artifacts | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: artifacts | |
# path: .release/ | |
- name: Install auto-changelog tool | |
run: | | |
npm install -g auto-changelog | |
- name: Check if release is for core version | |
run: | | |
if [[ ${RELEASE_TAG} == ${RELEASE_TAG%-*} ]]; then | |
echo "Core release" | |
echo "IS_RELEASE_CORE_VERSION=true" >> $GITHUB_ENV | |
else | |
echo "Non-core release" | |
echo "IS_RELEASE_CORE_VERSION=false" >> $GITHUB_ENV | |
fi | |
- name: Generate CHANGELOG.md | |
run: | | |
git commit -m "Generating changelog for ${RELEASE_TAG}" --allow-empty | |
if ${IS_RELEASE_CORE_VERSION}; then | |
auto-changelog --tag-pattern ^v\([0-9]\+\.\){2}[0-9]\+$ --starting-version v2.0.0 --ending-version ${RELEASE_TAG} -l 5 | |
else | |
git tag "${RELEASE_TAG}" --force && auto-changelog -l 5 --starting-version v2.0.0 --ending-version ${RELEASE_TAG} | |
fi | |
git add CHANGELOG.md && git commit --amend --no-edit || echo "Nothing to commit" | |
if ${IS_RELEASE_CORE_VERSION}; then | |
git commit -m "Update docs-gitbook code references for ${RELEASE_TAG}" --allow-empty | |
# Update GitBook URL tags pointing to source code | |
git tag "${RELEASE_TAG}" --force && make docs-gitbook-update-code-references | |
git add -A && git commit --amend --no-edit || echo "Nothing to commit" | |
# Revert GitBook URL tags to point back to the files in the v2 branch for commits | |
# after the release tag | |
git revert HEAD~1 --no-commit && git commit --amend -m "Restore docs-gitbook code references for updates after ${RELEASE_TAG}" || echo "Nothing to commit" | |
fi | |
- name: Generate release-notes.txt | |
run: | | |
if ${IS_RELEASE_CORE_VERSION}; then | |
auto-changelog --tag-pattern ^v\([0-9]\+\.\){2}[0-9]\+$ --starting-version ${RELEASE_TAG} --ending-version ${RELEASE_TAG} -l 5 -o release-notes.txt | |
else | |
auto-changelog -l 5 --starting-version ${RELEASE_TAG} --ending-version ${RELEASE_TAG} -o release-notes.txt | |
fi | |
# - name: Upload release notes | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: release-notes | |
# path: release-notes.txt | |
- name: Push new commits to repository | |
run: git push | |
# - name: Create or edit release draft | |
# run: | | |
# # TODO: Valdiate that there is no published released (we should not get here if tag exists anyway) | |
# gh release delete "${RELEASE_TAG}" --yes || echo "Draft does not yet exist" | |
# gh release create "${RELEASE_TAG}" --draft \ | |
# --title "${RELEASE_TAG}" \ | |
# --notes-file release-notes.txt \ | |
# --target "${RELEASE_BRANCH}" \ | |
# .release/* | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |