Skip to content

Commit ae06ad0

Browse files
authored
Fixes versioning for pre-release provider packages (#11586)
When we prepare pre-release versions, they are not intended to be converted to final release versions, so there is no need to replace version number for them artificially, For release candidates on the other hand, we should internally use the "final" version because those packages might be simply renamed to the final "production" versions. Fixes #11585
1 parent 91898e8 commit ae06ad0

File tree

5 files changed

+124
-36
lines changed

5 files changed

+124
-36
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ jobs:
281281
INSTALL_AIRFLOW_VERSION: "1.10.12"
282282
PYTHON_MAJOR_MINOR_VERSION: ${{needs.build-info.outputs.defaultPythonVersion}}
283283
BACKPORT_PACKAGES: "true"
284+
VERSION_SUFFIX_FOR_SVN: "rc1"
284285
if: github.repository == 'apache/airflow' || github.event_name != 'schedule'
285286
steps:
286287
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
@@ -316,6 +317,8 @@ jobs:
316317
env:
317318
INSTALL_AIRFLOW_VERSION: "2.0.0-dev" # Note that this causes local installation
318319
PYTHON_MAJOR_MINOR_VERSION: ${{needs.build-info.outputs.defaultPythonVersion}}
320+
VERSION_SUFFIX_FOR_PYPI: "a0"
321+
VERSION_SUFFIX_FOR_SVN: "a0"
319322
if: github.repository == 'apache/airflow' || github.event_name != 'schedule'
320323
steps:
321324
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"

BREEZE.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,14 +1945,17 @@ This is the current syntax for `./breeze <./breeze>`_:
19451945
Prepares backport packages. You can provide (after --) optional list of packages to prepare.
19461946
If no packages are specified, readme for all packages are generated. You can specify optional
19471947
--version-suffix-for-svn flag to generate rc candidate packages to upload to SVN or
1948-
--version-suffix-for-pypi flag to generate rc candidates for PyPI packages.
1948+
--version-suffix-for-pypi flag to generate rc candidates for PyPI packages. You can also
1949+
provide both suffixes in case you prepare alpha/beta versions.
19491950
19501951
Examples:
19511952
19521953
'breeze prepare-provider-packages' or
19531954
'breeze prepare-provider-packages google' or
19541955
'breeze prepare-provider-packages --version-suffix-for-svn rc1 http google amazon' or
19551956
'breeze prepare-provider-packages --version-suffix-for-pypi rc1 http google amazon'
1957+
'breeze prepare-provider-packages --version-suffix-for-pypi a1
1958+
--version-suffix-for-svn a1 http google amazon'
19561959
19571960
General form:
19581961

breeze

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,24 +1099,12 @@ function breeze::parse_arguments() {
10991099
shift 2
11001100
;;
11011101
-S | --version-suffix-for-pypi)
1102-
if [[ -n ${VERSION_SUFFIX_FOR_SVN=} ]]; then
1103-
echo
1104-
echo "You can only set one version suffix - either for PyPI or for SVN"
1105-
echo
1106-
exit 1
1107-
fi
11081102
export VERSION_SUFFIX_FOR_PYPI="${2}"
11091103
echo "Version suffix for PyPI ${VERSION_SUFFIX_FOR_PYPI}"
11101104
echo
11111105
shift 2
11121106
;;
11131107
-N | --version-suffix-for-svn)
1114-
if [[ -n ${VERSION_SUFFIX_FOR_PYPI=} ]]; then
1115-
echo
1116-
echo "You can only set one version suffix - either for PyPI or for SVN"
1117-
echo
1118-
exit 1
1119-
fi
11201108
export VERSION_SUFFIX_FOR_SVN="${2}"
11211109
echo "Version suffix for SVN ${VERSION_SUFFIX_FOR_SVN}"
11221110
echo
@@ -1725,14 +1713,17 @@ ${CMDNAME} prepare-provider-packages [FLAGS] [PACKAGE_ID ...]
17251713
Prepares backport packages. You can provide (after --) optional list of packages to prepare.
17261714
If no packages are specified, readme for all packages are generated. You can specify optional
17271715
--version-suffix-for-svn flag to generate rc candidate packages to upload to SVN or
1728-
--version-suffix-for-pypi flag to generate rc candidates for PyPI packages.
1716+
--version-suffix-for-pypi flag to generate rc candidates for PyPI packages. You can also
1717+
provide both suffixes in case you prepare alpha/beta versions.
17291718
17301719
Examples:
17311720
17321721
'${CMDNAME} prepare-provider-packages' or
17331722
'${CMDNAME} prepare-provider-packages google' or
17341723
'${CMDNAME} prepare-provider-packages --version-suffix-for-svn rc1 http google amazon' or
17351724
'${CMDNAME} prepare-provider-packages --version-suffix-for-pypi rc1 http google amazon'
1725+
'${CMDNAME} prepare-provider-packages --version-suffix-for-pypi a1
1726+
--version-suffix-for-svn a1 http google amazon'
17361727
17371728
General form:
17381729

