|
| 1 | +name: Sync Codemeta with Setup |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - codemeta.json |
| 7 | + |
| 8 | +jobs: |
| 9 | + sync-codemeta: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v3 |
| 15 | + |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v4 |
| 18 | + with: |
| 19 | + python-version: '3.x' |
| 20 | + |
| 21 | + - name: Install jq for JSON parsing |
| 22 | + run: sudo apt-get install -y jq |
| 23 | + |
| 24 | + - name: Parse and update setup.cfg |
| 25 | + run: | |
| 26 | + # Extract values from codemeta.json |
| 27 | + NAME=$(jq -r '.name' codemeta.json) |
| 28 | + VERSION=$(jq -r '.version' codemeta.json) |
| 29 | + AUTHOR=$(jq -r '.author[] | .name' codemeta.json | paste -sd ", " -) |
| 30 | + AUTHOR_EMAIL=$(jq -r '.author[] | .email // "[email protected]"' codemeta.json | paste -sd ", " -) |
| 31 | + DESCRIPTION=$(jq -r '.description' codemeta.json) |
| 32 | + URL=$(jq -r '.url' codemeta.json) |
| 33 | +
|
| 34 | + # Update setup.cfg fields |
| 35 | + sed -i "s/^name = .*/name = $NAME/" setup.cfg |
| 36 | + sed -i "s/^version = .*/version = $VERSION/" setup.cfg |
| 37 | + sed -i "s/^author = .*/author = $AUTHOR/" setup.cfg |
| 38 | + sed -i "s/^author_email = .*/author_email = $AUTHOR_EMAIL/" setup.cfg |
| 39 | + sed -i "s/^description = .*/description = $DESCRIPTION/" setup.cfg |
| 40 | + sed -i "s|^url = .*|url = $URL|" setup.cfg |
| 41 | +
|
| 42 | + - name: Commit changes |
| 43 | + run: | |
| 44 | + if ! git diff --quiet; then |
| 45 | + git config user.name "github-actions[bot]" |
| 46 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 47 | + git add setup.cfg |
| 48 | + git commit -m "Sync setup.cfg with codemeta.json changes" |
| 49 | + git push |
| 50 | + fi |
0 commit comments