Skip to content

✏️ add remote set-url #35

✏️ add remote set-url

✏️ add remote set-url #35

Workflow file for this run

name: Publish Python Package
on:
push:
tags:
- "v*"
jobs:
build-and-publish:
name: Build and Publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "export PATH=\"$HOME/.local/bin:$PATH\"" >> $GITHUB_ENV
- name: Install poetry-dynamic-versioning plugin
run: poetry self add "poetry-dynamic-versioning[plugin]"
- name: Install dependencies
run: poetry install --no-interaction --no-ansi
- name: Build the package
run: poetry build
# Generate metadata after publishing
- name: Generate Dublin Core metadata
run: |
mkdir -p metadata
poetry run python -c "from ontolearner import OntoLearnerMetadataExporter; OntoLearnerMetadataExporter().export('metadata/ontolearner-metadata.rdf')"
# Commit metadata back to repo
- name: Commit and push metadata
env:
REPO_PUSH_TOKEN: ${{ secrets.REPO_PUSH_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "actions@github.com"
# Fetch and switch to main branch
git fetch origin main
git checkout main
# Add metadata files
git add metadata/
# Commit only if changes exist
if ! git diff --cached --quiet; then
git commit -m ":bookmark: Update metadata after release"
git remote set-url origin https://x-access-token:${PAT_TOKEN}@github.com/sciknoworg/OntoLearner.git
git push origin main
else
echo "No changes to commit"
fi
- name: Configure Poetry for PyPI
run: |
poetry config pypi-token.pypi ${{ secrets.TWINE_API_TOKEN }}
- name: Publish to PyPI
run: |
poetry publish --no-interaction --no-ansi