diff --git a/.github/workflows/Changelog.yml b/.github/workflows/Changelog.yml new file mode 100644 index 0000000..9de6c31 --- /dev/null +++ b/.github/workflows/Changelog.yml @@ -0,0 +1,21 @@ +name: Check Changelog + +on: pull_request + +jobs: + changelog: + runs-on: ubuntu-latest + name: Changelog should be updated + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Git fetch + run: git fetch + + - name: Check that changelog has been updated. + run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0 diff --git a/.github/workflows/Version_Check.yml b/.github/workflows/Version_Check.yml new file mode 100644 index 0000000..d0387ab --- /dev/null +++ b/.github/workflows/Version_Check.yml @@ -0,0 +1,39 @@ +name: Check pyproject.toml Version Change + +on: + pull_request: + branches: + - 'main' + +jobs: + check-version: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get current version in PR branch + id: get-pr-version + run: | + PR_VERSION=$(sed -n -e 's/^version = "\(.*\)"/\1/p' pyproject.toml) + echo "PR_VERSION=$PR_VERSION" >> $GITHUB_ENV + + - name: Get version in base branch + id: get-base-version + run: | + git fetch origin ${{ github.event.pull_request.base.ref }} + git checkout FETCH_HEAD + BASE_VERSION=$(sed -n -e 's/^version = "\(.*\)"/\1/p' pyproject.toml) + echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV + + - name: Compare versions + run: | + echo "PR version: ${{ env.PR_VERSION }}" + echo "Base branch version: ${{ env.BASE_VERSION }}" + + if [ "${{ env.PR_VERSION }}" == "${{ env.BASE_VERSION }}" ]; then + echo "Version number has not been changed." + exit 1 + else + echo "Version number has changed." + fi diff --git a/.github/workflows/pr.yml b/.github/workflows/linting.yml similarity index 100% rename from .github/workflows/pr.yml rename to .github/workflows/linting.yml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..abad543 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- Changelog! +- PR workflows. +- Version number in UI. + +## [0.0.1] + +- Initial release + +[Unreleased]: https://github.com/itk-dev-rpa/OpenPostbud/compare/0.0.1...HEAD +[0.0.1]: https://github.com/itk-dev-rpa/OpenPostbud/releases/tag/0.0.1 diff --git a/src/OpenPostbud/config.py b/src/OpenPostbud/config.py index df3d55a..490f1ee 100644 --- a/src/OpenPostbud/config.py +++ b/src/OpenPostbud/config.py @@ -5,6 +5,7 @@ import os import logging import json +from importlib import metadata import dotenv @@ -49,6 +50,8 @@ def format(self, record: logging.LogRecord): SHIPMENT_LIFETIME_DAYS = int(os.environ['shipment_lifetime_days']) REGISTRATION_JOB_LIFETIME_DAYS = int(os.environ['registration_job_lifetime_days']) +OPENPOSTBUD_VERSION = metadata.version("OpenPostbud") + # Workers CVR = os.environ['cvr'] KOMBIT_CERT_PATH = os.environ['kombit_cert_path'] diff --git a/src/OpenPostbud/ui_components.py b/src/OpenPostbud/ui_components.py index e34e788..ecbab11 100644 --- a/src/OpenPostbud/ui_components.py +++ b/src/OpenPostbud/ui_components.py @@ -7,6 +7,7 @@ from nicegui import ui, app from OpenPostbud.middleware import authentication +from OpenPostbud import config def header(): @@ -32,6 +33,8 @@ def header(): ui.space() ui.label(authentication.get_current_user()).classes('text-lg text-white') ui.label(str(authentication.get_current_user_roles())).classes('text-lg text-white') + ui.separator().props("vertical color=white size=2px") + ui.label(config.OPENPOSTBUD_VERSION).classes('text-lg text-white') ui.button("Log Ud", on_click=authentication.logout, color="white").classes("text-primary")