Obtain git information from version file
This commit is contained in:
parent
6b36651def
commit
c3792dc333
|
@ -14,3 +14,4 @@ venv/
|
||||||
.venv
|
.venv
|
||||||
.coverage
|
.coverage
|
||||||
htmlcov
|
htmlcov
|
||||||
|
.git/
|
|
@ -114,16 +114,21 @@ jobs:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Build image and publish to Docker Registry
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
|
|
||||||
# We need to checkout the repository in order for the "Create Sentry release" to work
|
# We need to checkout the repository in order for the "Create Sentry release" to work
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Prepare version file
|
||||||
|
run: |
|
||||||
|
echo "${{ github.ref }}" > .version
|
||||||
|
|
||||||
|
- name: Build image and publish to Docker Registry
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
|
||||||
- name: Create Sentry release
|
- name: Create Sentry release
|
||||||
uses: getsentry/action-release@v1
|
uses: getsentry/action-release@v1
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -2,14 +2,29 @@ import os
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import string
|
import string
|
||||||
import subprocess
|
|
||||||
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
|
||||||
|
|
||||||
SHA1 = subprocess.getoutput("git rev-parse HEAD")
|
DEFAULT_VERSION = "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
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