Skip to content

Commit

Permalink
build: move update version logic to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
blackchoey committed Apr 9, 2024
1 parent f661669 commit 34fc8d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
32 changes: 30 additions & 2 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,37 @@ jobs:
azdev extension add apic-extension
# Append commit hash to the version. E.g. 1.0.0b4+abc1234
- name: Generate and update version
- name: Update version
run: |
python ./github/workflows/update_version.py
python -c "
import re
import os
# Open the file
with open('src/apic-extension/setup.py', 'r') as f:
content = f.read()
# Find the version string
version_match = re.search(r'VERSION = \'(.*?)\'', content)
if version_match is None:
raise ValueError('Could not find version string in setup.py')
# Extract the original version
original_version = version_match.group(1)
# Get the commit hash
commit_hash = os.getenv('GITHUB_SHA', 'daily')[:7]
# Create the new version string
new_version = original_version + '+' + commit_hash
# Replace the old version string with the new one
content_new = re.sub(r'VERSION = \'(.*?)\'', f'VERSION = \'{new_version}\'', content)
# Write the updated content back to the file
with open('src/apic-extension/setup.py', 'w') as f:
f.write(content_new)
"
- name: Build binary
run: |
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/update_version.py

This file was deleted.

0 comments on commit 34fc8d7

Please sign in to comment.