Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codemeta.json #30

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ jobs:
name: openMINDS_MATLAB_${{ env.versionNumber }}.mltbx
path: releases/openMINDS_MATLAB_${{ env.versionNumber }}.mltbx

- name: Update codemeta.json
uses: matlab-actions/run-command@v2
with:
command: |
addpath(genpath("tools"));
updateCodeMetaFile("${{ github.ref_name }}")

# Commit the updated Contents.m
- name: Commit updated Contents.m file
continue-on-error: true
Expand All @@ -123,6 +130,7 @@ jobs:
git config user.email "<>"
git status
git add code/Contents.m
git add codemeta.json
git commit -m "Final checkins for release ${{ github.ref_name }}"
git fetch
git push
Expand Down
43 changes: 43 additions & 0 deletions codemeta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"license": "https://spdx.org/licenses/MIT",
"codeRepository": "https://github.com/openMetadataInitiative/openMINDS_MATLAB",
"contIntegration": "https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions",
"issueTracker": "https://github.com/openMetadataInitiative/openMINDS_MATLAB/issues",
"name": "openMINDS MATLAB",
"description": "openMINDS MATLAB is a toolbox to support the creation and use of openMINDS metadata models and schemas in MATLAB, with import and export in JSON-LD format. The package contains all openMINDS schemas as MATLAB classes in addition to schema base classes and utility methods.",
"applicationCategory": "neuroscience",
"releaseNotes": "https://github.com/openMetadataInitiative/openMINDS_MATLAB/releases",
"funding": "https://cordis.europa.eu/project/id/945539",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that this is not enough (depending on the version). Right now you would receive funding through EBRAINS 2.0 I guess?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this not be an array? with funder inside? not sure how codemeta handles this...

"developmentStatus": "active",
"funder": {
"@type": "Organization",
"name": "European Commission"
},
"programmingLanguage": [
"MATLAB"
],
"operatingSystem": [
"Linux",
"Windows",
"macOS"
],
"softwareRequirements": [
"MATLAB R2022b or later"
],
"relatedLink": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead or in addition you could define isPartOf since this repo is part of the open metadata initiative organisation on github

"https://openminds-documentation.readthedocs.io"
],
"author": [
{
"@type": "Person",
"@id": "https://orcid.org/0000-0002-8297-1753",
"givenName": "Eivind",
"familyName": "Hennestad"
}
],
"version": "0.9.3",
"downloadUrl": "https://github.com/openMetadataInitiative/openMINDS_MATLAB/releases/download/v0.9.3/openMINDS_MATLAB_v0_9_3.mltbx",
"dateModified": "2024-10-01"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have an empty line at the end

38 changes: 38 additions & 0 deletions tools/tasks/updateCodeMetaFile.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function codeMetaInfo = updateCodeMetaFile(versionString)

arguments
versionString (1,1) string {mustBeTextScalar, mustBeValidVersionString}
end

if startsWith(versionString, "v")
versionStringNumeric = extractAfter(versionString, 1);
else
error('Expected versionString to start with "v"')
end

projectRootDirectory = ommtools.projectdir();

codeMetaFilePath = fullfile(projectRootDirectory, 'codemeta.json');
codeMetaInfo = jsondecode( fileread(codeMetaFilePath) );

codeMetaInfo.version = versionStringNumeric;
codeMetaInfo.downloadUrl = sprintf("https://github.com/openMetadataInitiative/openMINDS_MATLAB/releases/download/%s/openMINDS_MATLAB_%s.mltbx", ...
versionString, strrep(versionString, '.', '_'));
codeMetaInfo.dateModified = string(datetime('today', 'Format', 'yyyy-MM-dd'));

jsonStr = jsonencode(codeMetaInfo, 'PrettyPrint', true);

% Fix json-ld @props
jsonStr = strrep(jsonStr, 'x_context', '@context');
jsonStr = strrep(jsonStr, 'x_type', '@type');
jsonStr = strrep(jsonStr, 'x_id', '@id');

fid = fopen(codeMetaFilePath, 'wt');
fwrite(fid, jsonStr);
fclose(fid);
end

function mustBeValidVersionString(versionString)
pattern = 'v\d+\.\d+\.\d+';
assert( ~ismissing( regexp(versionString, pattern, 'match', 'once')), 'Invalid version string. Must be formatted as v<major>.<minor>.<patch>' )
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have an empty line at the end

Loading