Skip to content

Publish release

Publish release #1

Workflow file for this run

# 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.
# Publish Nessie release artifacts
# Triggered when a `nessie-*` tag is being pushed.
# Publishes the Maven, Python, Docker and Gradle-plugin artifacts.
# GitHub environment name:
# release
# Required secrets:
# OSSRH_ACCESS_ID
# OSSRH_TOKEN
# MAVEN_GPG_PASSPHRASE
# PYPI_API_TOKEN
# DOCKER_USERNAME
# DOCKER_TOKEN
name: Publish release
on:
push:
tags:
- nessie-*
workflow_dispatch:
inputs:
releaseTag:
description: 'Release tag name to re-release'
required: true
jobs:
publish-release:
name: Publish release
runs-on: ubuntu-22.04
if: github.repository_owner == 'projectnessie'
# Runs in the `release` environment, which has the necessary secrets and defines the reviewers.
# See https://docs.github.com/en/actions/reference/environments
environment: release
steps:
# GH doesn't provide just the tag name, so this step strips `/refs/tags/nessie-` from `GITHUB_REF`
# and provides the output `VERSION` or, in case of a manual run, uses the input `releaseTag` as
# the input tag name.
- name: Get release version
run: |
if [[ "${{ github.event_name }}" == "push" ]] ; then
V="${GITHUB_REF/refs\/tags\/}"
else
V="${{ github.event.inputs.releaseTag }}"
fi
# check if tag matches patterns like nessie-0.5, nessie-0.10.4.3-alpha1, etc
if [[ ${V} =~ ^nessie-[0-9]+[.][0-9.]*[0-9](-[a-zA-Z0-9]+)?$ ]]; then
echo "RELEASE_VERSION=${V/nessie-}" >> ${GITHUB_ENV}
echo "GIT_TAG=${V}" >> ${GITHUB_ENV}
else
echo "Tag must start with nessie- followed by a valid version (got tag ${V}, ref is ${GITHUB_REF} )"
exit 1
fi
### BEGIN runner setup
- name: Checkout
uses: actions/[email protected]
if: ${{ github.event_name == 'push' }}
with:
fetch-depth: '0'
- name: Checkout
uses: actions/[email protected]
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
fetch-depth: '0'
ref: refs/tags/${{ github.event.inputs.releaseTag }}
- name: Setup Python
uses: ./.github/actions/dev-tool-python
with:
python-version: '3.8'
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements_dev.txt
### END runner setup
# Deploys pynessie. Build and test steps were already ran in previous steps
- name: Build pynessie for release
run: python setup.py sdist bdist_wheel
- name: Publish pynessie package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: ./dist/
- name: pynessie info
run: echo "## Successfully published pynessie ${RELEASE_VERSION}" >> $GITHUB_STEP_SUMMARY
# Prepare Nessie release notes for GitHub
#
# The markdown file for the release is generated using some mostly simple shell script.
#
# `LAST_TAG` is evaluated using `git describe`, which is the name of the git tag before the release tag
# `NUM_COMMITS` is the total number of commits "between" LAST_TAG and GIT_TAG
#
# "Full Changelog" is the output of a `git log` considering the commits "between" LAST_TAG and
# GIT_TAG, removing the commits by `renovate` and `nessie-release-workflow`.
# Also removes commits that start with `[release] `.
#
# The final markdown is just a `cat` of the above information including some basic markdown formatting.
#
- name: Prepare Nessie release for GitHub
run: |
DIR=$(mktemp -d)
NOTES_FILE=${DIR}/release-notes.md
LAST_TAG=$(git describe --abbrev=0 --tags --match=nessie-* ${GIT_TAG}^1)
NUM_COMMITS=$(git log --format='format:%h' ${LAST_TAG}..HEAD^1 | wc -l)
git log --perl-regexp --author '^(?!.*renovate|.*nessie-release-workflow).*$' --format='format:* %s' ${LAST_TAG}..${GIT_TAG} | grep -v '^\* \[release\] .*$' > ${DIR}/release-log
cat <<EOF > ${NOTES_FILE}
# Nessie ${RELEASE_VERSION} release
* ${NUM_COMMITS} commits since ${LAST_TAG#nessie-}
* PyPI: https://pypi.org/project/pynessie/${RELEASE_VERSION}/
## Full Changelog (minus renovate commits):
$(cat ${DIR}/release-log)
EOF
echo "NOTES_FILE=${NOTES_FILE}" >> ${GITHUB_ENV}
cat "${NOTES_FILE}" >> $GITHUB_STEP_SUMMARY
- name: Create Nessie release in GitHub
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
gh release create ${GIT_TAG} \
--notes-file ${{ env.NOTES_FILE }} \
--title "pynessie ${RELEASE_VERSION}"