Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/generate-codemeta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Generate CodeMeta with SOMEF

on:
workflow_dispatch:

permissions:
contents: write # needed to push changes

jobs:
codemeta:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install SOMEF
run: |
python -m pip install --upgrade pip
pip install somef

- name: Configure SOMEF (auto)
run: somef configure -a

- name: Generate codemeta.json
env:
REPO_URL: https://github.com/${{ github.repository }}
run: |
somef describe -r "$REPO_URL" -t 0.8 -c codemeta.json

- name: Commit and push codemeta.json (only if created and not already tracked)
if: github.event_name != 'pull_request'
run: |

# If codemeta.json is already tracked in the repo, don't add/commit it
if git ls-files --error-unmatch codemeta.json > /dev/null 2>&1; then
echo "codemeta.json is already tracked in the repository. Skipping git add"
else
git add codemeta.json
fi

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Commit only if staging has changes (defensive)
if ! git diff --cached --quiet; then
git commit -m "chore: add autogenerated codemeta.json with SOMEF"
git push
else
echo "No changes to commit."
fi
Loading