Skip to content

Create Release

Create Release #160

# Copyright (C) 2020 Dremio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Projectnessie GitHub Release workflow
# Creates a release tag for the current in-tree version from the main or another branch.
# This workflow creates the git commits + git tag for a Nessie release.
# When this workflow pushes the release tag (e.g. `nessie-0.5.1`), the `release-publish.yml`
# workflow publishes the release artifacts.
# Projectnessie really prefers a linear git history - aka no merges. PRs must not be merged
# while the release workflow runs. In case the git history would not be linear, this workflow will
# fail without having uploaded/pushed any release artifacts.
# Secrets:
# NESSIE_BUILDER GH access-token to push the release-commits+tag to the branch,
# bypassing the required commit-hooks + review.
name: Create Release
on:
# Manually triggered
workflow_dispatch:
inputs:
releaseFromBranch:
description: 'The branch name the release from, leave empty to release from latest commit on main.'
required: false
bumpType:
description: 'Optional: bump patch, minor or major version (`patch`, `minor`, `major`). Default is `minor`.'
required: true
type: string
default: "minor"
jobs:
create-release:
name: Create release
runs-on: ubuntu-22.04
timeout-minutes: 60
if: github.repository == 'projectnessie/nessie'
env:
RELEASE_FROM: ${{ github.event.inputs.releaseFromBranch }}
BUMP_TYPE: ${{ github.event.inputs.bumpType }}
steps:
### BEGIN runner setup
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ env.RELEASE_FROM }}
fetch-depth: '0'
- name: Setup Java, Gradle
uses: ./.github/actions/dev-tool-java
- name: Setup Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5
### END runner setup
- name: Configure release-bot-user in git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "Nessie Release Workflow [bot]"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3
with:
cache-disabled: true
- name: Bump to release version
run: ./gradlew :bumpVersion --bumpType ${{ env.BUMP_TYPE }} --bumpToRelease
- name: Get release version
run: |
RELEASE_VERSION=$(cat version.txt)
LAST_TAG=$(git describe --abbrev=0 --tags --match=nessie-*)
echo "LAST_TAG=${LAST_TAG}" >> ${GITHUB_ENV}
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> ${GITHUB_ENV}
echo "GIT_TAG=nessie-${RELEASE_VERSION}" >> ${GITHUB_ENV}
cat <<! >> $GITHUB_STEP_SUMMARY
## About to release
Version information right before the Git release tag and commit:
| Name | Value |
| --- | --- |
| Nessie release version | ${RELEASE_VERSION} |
| Git tag name | \`nessie-${RELEASE_VERSION}\` |
| Previous Git tag | \`${LAST_TAG}\` |
| Release from branch | ${RELEASE_FROM} |
| Bump type | ${BUMP_TYPE} |
| Before release Git HEAD | \`$(git rev-parse HEAD)\` |
!
- name: Update .md files referencing latest Nessie version
run: |
LAST_VERSION="${LAST_TAG#nessie-}"
LAST_VERSION_PATTERN="$(echo ${LAST_VERSION} | sed 's/\([^.]*\)[.]\([^.]*\)[.].*/\1\\.\2/')\\."
for fn in SECURITY.md README.md site/docs/server-upgrade.md ; do
sed -i "s/${LAST_VERSION_PATTERN}[^ ]*/${RELEASE_VERSION}/" ${fn}
done
# Two steps that verify that the README.md, SECURITY.md and server-upgrade.md files contain
# information about the release, ignoring the patch version
- name: Check release version number in text files
run: |
FAILS=""
# version pattern without patch version
VERSION_PATTERN="$(echo ${RELEASE_VERSION} | sed 's/\([^.]*\)[.]\([^.]*\)[.].*/\1\\.\2/')\\."
grep -q " ${VERSION_PATTERN}" < site/docs/server-upgrade.md || FAILS="${FAILS} site/docs/server-upgrade.md"
grep -q "^| ${VERSION_PATTERN}" < README.md || FAILS="${FAILS} README.md"
grep -q "^| ${VERSION_PATTERN}.* .*check_mark.*$" < SECURITY.md || FAILS="${FAILS} SECURITY.md"
if [[ -n ${FAILS} ]] ; then
echo ${FAILS} "do not match the version pattern ${VERSION_PATTERN}."
exit 1
fi
- name: Patch changelog
run: ./gradlew :patchChangelog
- name: Update site
shell: bash
working-directory: site
run: |
bin/release.sh ${RELEASE_VERSION}
- name: Bump version in helm/nessie
shell: bash
run: |
sed -i "s/^version: [0-9.]*$/version: ${RELEASE_VERSION}/" helm/nessie/Chart.yaml
# Updates the site/docs/releases.md file, takes the first four lines (the big heading),
# adds a heading with the version and a note referencing the release notes on GitHub,
# followed by the Git change log, finalized with the remainder of the
# previous site/docs/releases.md file.
- name: Update releases.md file
run: |
head -4 site/docs/releases.md > /tmp/releases.md
cat <<! >> /tmp/releases.md
## ${RELEASE_VERSION} Release ($(date '+%B %d, %Y'))
See [Release information on GitHub](https://github.com/projectnessie/nessie/releases/tag/nessie-${RELEASE_VERSION}).
!
# Add section from CHANGELOG.md for the version to release
./gradlew --quiet --console=plain getChangelog --no-header --no-links >> /tmp/releases.md
echo "### Commits" >> /tmp/releases.md
git log --perl-regexp --author '^(?!.*renovate|.*nessie-release-workflow).*$'\
--format='format:* %s' ${LAST_TAG}..HEAD . |\
grep -v '^\* \[release\] .*$' >> /tmp/releases.md || true
tail +4 site/docs/releases.md >> /tmp/releases.md
cp /tmp/releases.md site/docs/releases.md
rm /tmp/releases.md
- name: Update helm/README.md
run: |
go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
$(go env GOPATH)/bin/helm-docs --chart-search-root=helm
# Record the release-version in git and add the git tag for the release.
- name: Record ${{ env.RELEASE_VERSION }} release in git
run: |
git commit -a -m "[release] release nessie-${RELEASE_VERSION}"
git tag -f -a -m "Release ${RELEASE_VERSION} from ${RELEASE_FROM} with bump-type ${BUMP_TYPE}" ${GIT_TAG}
cat <<! >> $GITHUB_STEP_SUMMARY
## Release version information
Version information after the Git release tag:
| Name | Value |
| --- | --- |
| Nessie release version | ${RELEASE_VERSION} |
| Git tag name | \`${GIT_TAG}\`\ |
| Previous Git tag | \`${LAST_TAG}\` |
| Release from branch | ${RELEASE_FROM} |
| Bump type | ${BUMP_TYPE} |
| Release Git HEAD | \`$(git rev-parse HEAD)\` |
!
# Bump to the next patch version as a SNAPSHOT
- name: Bump to next patch version
run: ./gradlew :bumpVersion --bumpType patch
- name: Get next patch version
run: |
NEXT_VERSION="$(cat version.txt)"
echo "NEXT_VERSION=${NEXT_VERSION}" >> ${GITHUB_ENV}
echo "NEXT_VERSION_NO_SNAPSHOT=${NEXT_VERSION%-SNAPSHOT}" >> ${GITHUB_ENV}
- name: Next version information
run: |
cat <<! >> $GITHUB_STEP_SUMMARY
## Next development version information
| Name | Value |
| --- | --- |
| Nessie development version | ${NEXT_VERSION} |
| \`version.txt\` content | \`$(cat version.txt)\` |
| Git HEAD | \`$(git rev-parse HEAD)\` |
!
# Record the next development iteration in Git
- name: Record next development version in Git
run: git commit -a -m "[release] next development iteration ${NEXT_VERSION}"
# Push the 2 git commits and git tag. If this one fails, some other commit was pushed to the
# 'main' branch and break the linear history for the Nessie git repo.
# The `release-publish.yml` job will run when the release tag `nessie-x.y.z` has been pushed.
- name: Push tag + branch
run: |
# Push directly using the remote repo URL, which includes the secret so this job can push to the repo
UPSTREAM="https://${{ secrets.NESSIE_BUILDER }}@github.com/${GITHUB_REPOSITORY}.git"
# Move the default auth settings in ~/.gitconfig out of the way, so the git-push can use the token
git config --rename-section http.https://github.com/ http.https://save.github.com/
# Push changes to docs to site-docs branch
(cd site/build/site-docs ; git push --no-verify "${UPSTREAM}" HEAD:site-docs)
git push --no-verify "${UPSTREAM}" HEAD:${GITHUB_REF} ${GIT_TAG}
# Move the default auth settings in ~/.gitconfig back
git config --rename-section http.https://save.github.com/ http.https://github.com/