Skip to content

Commit

Permalink
Merge pull request #490 from Pext/fix_ci_version
Browse files Browse the repository at this point in the history
Fix version generation in CI
  • Loading branch information
TheLastProject committed Nov 30, 2022
2 parents d199a0d + b115c67 commit a6a08eb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
1 change: 1 addition & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ after_test:
- conda create -n Pext python --yes
- CALL conda.bat activate Pext
- pip install -r requirements.txt
- python setup.py || true
- CALL conda.bat deactivate
- ps: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- ps: wsl sudo apt-get update
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ jobs:
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Install libfuse
run: |
sudo add-apt-repository universe
sudo apt install libfuse2
- name: Inspect directory after downloading artifacts
run: ls -alFR
- name: Create release and upload artifacts
Expand Down
52 changes: 42 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,51 @@
with open(pext_version_path) as version_file:
version = version_file.read().strip()

try:
from dulwich.porcelain import describe
print("Updating version with dulwich")
version = describe(pext_path)
except Exception as e:
print("Failed to determine version with dulwich, falling back to git describe: {}".format(e))
print("Calculating current version")
version_found = None

# Get version name from AppVeyor
if 'APPVEYOR' in os.environ:
if os.environ['APPVEYOR_REPO_TAG'] == "true":
version_found = os.environ['APPVEYOR_REPO_TAG_NAME']
print(f"AppVeyor: Set version to {version_found} from APPVEYOR_REPO_TAG_NAME")
else:
print(f"AppVeyor: Not a tagged version, APPVEYOR_REPO_TAG is {os.environ['APPVEYOR_REPO_TAG']} instead of true")
else:
print("AppVeyor: No valid version info")

# Get version name from GitHub
if not version_found:
if 'GITHUB_REF_TYPE' in os.environ:
if os.environ['GITHUB_REF_TYPE'] == "tag":
version_found = os.environ['GITHUB_REF_NAME']
print(f"GitHub: Set version to {version_found} from GITHUB_REF_NAME")
else:
print(f"GitHub: Found {os.environ['GITHUB_REF_NAME']} in GITHUB_REF_NAME but GITHUB_REF_TYPE is {os.environ['GITHUB_REF_TYPE']} instead of tag")
else:
print("GitHub: No valid version info")

# Get version name from Dulwich
if not version_found:
try:
from dulwich.porcelain import describe
version_found = describe(pext_path)
print(f"Dulwich: Set version to {version_found} using describe")
except Exception as e:
print("Dulwich: Failed to determine version with dulwich: {}".format(e))

# Get version name from Git
if not version_found:
try:
version = check_output(['git', 'describe'], cwd=pext_path).splitlines()[0]
version_found = check_output(['git', 'describe'], cwd=pext_path).splitlines()[0]
except Exception as e:
print("Failed to determine version with git describe: {}".format(e))
print("Git: Failed to determine version with git describe: {}".format(e))

if isinstance(version, bytes):
version = version.decode()
if version_found:
if isinstance(version_found, bytes):
version = version_found.decode()
else:
version = version_found

version = version.lstrip("v")

Expand Down

0 comments on commit a6a08eb

Please sign in to comment.