[bump-version.sh] Bumped version in toml to '2.27.0.dev20240710135754' #40
Workflow file for this run
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: pipeline_on_tag | |
on: | |
push: | |
tags: | |
# Semver (with optional dev extension (-dev) | |
# - 'v[0-9]+\.[0-9]+\.[0-9]+(?:-.*)?' | |
- 'v*' | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
# Checkout code | |
- name: Checkout code | |
id: git_checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Get the tag based on the GITHUB REF env var | |
- id: get_tag | |
run: | | |
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
# Check pre release regex match | |
- id: tag_regex_match_dev | |
uses: kaisugi/[email protected] | |
with: | |
text: ${{ steps.get_tag.outputs.tag }} | |
regex: '^v[0-9]+\.[0-9]+\.[0-9]+(\.dev[0-9]+)?$' | |
# Check pre release regex match | |
- id: tag_regex_match_prod | |
uses: kaisugi/[email protected] | |
with: | |
text: ${{ steps.get_tag.outputs.tag }} | |
regex: '^v[0-9]+\.[0-9]+\.[0-9]+(\.post[0-9]+)?$' | |
# Check tag regex match | |
- id: check_match | |
if: steps.check_tag.outputs.match == 'false' | |
run: | | |
echo "Tag not semver tag" 1>&2 | |
exit 1 | |
- id: verify_versions | |
run: | | |
# Install toml | |
pip install toml | |
pyproject_version="$( \ | |
python <<END | |
import toml | |
with open("pyproject.toml", "r") as f_h: | |
data = toml.load(f_h) | |
print("v"+data.get("project").get("version")) | |
END | |
)" | |
# TODO - consider -dev extension on toml and we override it? | |
# OR we create our own extension? | |
if [[ "${pyproject_version}" != "${{ steps.get_tag.outputs.tag }}" ]]; then | |
echo "version in pyproject.toml and tag do not match! Exiting" 2>&1 | |
exit 1 | |
fi | |
# Check tag is a valid tag and matched either dev or production groups | |
- id: is_valid_regex_match | |
run: | | |
if [[ "${{ steps.tag_regex_match_dev.outputs.match }}" == "" && "${{ steps.tag_regex_match_prod.outputs.match }}" == "" ]]; then | |
echo "Error! Tag regex did not match either development nor production regexes" 2>&1 | |
exit 1 | |
fi | |
# Is Pre Release | |
- id: is_pre_release | |
run: | | |
is_pre_release="false" | |
if [[ -n "${{ steps.tag_regex_match_dev.outputs.group1 }}" ]]; then | |
is_pre_release="true" | |
fi | |
echo "is_pre_release=${is_pre_release}" >> "${GITHUB_OUTPUT}" | |
# PyPi Outputs | |
- id: get_repository_and_index_url | |
run: | | |
pypi_repository="pypi" | |
pypi_repository_url="https://upload.pypi.org/legacy/" | |
index_url="https://pypi.org/simple/" | |
if [[ "${{ steps.is_pre_release.outputs.is_pre_release }}" == "true" ]]; then | |
pypi_repository="testpypi" | |
pypi_repository_url="https://test.pypi.org/legacy/" | |
index_url="https://test.pypi.org/simple/" | |
fi | |
echo "pypi_repository=${pypi_repository}" >> "${GITHUB_OUTPUT}" | |
echo "pypi_repository_url=${pypi_repository_url}" >> "${GITHUB_OUTPUT}" | |
echo "index_url=${index_url}" >> "${GITHUB_OUTPUT}" | |
# Get environment type | |
- id: get_environment | |
run: | | |
environment="development" | |
if [[ "${{ steps.is_pre_release.outputs.is_pre_release }}" == "false" ]]; then | |
environment="production" | |
fi | |
echo "environment=${environment}" >> "${GITHUB_OUTPUT}" | |
# Validate that if is_pre_release is false that the branch name startswith 'bump' | |
- id: get_branch_name | |
run: | | |
# Get branch name | |
raw="$( \ | |
git branch --remotes --contains "${{ github.ref }}" \ | |
)" | |
raw="${raw// /}" | |
echo "branch_name=${raw/origin\/}" >> "${GITHUB_OUTPUT}" | |
# Validate bump | |
- id: validate_branch | |
run: | | |
if [[ ! "${{ steps.get_branch_name.outputs.branch_name }}" =~ ^bump/.* && "${{ steps.is_pre_release.outputs.is_pre_release }}" == "false" ]]; then | |
echo "Error, production pushes must come from a 'bump' branch!" 2>&1 | |
exit 1 | |
fi | |
# Validate bump branch tag | |
- id: validate_bump_branch_tag | |
run: | | |
if [[ "${{ steps.get_branch_name.outputs.branch_name }}" =~ ^bump/.* && "${{ steps.is_pre_release.outputs.is_pre_release }}" == "false" ]]; then | |
# Running production env with bump branch | |
branch_name_without_bump="${branch_name#bump/}"; | |
if [[ ! "${branch_name_without_bump}" == "${get_tag}" ]]; then | |
echo "Error, bump branch name was not the same as tag name got '${branch_name_without_bump}' and '${get_tag}'" 2>&1 | |
exit 1 | |
fi | |
fi | |
# Set outputs of setup job | |
outputs: | |
git_tag: ${{ steps.get_tag.outputs.tag }} | |
is_pre_release: ${{ steps.is_pre_release.outputs.is_pre_release }} | |
pypi_repository: ${{ steps.get_repository_and_index_url.outputs.pypi_repository }} | |
pypi_repository_url: ${{ steps.get_repository_and_index_url.outputs.pypi_repository_url }} | |
index_url: ${{ steps.get_repository_and_index_url.outputs.index_url }} | |
environment: ${{ steps.get_environment.outputs.environment }} | |
branch_name: ${{ steps.get_branch_name.outputs.branch_name }} | |
# Run tests and generate report | |
# test: | |
# needs: | |
# - setup | |
# runs-on: ubuntu-latest | |
# defaults: | |
# run: | |
# shell: bash -l {0} | |
# steps: | |
# - id: git_checkout | |
# uses: actions/checkout@v4 | |
# - id: setup_python | |
# uses: actions/setup-python@v5 | |
# with: | |
# python-version: '3.10' | |
# - id: run_make_test | |
# run: | | |
# make test | |
# - uses: actions/upload-artifact@v4 | |
# with: | |
# name: coverage_report | |
# path: coverage_report.txt | |
# Commit docs | |
commit_docs_requirement_file: | |
needs: | |
- setup | |
uses: ./.github/workflows/build_docs_requirements_file.yml | |
with: | |
branch: ${{ needs.setup.outputs.branch_name }} | |
# Build package | |
build_package_wheels: | |
needs: | |
- setup | |
- commit_docs_requirement_file | |
# - test | |
uses: ./.github/workflows/build_package.yml | |
# Build package and make release on GitHub | |
build_release: | |
needs: | |
- setup | |
- commit_docs_requirement_file | |
# - test | |
- build_package_wheels | |
uses: ./.github/workflows/build_release.yml | |
with: | |
git_tag: ${{ needs.setup.outputs.git_tag }} | |
# coverage_report_artifacts_name: coverage_report | |
# coverage_report_artifacts_path: coverage_report.txt | |
dist_artifacts_name: dist | |
dist_artifacts_path: dist | |
# Now publish on pypi (or test-pypi if this is a dev release) | |
# This only occurs after release on GitHub | |
publish_pypi: | |
needs: | |
- setup | |
- commit_docs_requirement_file | |
# - test | |
- build_package_wheels | |
- build_release | |
uses: ./.github/workflows/publish_pypi.yml | |
with: | |
git_tag: ${{ needs.setup.outputs.git_tag }} | |
is_pre_release: ${{ needs.setup.outputs.is_pre_release }} | |
pypi_repository: ${{ needs.setup.outputs.pypi_repository }} | |
pypi_repository_url: ${{ needs.setup.outputs.pypi_repository_url }} | |
dist_artifacts_name: dist | |
dist_artifacts_path: dist | |
environment: ${{ needs.setup.outputs.environment }} | |
# Now generate a PR | |
make_pull_request: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
needs: | |
- setup | |
- commit_docs_requirement_file | |
# - test | |
- build_package_wheels | |
- build_release | |
- publish_pypi | |
if: ${{ needs.setup.outputs.is_pre_release == 'false' }} | |
steps: | |
# Complete git checkout | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ needs.setup.outputs.branch_name }} | |
# Make a pull request | |
- name: Create Pull Request | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh pr create \ | |
--base "main" \ | |
--title "Bump production version to ${{ needs.setup.outputs.git_tag }}" \ | |
--body "Updated pyproject.toml to use ${{ needs.setup.outputs.git_tag }}" |