Skip to content

Commit

Permalink
Centralize __version__ management
Browse files Browse the repository at this point in the history
There is now a single `update_version.sh` script that updates the
`__version__` variables in the client and export components and
increments the debian/changelog file.

The proxy version is hardcoded since it's going away as part of proxy v2
(also the usage in the response object was dubious to begin with).

Fixes #1815.
  • Loading branch information
legoktm committed Feb 14, 2024
1 parent 3c58d48 commit e42b902
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 155 deletions.
2 changes: 1 addition & 1 deletion client/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "securedrop-client"
version = "0.1.0"
version = "0.0.0"
description = "SecureDrop Workstation client application"
authors = ["SecureDrop Team"]
license = "AGPLv3+"
Expand Down
4 changes: 2 additions & 2 deletions client/securedrop_client/gui/auth/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
QWidget,
)

from securedrop_client import __version__ as sd_version
from securedrop_client import __version__
from securedrop_client.gui.auth.sign_in import LoginErrorBar, SignInButton
from securedrop_client.gui.auth.use_offline import LoginOfflineLink
from securedrop_client.gui.base import PasswordEdit
Expand Down Expand Up @@ -127,7 +127,7 @@ def __init__(self, parent: QWidget) -> None:
form_layout.addWidget(buttons)

# Create widget to display application name and version
application_version = QLabel(_("SecureDrop Client v{}").format(sd_version))
application_version = QLabel(_("SecureDrop Client v{}").format(__version__))
application_version.setAlignment(Qt.AlignHCenter)
application_version.setObjectName("LoginDialog_app_version_label")

Expand Down
2 changes: 1 addition & 1 deletion client/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setuptools.setup(
name="securedrop-client",
version="0.9.0",
version="0.0.0",
author="Freedom of the Press Foundation",
author_email="[email protected]",
description="SecureDrop Workstation client application",
Expand Down
31 changes: 0 additions & 31 deletions client/update_version.sh

This file was deleted.

1 change: 0 additions & 1 deletion export/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
include LICENSE
include README.md
include securedrop_export/VERSION
include changelog.md
include build-requirements.txt
include securedrop_export/*.py
Expand Down
2 changes: 1 addition & 1 deletion export/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "securedrop-export"
version = "0.1.0"
version = "0.0.0"
description = "SecureDrop Qubes export scripts"
authors = ["SecureDrop Team"]
license = "GPLv3+"
Expand Down
1 change: 0 additions & 1 deletion export/securedrop_export/VERSION

This file was deleted.

2 changes: 1 addition & 1 deletion export/securedrop_export/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.0"
__version__ = "0.9.0"
8 changes: 1 addition & 7 deletions export/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
with open("README.md", "r") as fh:
long_description = fh.read()

with open("securedrop_export/VERSION") as f:
version = f.read().strip()

setuptools.setup(
name="securedrop-export",
version=version,
version="0.0.0",
author="Freedom of the Press Foundation",
author_email="[email protected]",
description="SecureDrop Qubes export scripts",
Expand All @@ -19,9 +16,6 @@
python_requires=">=3.5",
url="https://github.com/freedomofpress/securedrop-export",
packages=setuptools.find_packages(exclude=["docs", "tests"]),
package_data={
"securedrop_export": ["VERSION"],
},
classifiers=[
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3",
Expand Down
28 changes: 0 additions & 28 deletions export/update_version.sh

This file was deleted.

1 change: 0 additions & 1 deletion log/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ include securedrop-redis-log
include securedrop.Log
include sd-rsyslog*
include sdlog.conf
include VERSION
1 change: 0 additions & 1 deletion log/VERSION

This file was deleted.

2 changes: 1 addition & 1 deletion log/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "securedrop-log"
version = "0.1.0"
version = "0.0.0"
description = "SecureDrop Qubes logging scripts"
authors = ["SecureDrop Team"]
license = "GPLv3+"
Expand Down
9 changes: 1 addition & 8 deletions log/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
with open("README.md", "r") as fh:
long_description = fh.read()

with open("VERSION") as fh:
version = fh.read().strip()


setuptools.setup(
name="securedrop-log",
version=version,
version="0.0.0",
author="Freedom of the Press Foundation",
author_email="[email protected]",
description="SecureDrop Qubes logging scripts",
Expand All @@ -19,9 +15,6 @@
install_requires=[],
python_requires=">=3.5",
packages=setuptools.find_packages(exclude=["docs", "tests"]),
package_data={
'securedrop_log': ['VERSION'],
},
url="https://github.com/freedomofpress/securedrop-log",
classifiers=[
"Development Status :: 3 - Alpha",
Expand Down
26 changes: 0 additions & 26 deletions log/update_version.sh

This file was deleted.

1 change: 0 additions & 1 deletion proxy/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
include LICENSE
include README.md
include securedrop_proxy/VERSION
include changelog.md
include config-example.yaml
include qubes/securedrop.Proxy
Expand Down
1 change: 0 additions & 1 deletion proxy/securedrop_proxy/VERSION

This file was deleted.

9 changes: 1 addition & 8 deletions proxy/securedrop_proxy/version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
import pkgutil

version = None
version_content = pkgutil.get_data("securedrop_proxy", "VERSION")
if isinstance(version_content, bytes):
version = version_content.decode("utf-8")
else:
raise ValueError("Could not read VERSION file")
version = "0.4.1\n"
8 changes: 1 addition & 7 deletions proxy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
with open("README.md", "r") as fh:
long_description = fh.read()

version = pkgutil.get_data("securedrop_proxy", "VERSION").decode("utf-8")
version = version.strip()

setuptools.setup(
name="securedrop-proxy",
version=version,
version="0.0.0",
author="Freedom of the Press Foundation",
author_email="[email protected]",
description="SecureDrop Qubes proxy service",
Expand All @@ -20,9 +17,6 @@
python_requires=">=3.7",
url="https://github.com/freedomofpress/securedrop-proxy",
packages=setuptools.find_packages(exclude=["docs", "tests"]),
package_data={
'securedrop_proxy': ['VERSION'],
},
classifiers=(
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3",
Expand Down
27 changes: 0 additions & 27 deletions proxy/update_version.sh

This file was deleted.

25 changes: 25 additions & 0 deletions update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -euxo pipefail

NEW_VERSION=${1:-""}

if [ -z "$NEW_VERSION" ]; then
echo "Usage: ./update_version.sh <version>";
exit 1
fi


if [[ $NEW_VERSION == *~rc* ]]; then
echo "RCs should use the versioning a.b.c-rcD, where a.b.c is the next version"
exit 1
fi

sed -i'' -r -e "s/^__version__ = \"(.*?)\"/__version__ = \"${NEW_VERSION}\"/" client/securedrop_client/__init__.py
sed -i'' -r -e "s/^__version__ = \"(.*?)\"/__version__ = \"${NEW_VERSION}\"/" export/securedrop_export/__init__.py

# Normalize version, convert any - to ~, e.g. 0.9.0-rc1 to 0.9.0~rc1
DEB_VERSION=$(echo $NEW_VERSION | sed 's/-/~/g')

export DEBEMAIL="[email protected]"
export DEBFULLNAME="SecureDrop Team"
dch -b --newversion "${DEB_VERSION}" --distribution unstable "see changelog.md"

0 comments on commit e42b902

Please sign in to comment.