Skip to content

Commit cb3dd26

Browse files
authored
Merge pull request #433 from igaw/build-support-pypi-rc-uploads
Add support for uploading release candidates to PyPI
2 parents 47e3562 + 6081b1e commit cb3dd26

3 files changed

Lines changed: 23 additions & 24 deletions

File tree

.github/workflows/python-publish.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@ jobs:
4646
runs-on: ubuntu-latest
4747
if: startsWith(github.ref, 'refs/tags/v')
4848
steps:
49-
- uses: actions/download-artifact@v3
49+
- name: Check if it is a release tag
50+
id: check-tag
51+
run: |
52+
if [[ ${{ github.event.ref }} =~ ^refs/tags/v([0-9]+\.[0-9]+)(-rc[0-9]+)?$ ]]; then
53+
echo ::set-output name=match::true
54+
fi
55+
- name: Download artifiact
56+
uses: actions/download-artifact@v3
57+
if: steps.check-tag.outputs.match == 'true'
5058
with:
5159
name: artifact
5260
path: dist
53-
5461
- name: Publish package to PyPI
5562
uses: pypa/gh-action-pypi-publish@release/v1.5
63+
if: steps.check-tag.outputs.match == 'true'
5664
with:
5765
user: __token__
5866
password: ${{ secrets.PYPI_API_TOKEN }}

meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ project(
1818
]
1919
)
2020

21-
library_version = meson.project_version() + '.0'
21+
maj_min = meson.project_version().split('-rc')[0]
22+
library_version = maj_min + '.0'
2223

2324
################################################################################
2425
cc = meson.get_compiler('c')

release.sh

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ usage() {
99
echo " '^v[\d]+.[\d]+(-rc[0-9]+)?$'"
1010
echo ""
1111
echo "example:"
12-
echo " release.sh v2.1-rc0 # v2.1 release candidate 0 -> sets the project "
13-
echo " # version to '1.1' and sets the tag"
14-
echo " release.sh v2.1-rc1 # v2.1 release canditate 1 -> only sets the tag"
15-
echo " release.sh v2.1 # v2.1 release -> sets the final tag"
12+
echo " release.sh v2.1-rc0 # v2.1 release candidate 0"
13+
echo " release.sh v2.1 # v2.1 release"
1614
}
1715

1816
VERSION=$1
@@ -22,14 +20,12 @@ if [ -z "$VERSION" ] ; then
2220
exit 1
2321
fi
2422

25-
new_ver=""
26-
rc=""
23+
ver=""
2724

2825
re='^v([0-9]+\.[0-9]+)(-rc[0-9]+)?$'
2926
if [[ "$VERSION" =~ $re ]]; then
3027
echo "Valid version $VERSION string"
31-
new_ver=${BASH_REMATCH[1]}
32-
rc=${BASH_REMATCH[2]}
28+
ver=${BASH_REMATCH[1]}${BASH_REMATCH[2]}
3329
else
3430
echo "Invalid version string $VERSION"
3531
echo ""
@@ -58,22 +54,16 @@ else
5854
exit 1
5955
fi
6056

57+
# update meson.build
58+
sed -i -e "0,/[ \t]version: /s/\([ \t]version: \).*/\1\'$ver\',/" meson.build
59+
git add meson.build
60+
git commit -s -m "build: Update version to $VERSION"
61+
62+
# update documentation
6163
./$doc_dir/update-docs.sh
6264
git add $doc_dir
63-
git commit -s -m "Regenerate all documentation" \
64-
-m "Regenerate documentation for $VERSION release"
65-
66-
# update meson.build
67-
old_ver=$(sed -n "0,/[ \t]\+version: /s/[ \t]\+version: '\([0-9]\+.[0-9]\+\)',$/\1/p" meson.build)
68-
if [ "$old_ver" != "$new_ver" ]; then
69-
# Only update project version once, that is either
70-
# - for the first RC phase or
71-
# - for the release when there was no RC
72-
sed -i -e "0,/[ \t]version: /s/\([ \t]version: \).*/\1\'$new_ver\',/" meson.build
73-
git add meson.build
74-
fi
65+
git commit -s -m "doc: Regenerate all docs for $VERSION"
7566

76-
git commit -s -m "Release $VERSION"
7767
git tag -s -m "Release $VERSION" "$VERSION"
7868
git push --dry-run origin "$VERSION"^{}:master tag "$VERSION"
7969

0 commit comments

Comments
 (0)