@@ -8,7 +8,7 @@ module fpm_cmd_publish
8
8
use fpm_model, only: fpm_model_t
9
9
use fpm_error, only: error_t, fpm_stop
10
10
use fpm_versioning, only: version_t
11
- use fpm_filesystem, only: exists, join_path, get_temp_filename
11
+ use fpm_filesystem, only: exists, join_path, get_temp_filename, delete_file
12
12
use fpm_git, only: git_archive
13
13
use fpm_downloader, only: downloader_t
14
14
use fpm_strings, only: string_t
@@ -64,34 +64,37 @@ subroutine cmd_publish(settings)
64
64
end if
65
65
end do
66
66
67
+ tmp_file = get_temp_filename()
68
+ call git_archive(' .' , tmp_file, error)
69
+ if (allocated (error)) call fpm_stop(1 , ' *cmd_publish* Archive error: ' // error% message)
70
+
67
71
upload_data = [ &
68
- string_t(' package_name="' // package% name// ' "' ), &
69
- string_t(' package_license="' // package% license// ' "' ), &
70
- string_t(' package_version="' // version% s()// ' "' ) &
71
- & ]
72
+ & string_t(' package_name="' // package% name// ' "' ), &
73
+ & string_t(' package_license="' // package% license// ' "' ), &
74
+ & string_t(' package_version="' // version% s()// ' "' ), &
75
+ & string_t(' tarball=@"' // tmp_file// ' "' ) &
76
+ & ]
72
77
73
78
if (allocated (settings% token)) upload_data = [upload_data, string_t(' upload_token="' // settings% token// ' "' )]
74
79
75
- tmp_file = get_temp_filename()
76
- call git_archive(' .' , tmp_file, error)
77
- if (allocated (error)) call fpm_stop(1 , ' *cmd_publish* Pack error: ' // error% message)
78
- upload_data = [upload_data, string_t(' tarball=@"' // tmp_file// ' "' )]
79
-
80
80
if (settings% show_upload_data) then
81
81
do i = 1 , size (upload_data)
82
82
print * , upload_data(i)% s
83
83
end do
84
- return
84
+ call delete_file(tmp_file); return
85
85
end if
86
86
87
87
! Make sure a token is provided for publishing.
88
88
if (allocated (settings% token)) then
89
- if (settings% token == ' ' ) call fpm_stop(1 , ' No token provided.' )
89
+ if (settings% token == ' ' ) then
90
+ call delete_file(tmp_file); call fpm_stop(1 , ' No token provided.' )
91
+ end if
90
92
else
91
- call fpm_stop(1 , ' No token provided.' )
93
+ call delete_file(tmp_file); call fpm_stop(1 , ' No token provided.' )
92
94
end if
93
95
94
96
call downloader% upload_form(official_registry_base_url// ' /packages' , upload_data, error)
97
+ call delete_file(tmp_file)
95
98
if (allocated (error)) call fpm_stop(1 , ' *cmd_publish* Upload error: ' // error% message)
96
99
end
97
100
end
0 commit comments