Skip to content

Commit

Permalink
Merge pull request EDCD#2118 from dvdmuckle/linux-gitversion
Browse files Browse the repository at this point in the history
Add .gitversion file to Linux archive
  • Loading branch information
Rixxan authored Dec 26, 2023
2 parents b0b9113 + 3947c6a commit 1976ddb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# vim: tabstop=2 shiftwidth=2
name: Build EDMC for Windows
name: Build EDMC

on:
push:
Expand All @@ -11,7 +11,7 @@ jobs:
variables:
outputs:
sem_ver: ${{ steps.var.outputs.sem_ver }}
archive_exclusions: ${{ steps.var.outputs.archive_exclusions }}
short_sha: ${{ steps.var.outputs.short_sha }}
runs-on: "ubuntu-latest"
steps:
- name: Setting global variables
Expand All @@ -20,6 +20,7 @@ jobs:
with:
script: |
core.setOutput('sem_ver', '${{ github.ref_name }}'.replaceAll('Release\/', ''))
core.setOutput('short_sha', '${{ github.sha }}'.substring(0, 8))
linux_build:
needs: [variables]
Expand All @@ -29,6 +30,9 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Create .gitversion
run: |
echo "${{ needs.variables.outputs.short_sha }}" > .gitversion
- name: Make tar archive
run: |
Expand All @@ -40,7 +44,11 @@ jobs:
--exclude=EDMarketConnector-release-*.* \
--exclude=.editorconfig \
--exclude=.flake8 \
--exclude=.git* \
--exclude=.gitattributes \
--exclude=.gitignore \
--exclude=.gitmodules \
--exclude=.git \
--exclude=.github \
--exclude=.mypy.ini \
--exclude=.pre-commit-config.yaml \
--exclude=build.py \
Expand Down
10 changes: 8 additions & 2 deletions config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,16 @@ def appversion() -> semantic_version.Version:
shorthash = gitv.read()

else:
# Running from source
# Running from source. Use git rev-parse --short HEAD
# or fall back to .gitversion file if it exists.
# This is also required for the Flatpak
shorthash = git_shorthash_from_head()
if shorthash is None:
shorthash = 'UNKNOWN'
if pathlib.Path(sys.path[0] + "/" + GITVERSION_FILE).exists():
with open(pathlib.Path(sys.path[0] + "/" + GITVERSION_FILE), encoding='utf-8') as gitv:
shorthash = gitv.read()
else:
shorthash = 'UNKNOWN'

_cached_version = semantic_version.Version(f'{_static_appversion}+{shorthash}')
return _cached_version
Expand Down

0 comments on commit 1976ddb

Please sign in to comment.