Skip to content

Commit

Permalink
Merge pull request #385 from anandhu-eng/releaseAutomate
Browse files Browse the repository at this point in the history
Build wheels and release them into PYPI
  • Loading branch information
arjunsuresh authored Oct 17, 2024
2 parents a7d560e + b124892 commit 7c5c8c3
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build wheels and release them into PYPI

on:
release:
types: [published]
push:
branches:
- main
- mlperf_inference
paths:
- VERSION
- setup.py

jobs:
build_wheels:
name: Build wheel
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
strategy:
fail-fast: false
steps:
# Step 1: Checkout the code
- uses: actions/checkout@v3

# Step 2: Set up Python
- uses: actions/setup-python@v3

# Step 3: Check if VERSION file has changed in this push
- name: Check if VERSION file has changed
id: version_changed
run: |
if git diff --name-only HEAD~1 | grep -q "VERSION"; then
echo "VERSION file has been modified"
echo "::set-output name=version_changed::true"
new_version=$(cat VERSION)
else
echo "VERSION file has NOT been modified"
echo "::set-output name=version_changed::false"
fi
echo "::set-output name=new_version::$new_version"
# Step 4: Increment version if VERSION was not changed
- name: Increment version if necessary
if: steps.version_changed.outputs.version_changed == 'false'
run: |
# Check if VERSION file exists, else initialize it
if [ ! -f VERSION ]; then
echo "0.0.0" > VERSION
fi
version=$(cat VERSION)
IFS='.' read -r major minor patch <<< "$version"
patch=$((patch + 1))
new_version="$major.$minor.$patch"
echo $new_version > VERSION
echo "New version: $new_version"
echo "::set-output name=new_version::$new_version"
# Step 5: Commit the updated version to the repository
- name: Commit updated version
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git add VERSION
git commit -m "Increment version to ${{ steps.version_changed.outputs.new_version }}"
git push
# Step 6: Install required dependencies
- name: Install requirements
run: python3 -m pip install setuptools wheel

# Step 7: Build the Python wheel
- name: Build wheels
run: python3 setup.py bdist_wheel

# Step 8: Publish to PyPI
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verify-metadata: true
skip-existing: true
packages-dir: dist
repository-url: https://upload.pypi.org/legacy/
verbose: true
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.0

0 comments on commit 7c5c8c3

Please sign in to comment.