Install and Publish Specified Packages (Package Manager) #134
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: Install and Publish Specified Packages (Package Manager) | |
on: | |
workflow_dispatch: | |
inputs: | |
tag_name: | |
description: "The base tag for the release (e.g., v0.6.0)" | |
required: true | |
pre_release: | |
description: "The pre-release identifier (e.g., .dev1, .rc1, .alpha1)" | |
required: false | |
default: "" | |
jobs: | |
test: | |
env: | |
UNIQUE_VENV_PATH: "${{ github.workspace }}/.venv_core_${{ github.run_id }}" | |
runs-on: self-hosted | |
steps: | |
- name: Check Out Repository | |
uses: actions/checkout@v4 | |
- name: Set Up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Extract Version from Tag | |
id: extract-version | |
run: | | |
FULL_TAG="${{ inputs.tag_name }}${{ inputs.pre_release }}" | |
echo "Full tag: $FULL_TAG" | |
# Remove the 'v' prefix if present and extract the version | |
VERSION=${FULL_TAG#v} | |
echo "Extracted version: $VERSION" | |
echo "version=$VERSION" >> $GITHUB_ENV | |
- name: Create and Activate Virtual Environment | |
run: | | |
python -m venv $UNIQUE_VENV_PATH | |
source $UNIQUE_VENV_PATH/bin/activate | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV | |
- name: Install Poetry-Dynamic-Versioning Plugin | |
run: poetry self add poetry-dynamic-versioning | |
- name: Install toml | |
run: | | |
source $UNIQUE_VENV_PATH/bin/activate | |
pip install toml | |
- name: Generate poetry.lock | |
run: | | |
source $UNIQUE_VENV_PATH/bin/activate | |
python scripts/manage_packages.py poetry-lock --directory pkgs | |
- name: Install Dependencies | |
run: | | |
source $UNIQUE_VENV_PATH/bin/activate | |
python scripts/manage_packages.py poetry-install --directory pkgs --all-extras --dev | |
- name: Update pyproject.toml Files | |
run: | | |
# Function to process each directory | |
process_directory() { | |
for package in "$1"/*; do | |
if [ -d "$package" ]; then | |
if [ -f "$package/pyproject.toml" ]; then | |
echo "Processing $package" | |
# Update version field in pyproject.toml | |
sed -i "s/^version = \".*\"/version = \"${{ env.version }}\"/" "$package/pyproject.toml" | |
# Replace path dependencies with the extracted version | |
sed -i "s|\(path = \"\..*/core\"\)|version = \"^${{ env.version }}\"|" "$package/pyproject.toml" | |
sed -i "s|\(path = \"\..*/base\"\)|version = \"^${{ env.version }}\"|" "$package/pyproject.toml" | |
sed -i "s|\(path = \"\..\../core\"\)|version = \"^${{ env.version }}\"|" "$package/pyproject.toml" | |
sed -i "s|\(path = \"\..\../base\"\)|version = \"^${{ env.version }}\"|" "$package/pyproject.toml" | |
sed -i "s|\(path = \"\..*/standards/swarmauri_standard\"\)|version = \"^${{ env.version }}\"|" "$package/pyproject.toml" | |
sed -i "s|\(path = \"\..*/standards/swm_example_plugin\"\)|version = \"^${{ env.version }}\"|" "$package/pyproject.toml" | |
sed -i "s|\(path = \"\..*/community/swarmauri_community\"\)|version = \"^${{ env.version }}\"|" "$package/pyproject.toml" | |
sed -i "s|\(path = \"\..*/community/swm_example_package\"\)|version = \"^${{ env.version }}\"|" "$package/pyproject.toml" | |
# Show updated pyproject.toml content | |
cat "$package/pyproject.toml" | |
fi | |
# Recurse into subdirectories | |
process_directory "$package" | |
fi | |
done | |
} | |
# Start processing from pkgs directory | |
process_directory "pkgs" | |
- name: Publish from Dependencies | |
run: | | |
source $UNIQUE_VENV_PATH/bin/activate | |
python scripts/manage_packages.py publish-from-dependencies --directory pkgs --username __token__ --password "${{ secrets.DANGER_MASTER_PYPI_API_TOKEN }}" | |
- name: Show Installed Packages | |
run: | | |
source $UNIQUE_VENV_PATH/bin/activate | |
python scripts/manage_packages.py show-pip-freeze | |
- name: Clean Up Virtual Environment | |
if: always() | |
run: | | |
rm -rf ${{ env.UNIQUE_VENV_PATH }} |