Skip to content

Create Release

Create Release #5

Workflow file for this run

name: Create Release
on:
workflow_dispatch:
inputs:
version:
description: The version to create (semantic versioning, passed to hatch version)
required: true
jobs:
release_new_version:
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
lfs: true
- name: fetch tags
run: |
git fetch --prune --tags --prune-tags --force
echo exit code $?
git tag --list
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: bump version without commit or tag and build
id: build
run: |
rm -r dist || true
pip install hatch
echo "KAZU_OLD_VERSION=$(hatch version)" >> $GITHUB_ENV
hatch version $KAZU_NEW_VERSION_SEGMENT
echo "KAZU_NEW_VERSION=$(hatch version)" >> $GITHUB_ENV
# if hatch build is not working, try removing ~/.config/hatch and ~/.local/share/hatch
hatch build
PIP_CACHE_DIR=$(pip cache dir)
echo "pip cache dir is "${PIP_CACHE_DIR}
echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}" >> $GITHUB_ENV
env:
KAZU_NEW_VERSION_SEGMENT: ${{ inputs.version }}
- name: create venv and install wheel
run: |
PIP_CACHE_DIR=$(echo "${{ env.PIP_CACHE_DIR }}")
echo "pip cache dir is "${PIP_CACHE_DIR}
python -m venv kazu-env
. kazu-env/bin/activate
python -m pip install --upgrade pip
WHEEL_PATH=$(echo $GITHUB_WORKSPACE/dist/*whl)
pip install --upgrade --upgrade-strategy eager --index-url https://download.pytorch.org/whl/cpu "torch>=2.0.0"
pip install "${WHEEL_PATH}[dev]" --cache-dir $PIP_CACHE_DIR --upgrade --upgrade-strategy eager
- name: Check precommit
run: |
. kazu-env/bin/activate
pre-commit run --all-files
- name: Build model pack caches and test (with acceptance tests)
id: model_pack_cache_build_and_test
run: |
export BASE_KAZU_CONF_PATH=$GITHUB_WORKSPACE"/kazu/conf"
# random suffix to prevent clashes with other runs
export MODEL_PACK_BUILD_PATH=$GITHUB_WORKSPACE"/temp_model_pack_test_dir_"$RANDOM
export KAZU_MODEL_PACK_BUILD_RESOURCES_PATH=$GITHUB_WORKSPACE"/resources/"
mkdir $MODEL_PACK_BUILD_PATH
. kazu-env/bin/activate
KAZU_LOGGING_CONF=$GITHUB_WORKSPACE"/kazu/utils/model_pack_build_logging.conf"
python -m kazu.utils.build_and_test_model_packs \
--base_configuration_path $BASE_KAZU_CONF_PATH \
--model_packs_to_build kazu_model_pack_public \
--zip_model_pack \
--logging_config_path $KAZU_LOGGING_CONF \
--model_pack_output_path $MODEL_PACK_BUILD_PATH \
--skip_tests \
--debug
export KAZU_MODEL_PACK=$(echo $MODEL_PACK_BUILD_PATH/kazu_model_pack_public)
# we now skip the acceptance tests above and run in a separate process here
# since we previously had memory issues on the GitHub runners when trying to
# do it all in the same process.
python $GITHUB_WORKSPACE/.github/workflows/run_acceptance_tests.py
# skip server tests on runner due to low shared memory.
export SKIP_KAZU_SERVER_TESTS=1
# skip experimental modules
export SKIP_KAZU_EXPERIMENTAL_TESTS=1
cd /tmp
# separate out hypothesis and non-hypothesis tests
# because the hypothesis cache causes memory to grow significantly and
# cause the run to fail.
pytest -m "not hypothesis" $GITHUB_WORKSPACE/kazu/tests
pytest -m "hypothesis" $GITHUB_WORKSPACE/kazu/tests
NEW_MODEL_PACK_ZIP=$(echo $MODEL_PACK_BUILD_PATH/*.zip)
echo "NEW_MODEL_PACK_ZIP=${NEW_MODEL_PACK_ZIP}" >> $GITHUB_ENV
env:
LS_TOKEN: ${{ secrets.LS_TOKEN }}
LS_URL_PORT: ${{ secrets.LS_URL_PORT }}
- name: Build changelogs
run: |
. kazu-env/bin/activate
# reset to make sure only the outputs of the next steps are committed
cd $GITHUB_WORKSPACE
GITHUB_BOT="[email protected]"
git config --global user.name 'Kazu Version Bump'
git config --global user.email $GITHUB_BOT
git reset --hard
# first, generate release notes for just this release, to pass
# to the gh release command further down
current_release_file="/tmp/${KAZU_NEW_VERSION}-notes.md"
echo "CURRENT_RELEASE_FILE=$current_release_file" >> $GITHUB_ENV
python -m towncrier build --draft --version=${KAZU_NEW_VERSION} > $current_release_file
python -m towncrier build --yes --version=${KAZU_NEW_VERSION}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bump version with commit and tag, commit, and push
run: |
cd $GITHUB_WORKSPACE
hatch version $KAZU_NEW_VERSION_SEGMENT
BUMP_MESSAGE="Bump version: ${KAZU_OLD_VERSION} → ${KAZU_NEW_VERSION}"
git add -u
git commit -m "${BUMP_MESSAGE}"
KAZU_RELEASE_VERSION=v${KAZU_NEW_VERSION}
echo "KAZU_RELEASE_VERSION=${KAZU_RELEASE_VERSION}" >> $GITHUB_ENV
git tag -a $KAZU_RELEASE_VERSION -m "${BUMP_MESSAGE}"
git checkout -b releases/$KAZU_RELEASE_VERSION
rm -r dist || true
. kazu-env/bin/activate
hatch build --clean
git push -u origin --follow-tags releases/$KAZU_RELEASE_VERSION
PR_MERGING_WARNING="Make sure to merge using 'create a merge commit' or the tag for the release will no longer point to a commit on main"
PR_ID=$(gh pr create -b main --title "version bump ${KAZU_NEW_VERSION_SEGMENT}: ${KAZU_OLD_VERSION} -> ${KAZU_RELEASE_VERSION}" --body "${PR_MERGING_WARNING}")
# todo: auto merge when we have a solution for this
# gh pr merge $PR_ID --admin --rebase
NEW_MODEL_PACK_ZIP=$(echo "${{ env.NEW_MODEL_PACK_ZIP }}")
gh release create $KAZU_RELEASE_VERSION --notes-file $CURRENT_RELEASE_FILE --title $KAZU_RELEASE_VERSION
gh release upload $KAZU_RELEASE_VERSION dist/* --clobber
gh release upload $KAZU_RELEASE_VERSION $NEW_MODEL_PACK_ZIP --clobber
rm -r $NEW_MODEL_PACK_ZIP
env:
KAZU_NEW_VERSION_SEGMENT: ${{ inputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push artifacts
run: |
. kazu-env/bin/activate
hatch publish -r main
env:
HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }}
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}
- name: remove temp resources
run: |
# need to call twice, for NFS bug
MODEL_PACK_BUILD_PATH=$(echo "${{ env.MODEL_PACK_BUILD_PATH }}")
rm -r $MODEL_PACK_BUILD_PATH || true
rm -r $MODEL_PACK_BUILD_PATH || true