diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 2acb43d7..f86bb8cc 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -23,3 +23,45 @@ jobs: tools_directory: tools secrets: DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} + + update-codemeta: + name: Update codemeta.json + needs: prepare-release + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ssh-key: ${{ secrets.DEPLOY_KEY }} + ref: main + + - name: Determine version string + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "tag=v${{ inputs.version }}" >> $GITHUB_OUTPUT + else + echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT + fi + + - name: Set up MATLAB + uses: matlab-actions/setup-matlab@v2 + + - name: Update codemeta.json + uses: matlab-actions/run-command@v2 + with: + command: addpath(genpath("tools")); updateCodeMetaFile("${{ steps.version.outputs.tag }}") + + - name: Commit and push changes + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add codemeta.json + if git diff --cached --quiet; then + echo "No changes to commit" + else + git commit -m "Update codemeta.json for ${{ steps.version.outputs.tag }}" + git push + fi