mirror of
https://github.com/simple-login/app.git
synced 2024-09-27 20:31:30 +02:00
Use python version file
This commit is contained in:
parent
c3792dc333
commit
9959848d74
6
.github/workflows/main.yml
vendored
6
.github/workflows/main.yml
vendored
@ -120,7 +120,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Prepare version file
|
- name: Prepare version file
|
||||||
run: |
|
run: |
|
||||||
echo "${{ github.ref }}" > .version
|
BUILD_INFO_FILE=app/build_info.py
|
||||||
|
echo "SHA1 = '${{ github.ref }}'" > $BUILD_INFO_FILE
|
||||||
|
BUILD_TIME=$(date +%s)
|
||||||
|
echo "BUILD_TIME = '${BUILD_TIME}' >> $BUILD_INFO_FILE
|
||||||
|
cat $BUILD_INFO_FILE
|
||||||
|
|
||||||
- name: Build image and publish to Docker Registry
|
- name: Build image and publish to Docker Registry
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
|
2
app/build_info.py
Normal file
2
app/build_info.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
SHA1 = "dev"
|
||||||
|
BUILD_TIME = "1652365083"
|
@ -2,29 +2,15 @@ import os
|
|||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import string
|
import string
|
||||||
|
from app import build_info
|
||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
from pathlib import Path
|
|
||||||
from typing import Callable, List
|
from typing import Callable, List
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
DEFAULT_VERSION = "unknown"
|
|
||||||
|
|
||||||
|
SHA1 = build_info.SHA1
|
||||||
def load_version() -> str:
|
|
||||||
try:
|
|
||||||
this_file_path = Path(__file__)
|
|
||||||
root_dir_path = this_file_path.parent.parent
|
|
||||||
version_file_path = root_dir_path.joinpath(".version")
|
|
||||||
with open(version_file_path, "r") as f:
|
|
||||||
return f.readline().strip()
|
|
||||||
except Exception:
|
|
||||||
print("Could not load .version. Using default version")
|
|
||||||
return DEFAULT_VERSION
|
|
||||||
|
|
||||||
|
|
||||||
SHA1 = load_version()
|
|
||||||
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user