Skip to content

Merge remote-tracking branch 'origin/dev' into dev #41

Merge remote-tracking branch 'origin/dev' into dev

Merge remote-tracking branch 'origin/dev' into dev #41

Workflow file for this run

name: Build loadgen wheels and release them into PYPI
on:
release:
types: [published]
push:
branches:
- master
- loadgen-release
- dev
paths:
- loadgen/**
jobs:
update_version:
name: Update version only on ubuntu but used by windows and macos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Check if VERSION.txt file has changed in this push

Check failure on line 21 in .github/workflows/build_wheels.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build_wheels.yml

Invalid workflow file

You have an error in your yaml syntax on line 21
- name: Check if VERSION.txt file has changed
id: version_changed
run: |
echo "version_changed=false" >> $GITHUB_ENV
echo "new_version=" >> $GITHUB_ENV # Initialize with empty value
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q "VERSION.txt"; then
echo "VERSION.txt file has been modified"
echo "version_changed=true" >> $GITHUB_ENV
new_version=$(cat VERSION.txt)
echo "new_version=$new_version" >> $GITHUB_ENV
else
echo "VERSION.txt file has NOT been modified"
fi
# Step 4: Increment version if VERSION.txt was not changed
- name: Increment version if necessary
id: do_version_increment
if: env.version_changed == 'false'
run: |
cd loadgen
# Check if VERSION file exists, else initialize it
if [ ! -f VERSION.txt ]; then
echo "0.0.0" > VERSION.txt
fi
version=$(cat VERSION.txt)
IFS='.' read -r major minor patch <<< "$version"
patch=$((patch + 1))
new_version="$major.$minor.$patch"
echo $new_version > VERSION.txt
echo "New version: $new_version"
echo "new_version=$new_version" >> $GITHUB_ENV
# Step 5: Commit the updated version to the repository
- name: Commit updated version
if: env.version_changed == 'false'
run: |
cd loadgen
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git add VERSION.txt
git commit -m "Increment version to $new_version"
git push
build_wheels:
name: Build wheels on ${{ matrix.os }}
needs: update_version
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Install requirements
run: python -m pip install cibuildwheel twine
- name: Build wheels
run: git pull && python -m cibuildwheel loadgen/ --output-dir wheels
# Save wheels as artifacts
- name: Upload built wheels
uses: actions/upload-artifact@v3
with:
name: wheels-${{ matrix.os }}
path: wheels
publish_wheels:
needs: build_wheels # Wait for the build_wheels job to complete
runs-on: ubuntu-latest # Only run this job on Linux
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v3
# Download the built wheels from ubuntu
- name: Download Ubuntu wheels
uses: actions/download-artifact@v3
with:
name: wheels-ubuntu-latest
path: wheels
# Download the built wheels from macOS
- name: Download macOS wheels
uses: actions/download-artifact@v3
with:
name: wheels-macos-latest
path: wheels
# Download the built wheels from Windows
- name: Download Windows wheels
uses: actions/download-artifact@v3
with:
name: wheels-windows-latest
path: wheels
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
verify-metadata: true
skip-existing: true
packages-dir: wheels
repository-url: https://upload.pypi.org/legacy/
verbose: true