From 0cc7dc7416f8bf36d61956702fdb428f84926abd Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Wed, 9 Sep 2026 12:11:21 +0100 Subject: [PATCH] Added generate codemeta --- .github/workflows/generate-codemeta.yaml | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/generate-codemeta.yaml diff --git a/.github/workflows/generate-codemeta.yaml b/.github/workflows/generate-codemeta.yaml new file mode 100644 index 00000000..dbeabda0 --- /dev/null +++ b/.github/workflows/generate-codemeta.yaml @@ -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