CD #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | |
on: | |
pull_request: | |
types: [closed] | |
workflow_dispatch: | |
permissions: | |
actions: read | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Setup development environment | |
run: | | |
python -m venv .venv | |
source .venv/bin/activate | |
python -m pip install -U pip | |
pip install azdev | |
azdev setup -r . | |
azdev extension add apic-extension | |
# Append commit hash to the version. E.g. 1.0.0b4+abc1234 | |
- name: Update version | |
run: | | |
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: | | |
source .venv/bin/activate | |
azdev extension build apic-extension | |
- name: Upload release asset | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release | |
path: | | |
./dist/*.whl |