Skip to content

Commit

Permalink
include handling of CITATION.cff files
Browse files Browse the repository at this point in the history
  • Loading branch information
pucicu committed Nov 11, 2024
1 parent ca36478 commit 95da2e8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
63 changes: 42 additions & 21 deletions makeinstall.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,9 @@ function makeinstall(varargin)
mi_version = 'none';
fid = fopen(mi_file,'r');
if fid ~= -1
while 1
while ~feof(fid)
temp = fgetl(fid);
if ~ischar(temp), break
elseif ~isempty(temp)
if ~isempty(temp)
if temp(1) == '%'
i = findstr(temp,'Version:');
if ~isempty(i), mi_version = temp(i(1)+9:end); break, end
Expand Down Expand Up @@ -235,9 +234,8 @@ function makeinstall(varargin)
fid = fopen(rc_file,'r');
if fid > 0 % begin main part
disp(' Reading the resource file')
while 1
while ~feof(fid)
l = fgetl(fid);
if ~ischar(l), break, end
if ~isempty(l), eval(l); end
end
fclose(fid);
Expand Down Expand Up @@ -271,9 +269,8 @@ function makeinstall(varargin)
end
fid = fopen(mi_file, 'r'); warning off
i = 1; flag = 0;
while 1
while ~feof(fid)
temp = fgetl(fid);
if ~ischar(temp), break, end
if length(temp) > 1
if strcmpi(temp,'%<-- ASCII begins here: install -->')
eofbyte = ftell(fid);
Expand Down Expand Up @@ -375,10 +372,9 @@ function makeinstall(varargin)
% version number from CVS/SVN tag in specified file
fid = fopen(version_file,'r');
if fid ~= -1
while 1
while ~feof(fid)
temp = fgetl(fid);
if ~ischar(temp), break
elseif ~isempty(temp)
if ~isempty(temp)
if temp(1) == '%'
i = findstr(temp,'Version:');
if ~isempty(i), version_number = temp(i(1)+9:end); break, end
Expand Down Expand Up @@ -551,18 +547,17 @@ function makeinstall(varargin)
% modify contents file
disp(' Modify Contents.m')
fid = fopen('Contents.m','r'); contents = '';
while 1
while ~feof(fid)
temp = fgetl(fid);
if ~ischar(temp), break, end
contents = [contents;{temp}];
end
fclose(fid);

if length(contents) > 1 && isempty(findstr(lower(contents{2}),'version'))
contents(3:end+1) = contents(2:end);
end
if ~strcmp(release,' ') && ~isempty(release), release = [' (',release,') ']; end
contents{2} = ['% Version ',strrep(version_number, 'v', ''),release,date];
if ~strcmp(release,' ') && ~isempty(release), crelease = [' (',release,') ']; end
contents{2} = ['% Version ',strrep(version_number, 'v', ''),crelease,date];
if (isempty(contents{end}) | findstr(contents{end},'Modified at')>0); l = length(contents); else l = length(contents)+1; end
contents{l} = ['% Modified at ',time_string,' by MAKEINSTALL'];

Expand All @@ -574,6 +569,35 @@ function makeinstall(varargin)
end


% Update CITATION.cff file if available
if exist(fullfile(src_dir,'CITATION.cff'),'file')
disp(' Modify CITATION.cff')
fid = fopen('CITATION.cff','r'); contents = {};
while ~feof(fid)
temp = fgetl(fid);
contents{end + 1} = temp;
end
fclose(fid);

% find cells with version and release date
matches_version = cellfun(@(x) strncmp(x, 'version:', length('version:')), contents);
matches_date = cellfun(@(x) strncmp(x, 'date-released:', length('date-released:')), contents);
index_version = find(matches_version);
index_date = find(matches_date);

if ~strcmp(release,' ') && ~isempty(release), crelease = [' (',release,')']; end
contents{index_version} = ['version: ''',strrep(version_number, 'v', ''),crelease,''''];
contents{index_date} = ['date-released: ''',datestr(now,'YYYY-mm-dd'),''''];

fid = fopen('CITATION.cff','w');
for i = 1:length(contents)
fprintf(fid,'%s\n',contents{i});
end
fclose(fid);
end



% find sub-directories
dirnames = ''; filenames = '';
temp = '.:';
Expand Down Expand Up @@ -837,7 +861,7 @@ function makeinstall(varargin)
%@ fid=fopen(install_file,'r');
%@ fseek(fid,0,'eof'); eofbyte=ftell(fid);
%@ fseek(fid,$startbyte$,'bof'); % location where the container starts
%@ while 1
%@ while ~feof(fid)
%@ temp=fgetl(fid);
%@ startbyte=ftell(fid);
%@ if length(temp)>1
Expand Down Expand Up @@ -929,9 +953,8 @@ function makeinstall(varargin)
%@ end
%@ fid = fopen(startupfile,'r');
%@ k = 1;
%@ while 1
%@ while ~feof(fid)
%@ tmp = fgetl(fid);
%@ if ~ischar(tmp), break, end
%@ instpaths{k} = tmp;
%@ k = k + 1;
%@ end
Expand Down Expand Up @@ -1031,9 +1054,8 @@ function makeinstall(varargin)
%@ end
%@ fid = fopen(startupfile,'r');
%@ k = 1;
%@ while 1
%@ while ~feof(fid)
%@ tmp = fgetl(fid);
%@ if ~ischar(tmp), break, end
%@ instpaths{k} = tmp;
%@ k = k + 1;
%@ end
Expand Down Expand Up @@ -1710,9 +1732,8 @@ function makeinstall(varargin)
%@ end
%@ fid = fopen(startupfile,'r');
%@ k = 1;
%@ while 1
%@ while ~feof(fid)
%@ tmp = fgetl(fid);
%@ if ~ischar(tmp), break, end
%@ instpaths{k} = tmp;
%@ k = k + 1;
%@ end
Expand Down
3 changes: 2 additions & 1 deletion makerelease.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


# Get a list of existing tags
tags=$(git tag | sort -V)
tags=$(git tag | sort -V | tail -n 3)

previous_tag=v3.5

Expand All @@ -18,6 +18,7 @@ for tag in ${=tags}; do
response=$(echo $response | jq -r ".message")
if [[ "$response" != "Not Found" ]]; then
echo "Release already exists for tag: $tag. Skipping..."
previous_tag=$tag
continue
fi

Expand Down

0 comments on commit 95da2e8

Please sign in to comment.