dev/README.md

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,13 +1458,15 @@ Details about maintaining the SEMVER version are going to be discussed and imple
14581458
You can iterate and re-generate the same readme content as many times as you want.
14591459
Generated readme files should be eventually committed to the repository.
14601460
1461-
### Build an Alpha release for SVN apache upload
1461+
### Build regular provider packages for SVN apache upload
14621462
1463-
The Alpha artifacts we vote upon should be the exact ones in the future we vote against, without any
1464-
modification than renaming i.e. the contents of the files must be the same between voted
1465-
release candidate and final release. Because of this the version in the built artifacts
1466-
that will become the official Apache releases must not include the rcN suffix. They also need
1467-
to be signed and have checksum files. You can generate the checksum/signature files by running
1463+
There is a slightly different procedure if you build pre-release (alpha/beta) packages and the
1464+
release candidates. For the Alpha artifacts there is no voting and signature/checksum check, so
1465+
we do not need to care about this part. For release candidates - those packages might get promoted
1466+
to "final" packages by just renaming the files, so internally they should keep the final version
1467+
number without the rc suffix, even if they are rc1/rc2/... candidates.
1468+
1469+
They also need to be signed and have checksum files. You can generate the checksum/signature files by running
14681470
the "dev/sign.sh" script (assuming you have the right PGP key set-up for signing). The script
14691471
generates corresponding .asc and .sha512 files for each file to sign.
14701472
@@ -1474,20 +1476,37 @@ Currently, we are releasing alpha provider packages together with the main sourc
14741476
we are going to add procedure to release the sources of released provider packages separately.
14751477
Details are in [the related issue](https://github.com/apache/airflow/issues/11425)
14761478
1477-
* Generate the packages - since we are preparing packages for SVN repo, we should use the right switch. Note
1478-
that this will clean up dist folder before generating the packages, so it will only contain the packages
1479-
you intended to build.
1479+
For alpha/beta releases you need to specify both - svn and pyp i - suffixes, and they have to match. This is
1480+
verified by the breeze script. Note that the script will clean up dist folder before generating the
1481+
packages, so it will only contain the packages you intended to build.
1482+
1483+
* Pre-release packages:
14801484
14811485
```shell script
14821486
export VERSION=0.0.1alpha1
14831487
1484-
./breeze prepare-provider-packages --version-suffix-for-svn alpha1
1488+
./breeze prepare-provider-packages --version-suffix-for-svn a1 --version-suffix-for-pypi a1
14851489
```
14861490
14871491
if you ony build few packages, run:
14881492
14891493
```shell script
1490-
./breeze prepare-provider-packages --version-suffix-for-svn alpha1 PACKAGE PACKAGE ....
1494+
./breeze prepare-provider-packages --version-suffix-for-svn a1 --version-suffix-for-pypi a1 \
1495+
PACKAGE PACKAGE ....
1496+
```
1497+
1498+
* Release candidate packages:
1499+
1500+
```shell script
1501+
export VERSION=0.0.1alpha1
1502+
1503+
./breeze prepare-provider-packages --version-suffix-for-svn rc1
1504+
```
1505+
1506+
if you ony build few packages, run:
1507+
1508+
```shell script
1509+
./breeze prepare-provider-packages --version-suffix-for-svn rc1 PACKAGE PACKAGE ....
14911510
```
14921511
14931512
* Sign all your packages
@@ -1527,24 +1546,30 @@ cd ${AIRFLOW_REPO_ROOT}
15271546
Verify that the files are available at
15281547
[backport-providers](https://dist.apache.org/repos/dist/dev/airflow/backport-providers/)
15291548
1530-
### Publish the Alpha convenience package to PyPI
1549+
### Publish the Regular convenience package to PyPI
15311550
1532-
In order to publish to PyPI you just need to build and release packages. The packages should however
1533-
contain the rcN suffix in the version name as well, so you need to use `--version-suffix-for-pypi` switch
1534-
to prepare those packages. Note that these are different packages than the ones used for SVN upload
1551+
1552+
In case of pre-release versions you build the same packages for both PyPI and SVN so you can simply use
1553+
packages generated in the previous step and you can skip the "prepare" step below.
1554+
1555+
In order to publish release candidate to PyPI you just need to build and release packages.
1556+
The packages should however contain the rcN suffix in the version file name but not internally in the package,
1557+
so you need to use `--version-suffix-for-pypi` switch to prepare those packages.
1558+
Note that these are different packages than the ones used for SVN upload
15351559
though they should be generated from the same sources.
15361560
15371561
* Generate the packages with the right RC version (specify the version suffix with PyPI switch). Note that
15381562
this will clean up dist folder before generating the packages, so you will only have the right packages there.
15391563
15401564
```shell script
1541-
./breeze prepare-provider-packages --version-suffix-for-pypi alpha1
1565+
./breeze prepare-provider-packages --version-suffix-for-pypi a1 --version-suffix-for-SVN a1
15421566
```
15431567
15441568
if you ony build few packages, run:
15451569
15461570
```shell script
1547-
./breeze prepare-provider-packages --version-suffix-for-pypi alpha1 PACKAGE PACKAGE ....
1571+
./breeze prepare-provider-packages --version-suffix-for-pypi a1 \
1572+
PACKAGE PACKAGE ....
15481573
```
15491574
15501575
* Verify the artifacts that would be uploaded:

scripts/in_container/run_prepare_provider_packages.sh

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,81 @@ fi
8989
python3 refactor_provider_packages.py
9090

9191
VERSION_SUFFIX_FOR_PYPI=${VERSION_SUFFIX_FOR_PYPI:=""}
92+
readonly VERSION_SUFFIX_FOR_PYPI
93+
9294
VERSION_SUFFIX_FOR_SVN=${VERSION_SUFFIX_FOR_SVN:=""}
95+
readonly VERSION_SUFFIX_FOR_SVN
96+
97+
if [[ ${VERSION_SUFFIX_FOR_PYPI} != "" ]]; then
98+
echo
99+
echo "Version suffix for PyPI = ${VERSION_SUFFIX_FOR_PYPI}"
100+
echo
101+
fi
102+
if [[ ${VERSION_SUFFIX_FOR_SVN} != "" ]]; then
103+
echo
104+
echo "Version suffix for SVN = ${VERSION_SUFFIX_FOR_SVN}"
105+
echo
106+
fi
93107

94-
echo "Version suffix for PyPI= ${VERSION_SUFFIX_FOR_PYPI}"
95-
echo "Version suffix for SVN = ${VERSION_SUFFIX_FOR_SVN}"
108+
if [[ ${VERSION_SUFFIX_FOR_PYPI} != '' && ${VERSION_SUFFIX_FOR_SVN} != '' ]]; then
109+
if [[ ${VERSION_SUFFIX_FOR_PYPI} != "${VERSION_SUFFIX_FOR_SVN}" ]]; then
110+
>&2 echo
111+
>&2 echo "If you specify both version suffixes they must match"
112+
>&2 echo "However they are different: '${VERSION_SUFFIX_FOR_PYPI}' vs. '${VERSION_SUFFIX_FOR_SVN}'"
113+
>&2 echo
114+
exit 1
115+
else
116+
if [[ ${VERSION_SUFFIX_FOR_PYPI} =~ ^rc ]]; then
117+
>&2 echo
118+
>&2 echo "If you prepare an RC candidate, you need to specify only one of the PyPI/SVN suffixes"
119+
>&2 echo "However you specified both: '${VERSION_SUFFIX_FOR_PYPI}' vs. '${VERSION_SUFFIX_FOR_SVN}'"
120+
>&2 echo
121+
exit 2
122+
fi
123+
# Just use one of them - they are both the same:
124+
TARGET_VERSION_SUFFIX=${VERSION_SUFFIX_FOR_PYPI}
125+
fi
126+
else
127+
if [[ ${VERSION_SUFFIX_FOR_PYPI} == '' && ${VERSION_SUFFIX_FOR_SVN} == '' ]]; then
128+
# Preparing "official version"
129+
TARGET_VERSION_SUFFIX=""
130+
else
131+
TARGET_VERSION_SUFFIX=${VERSION_SUFFIX_FOR_PYPI}${VERSION_SUFFIX_FOR_SVN}
132+
if [[ ! ${TARGET_VERSION_SUFFIX} =~ rc.* ]]; then
133+
>&2 echo
134+
>&2 echo "If you prepare an alpha/beta release, you need to specify both PyPI/SVN suffixes"
135+
>&2 echo "And they have to match. You specified only one."
136+
>&2 echo
137+
exit 2
138+
fi
139+
fi
140+
fi
141+
142+
readonly TARGET_VERSION_SUFFIX
96143

97144
for PROVIDER_PACKAGE in ${PROVIDER_PACKAGES}
98145
do
99146
LOG_FILE=$(mktemp)
100147
echo "==================================================================================="
101-
echo " Preparing ${PACKAGE_TYPE} package ${PROVIDER_PACKAGE}"
148+
echo " Preparing ${PACKAGE_TYPE} package ${PROVIDER_PACKAGE} "
149+
if [[ "${VERSION_SUFFIX_FOR_PYPI}" == '' && "${VERSION_SUFFIX_FOR_SVN}" == '' ]]; then
150+
echo
151+
echo " Official version"
152+
echo
153+
elif [[ "${VERSION_SUFFIX_FOR_PYPI}" == '' ]]; then
154+
echo
155+
echo " Package Version for SVN release candidate: ${TARGET_VERSION_SUFFIX}"
156+
echo
157+
elif [[ "${VERSION_SUFFIX_FOR_SVN}" == '' ]]; then
158+
echo
159+
echo " Package Version for PyPI release candidate: ${TARGET_VERSION_SUFFIX}"
160+
echo
161+
else
162+
# Both SV/PYPI are set to the same version here!
163+
echo
164+
echo " Pre-release version: ${TARGET_VERSION_SUFFIX}"
165+
echo
166+
fi
102167
echo "-----------------------------------------------------------------------------------"
103168
set +e
104169
python3 setup_provider_packages.py "${PROVIDER_PACKAGE}" clean --all >"${LOG_FILE}" 2>&1
@@ -160,7 +225,8 @@ cd "${AIRFLOW_SOURCES}" || exit 1
160225

161226
pushd dist
162227

163-
if [[ -n ${VERSION_SUFFIX_FOR_SVN=} ]]; then
228+
if [[ ${VERSION_SUFFIX_FOR_PYPI} != "${TARGET_VERSION_SUFFIX}" ]]; then
229+
# In case we prepare different suffix for SVN and PYPI, rename the generated files
164230
for FILE in *.tar.gz
165231
do
166232
mv "${FILE}" "${FILE//\.tar\.gz/${VERSION_SUFFIX_FOR_SVN}-bin.tar.gz}"
@@ -173,7 +239,7 @@ fi
173239

174240
popd
175241

176-
AIRFLOW_PACKAGES_TGZ_FILE="/files/airflow-packages-$(date +"%Y%m%d-%H%M%S")-${VERSION_SUFFIX_FOR_SVN}${VERSION_SUFFIX_FOR_PYPI}.tar.gz"
242+
AIRFLOW_PACKAGES_TGZ_FILE="/files/airflow-packages-$(date +"%Y%m%d-%H%M%S")-${TARGET_VERSION_SUFFIX}.tar.gz"
177243

178244
tar -cvzf "${AIRFLOW_PACKAGES_TGZ_FILE}" dist/*.whl dist/*.tar.gz
179245
echo

0 commit comments

Comments
 (0)