Skip to content

Commit ef31285

Browse files
maxhbrarmintaenzertng
authored andcommitted
add script to publish from tag
Signed-off-by: Maximilian Huber <[email protected]>
1 parent 8ef0cef commit ef31285

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ __pycache__/
22
*.py[cod]
33
*.out
44
/build/
5-
/dist/
5+
/dist*/
66
/tmp/
77
src/spdx_tools/spdx/parser/tagvalue/parsetab.py
88
/.cache/

dev/publish_from_tag.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: 2023 spdx contributors
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
set -euo pipefail
6+
7+
if [ $# -eq 0 ]; then
8+
cat<<EOF
9+
Usage:
10+
$0 \$VERSION
11+
Example:
12+
$0 0.8.0rc2
13+
where 0.8.0rc2 is the version and v0.8.0rc2 is the corresponding tag.
14+
EOF
15+
exit 0
16+
fi
17+
18+
19+
version="$1"
20+
tag="v${version}"
21+
tar_gz="https://github.com/spdx/tools-python/releases/download/${tag}/spdx_tools_dist.tar.gz"
22+
tag_dir="dist-${tag}"
23+
24+
cd -- "$(dirname "$0")/.."
25+
26+
if ! command -v twine &> /dev/null; then
27+
echo "twine could not be found"
28+
echo "maybe load venv with"
29+
echo " . ./venv/bin/activate"
30+
echo " . ./venv/bin/activate.fish"
31+
echo
32+
33+
if [[ -d ./venv/bin/ ]]; then
34+
echo "will try to activate ./venv ..."
35+
36+
source ./venv/bin/activate
37+
38+
if ! command -v twine &> /dev/null; then
39+
echo "twine still could not be found"
40+
exit 1
41+
fi
42+
else
43+
exit 1
44+
fi
45+
fi
46+
47+
48+
if [[ -d "$tag_dir" ]]; then
49+
echo "the dir \"$tag_dir\" already exists, exiting for safety"
50+
exit 1
51+
fi
52+
53+
mkdir -p "$tag_dir"
54+
(cd "$tag_dir" && wget -c "$tar_gz" -O - | tar --strip-components=1 -xz)
55+
56+
twine check "${tag_dir}/spdx-tools-${version}.tar.gz" "${tag_dir}/spdx_tools-${version}-py3-none-any.whl"
57+
read -r -p "Do you want to upload? [y/N] " response
58+
case "$response" in
59+
[yY][eE][sS]|[yY])
60+
twine upload -r pypi "${tag_dir}/spdx-tools-${version}.tar.gz" "${tag_dir}/spdx_tools-${version}-py3-none-any.whl"
61+
;;
62+
esac

0 commit comments

Comments
 (0)