-
Notifications
You must be signed in to change notification settings - Fork 7
192 lines (156 loc) · 7.18 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
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