Update compute_tunings.py #33
Workflow file for this run
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: Upload Python Package | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest # Use the latest Ubuntu environment | |
steps: | |
# Step 1: Check out the repository code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Python environment | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' # Specify the Python version | |
# Step 3: Install dependencies for building and uploading the package | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip # Upgrade pip | |
pip install build twine # Install build and twine | |
# Step 4: Update the version in pyproject.toml | |
- name: Update version in pyproject.toml | |
run: | | |
TAG_NAME="${GITHUB_REF#refs/tags/}" # Extract tag name | |
VERSION="${TAG_NAME#v}" # Remove 'v' prefix to get version number | |
echo "Updating version in pyproject.toml to $VERSION" | |
# Use sed to update the version in pyproject.toml | |
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml | |
# Verify the change | |
grep "^version = " pyproject.toml | |
# Step 5: Build the package | |
- name: Build the package | |
run: | | |
python -m build # Build source and wheel distributions | |
# List the contents of the dist directory after build | |
echo "Contents of dist directory after build:" | |
ls -l dist | |
# Step 6: Extract version from the tag and upload the matching files | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: __token__ # Use __token__ for authentication | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} # Use the PyPI API token stored as a secret | |
run: | | |
# Extract the version from the tag | |
TAG_NAME="${GITHUB_REF#refs/tags/}" # Get the tag name without "refs/tags/" | |
VERSION="${TAG_NAME#v}" # Remove the 'v' prefix | |
echo "Version extracted from tag: $VERSION" | |
# Define the base name of your package | |
PACKAGE_NAME="numan_plus" | |
# Print the list of files in dist directory for debugging | |
echo "Files in dist directory before uploading:" | |
ls dist | |
# Find the distribution files that match the extracted version | |
LATEST_FILES=$(ls dist | grep -E "^${PACKAGE_NAME}-${VERSION}.*\.(tar\.gz|whl)$") | |
echo "Files matched for version $VERSION: $LATEST_FILES" | |
# Check if files were found | |
if [ -z "$LATEST_FILES" ]; then | |
echo "No distribution files found for version $VERSION" | |
exit 1 | |
fi | |
# Upload the matching files | |
for FILE in $LATEST_FILES; do | |
echo "Uploading $FILE" | |
twine upload "dist/$FILE" | |
done |