Skip to content

Implement fpm publish #876

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

Merged
merged 28 commits into from
Apr 21, 2023
Merged

Implement fpm publish #876

merged 28 commits into from
Apr 21, 2023

Conversation

minhqdao
Copy link
Contributor

@minhqdao minhqdao commented Apr 12, 2023

Implement api for publishing a package to the registry.

  • Add new fpm_publish_settings and fpm_cmd_publish module.
  • Add procedure to find system tmp folder.
  • Add procedure to execute command line and read output.
  • Optionally show request with --show-form-data instead of publishing.
  • Optionally show package version with --show-version instead of publishing.
  • Parse license from the manifest.
  • Parse token from command.
  • Validate data.
  • Reject packages containing git dependencies.
  • Pack and archive using git archive.
  • Determine available archive methods with git archive -l and use available method.
  • Send request with form data using curl.
  • Add tests.

How to test

  1. Run fpm publish --show-package-version to print the package version to the console.

  2. Run fpm publish --show-form-data to print the form data to the console that would otherwise be sent through fpm publish --token <token>. If you include the token (fpm publish --token <token> --show-form-data), the token will be included in the form data.

  3. Get a (test) token from the registry website and run fpm publish --token <token> to publish a package to the (test) registry.

@minhqdao minhqdao mentioned this pull request Apr 19, 2023
@minhqdao minhqdao requested a review from perazz April 19, 2023 10:27
# Conflicts:
#	src/fpm_command_line.f90
Copy link
Member

@perazz perazz left a comment

Choose a reason for hiding this comment

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

Thanks @minhqdao, looks good to me.

@minhqdao minhqdao mentioned this pull request Apr 20, 2023
3 tasks
Copy link
Member

@arteevraina arteevraina left a comment

Choose a reason for hiding this comment

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

@minhqdao Looks good to me.

Copy link
Member

@henilp105 henilp105 left a comment

Choose a reason for hiding this comment

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

Thanks @minhqdao , Looks good to me.

@@ -1020,4 +1021,65 @@ subroutine get_home(home, error)
end if
end subroutine get_home

!> Execute command line and return output as a string.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this should be built into fortran just as execute_command_line. I was searching whether we already have a routine implemented in fpm but couldn't find any. Have I missed sth? @awvwgk @everythingfunctional @milancurcic

Choose a reason for hiding this comment

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

I haven't found any better method of capturing external command output in Fortran. I could potentially mention it to the standards committee.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be great if we had that.

Comment on lines +1060 to +1083
!> Get system-dependent tmp directory.
subroutine get_tmp_directory(tmp_dir, error)
!> System-dependant tmp directory.
character(len=:), allocatable, intent(out) :: tmp_dir
!> Error to handle.
type(error_t), allocatable, intent(out) :: error

tmp_dir = get_env('TMPDIR', '')
if (tmp_dir /= '') then
tmp_dir = tmp_dir//'fpm'; return
end if

tmp_dir = get_env('TMP', '')
if (tmp_dir /= '') then
tmp_dir = tmp_dir//'fpm'; return
end if

tmp_dir = get_env('TEMP', '')
if (tmp_dir /= '') then
tmp_dir = tmp_dir//'fpm'; return
end if

call fatal_error(error, "Couldn't determine system temporary directory.")
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same for this actually. @awvwgk @everythingfunctional @milancurcic

Choose a reason for hiding this comment

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

This one is built in.

error stop "Couldn't ..."

Copy link
Member

@awvwgk awvwgk left a comment

Choose a reason for hiding this comment

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

Looks good to me as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants