Workflow file for this run
This file contains hidden or 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: Publish Python Package | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| build-and-publish: | |
| name: Build and Publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false # important to use PAT for pushing | |
| - 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 via a branch + PR | |
| - 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 "[email protected]" | |
| # Create/update temporary branch for metadata | |
| git checkout -B auto-update | |
| # 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:${REPO_PUSH_TOKEN}@github.com/sciknoworg/OntoLearner.git | |
| git push origin auto-update --force | |
| else | |
| echo "No changes to commit" | |
| fi | |
| # Create or update PR for metadata | |
| - name: Create or update Pull Request | |
| id: cpr | |
| uses: peter-evans/create-pull-request@v3 | |
| with: | |
| token: ${{ secrets.REPO_PUSH_TOKEN }} | |
| commit-message: ":bookmark: Update metadata after release" | |
| branch: auto-update | |
| base: main | |
| title: "🤖 Automated metadata update" | |
| body: "This PR updates Dublin Core metadata automatically after package release." | |
| labels: automated | |
| # Automatically merge the PR if possible | |
| - name: Auto-merge PR | |
| if: steps.cpr.outputs.pull-request-operation == 'created' | |
| uses: peter-evans/enable-pull-request-automerge@v3 | |
| with: | |
| token: ${{ secrets.REPO_PUSH_TOKEN }} | |
| pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} | |
| merge-method: squash | |
| - 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 |