3939 X(dist, "Create distribution zip") \
4040 X(publish, "Publish to the things..") \
4141 X(pip, "Create pip egg") \
42+ X(aur, "Publish to aur.") \
4243 X(unittests, "Run unit tests") \
4344 X(fuzztests, "Run fuzz tests") \
4445 X(compile_commands, "Create compile_commands.json file") \
@@ -905,11 +906,10 @@ bool nob_cmd_run_sync_str_and_reset(const char* temp_file_path, Nob_Cmd* cmd, br
905906 return success ;
906907}
907908
908- static bool generate_version_file (void ) {
909+ static bool generate_version_file (br_str_t * out_hash ) {
909910 bool success = true;
910911 Nob_Cmd cmd = { 0 };
911912 br_str_t value1 = { 0 };
912- br_str_t value2 = { 0 };
913913 FILE * out_file = NULL ;
914914 bool rebuild = false;
915915
@@ -918,14 +918,14 @@ static bool generate_version_file(void) {
918918 if (false == cache .was_last_cached ) rebuild = true;
919919
920920 nob_cmd_append (& cmd , "git" , "rev-parse" , "HEAD" );
921- if (false == nob_cmd_run_sync_str_and_reset (".generated/temp2" , & cmd , & value2 )) BR_ERROR ("Failed to run a command" );
921+ if (false == nob_cmd_run_sync_str_and_reset (".generated/temp2" , & cmd , out_hash )) BR_ERROR ("Failed to run a command" );
922922 if (false == cache .was_last_cached ) rebuild = true;
923923
924924 if (rebuild ) {
925925 LOGI ("Rebuilding git version" );
926926 if (NULL == (out_file = fopen (".generated/br_version.h" , "wb" ))) BR_ERROR ("Failed to open file: %s" , strerror (errno ));
927927 fprintf (out_file , "#define BR_GIT_BRANCH \"%.*s\"\n" , value1 .len - 1 , value1 .str );
928- fprintf (out_file , "#define BR_GIT_HASH \"%.*s\"\n" , value2 . len - 1 , value2 . str );
928+ fprintf (out_file , "#define BR_GIT_HASH \"%.*s\"\n" , out_hash -> len - 1 , out_hash -> str );
929929 }
930930
931931 goto done ;
@@ -937,7 +937,6 @@ static bool generate_version_file(void) {
937937 if (NULL != out_file ) fclose (out_file );
938938 nob_cmd_free (cmd );
939939 br_str_free (value1 );
940- br_str_free (value2 );
941940 return success ;
942941}
943942
@@ -949,7 +948,8 @@ static bool n_generate_do(void) {
949948 if (false == gl_gen ()) return false;
950949 if (false == cat_files ((const char * []){"LICENSE" , "./external/LICENCES" }, 2 , ".generated/FULL_LICENSE" )) return false;
951950 if (false == embed_file_as_string (".generated/FULL_LICENSE" , "br_license" )) return false;
952- if (false == generate_version_file ()) return false;
951+ br_str_t out_hash = { 0 };
952+ if (false == generate_version_file (& out_hash )) return false;
953953 LOGI ("Generate OK" );
954954 return true;
955955}
@@ -1115,15 +1115,22 @@ static bool n_dist_do(void) {
11151115}
11161116
11171117static bool n_publish_do (void ) {
1118+ disable_logs = true;
1119+ is_debug = false;
11181120 if (false == n_unittests_do ()) return false;
11191121 if (false == n_dist_do ()) return false;
1122+ if (false == n_pip_do ()) return false;
1123+
11201124 Nob_Cmd cmd = { 0 };
11211125 nob_cmd_append (& cmd , "./tools/is_clean.sh" );
11221126 if (false == nob_cmd_run (& cmd ) && false == is_ignore_dirty ) LOGF ("Can't publish because the repo is not clean." );
11231127 nob_cmd_append (& cmd , "git" , "tag" , "v" BR_VERSION_STR );
11241128 if (false == nob_cmd_run (& cmd )) LOGF ("Can't publish because the version v" BR_VERSION_STR " is already publish. Increment the version in include/brplot.h:48" );
1125- nob_cmd_append (& cmd , "gh" , "release" , "create" , "-R" , "Bump." , "--target" , "v" BR_VERSION_STR , ".generated/brplot-v" BR_VERSION_STR ".tar.gz" , "--generate-notes" );
1129+ nob_cmd_append (& cmd , "gh" , "release" , "create" , "v" BR_VERSION_STR , "--target" , "master" , "--notes" , "Bump." , "--generate-notes" );
1130+ if (false == nob_cmd_run (& cmd )) LOGF ("Failed to publish.." );
1131+ nob_cmd_append (& cmd , "gh" , "release" , "upload" , "v" BR_VERSION_STR , ".generated/brplot-v" BR_VERSION_STR "/include/brplot.h" );
11261132 if (false == nob_cmd_run (& cmd )) LOGF ("Failed to publish.." );
1133+ if (false == n_aur_do ()) return false;
11271134 return true;
11281135}
11291136
@@ -1154,16 +1161,16 @@ static bool build_no_set(const char* file_name, int build_no) {
11541161
11551162static bool n_pip_do (void ) {
11561163 if (false == pip_skip_build ) {
1157- is_rebuild = true;
1164+ // is_rebuild = true;
11581165 is_debug = false;
11591166 disable_logs = true;
11601167 if (false == n_dist_do ()) return false;
11611168 if (false == nob_mkdir_if_not_exists ("packages/pip/src" )) return false;
11621169 if (false == nob_mkdir_if_not_exists ("packages/pip/src/brplot" )) return false;
11631170 Nob_String_Builder pytoml = { 0 };
1164- if (false == nob_copy_file (PSHARE " /licenses/brplot/LICENSE" , "packages/pip/LICENSE" )) return false;
1171+ if (false == nob_copy_file (".generated/brplot-v" BR_VERSION_STR "/share /licenses/brplot/LICENSE" , "packages/pip/LICENSE" )) return false;
11651172 if (false == nob_copy_file ("README.md" , "packages/pip/README.md" )) return false;
1166- if (false == nob_copy_file (".generated/brplot.h" , "packages/pip/src/brplot/brplot.h" )) return false;
1173+ if (false == nob_copy_file (".generated/brplot-v" BR_VERSION_STR "/include/brplot .h" , "packages/pip/src/brplot/brplot.h" )) return false;
11671174 if (false == nob_read_entire_file ("packages/pip/pyproject.toml.in" , & pytoml )) return false;
11681175 br_str_t out_toml = { .str = pytoml .items , .len = (uint32_t )pytoml .count , .cap = (uint32_t )pytoml .capacity };
11691176 br_str_t build_no_str = { 0 };
@@ -1182,6 +1189,59 @@ static bool n_pip_do(void) {
11821189 return nob_cmd_run_cache (& cmd );
11831190}
11841191
1192+ static bool n_aur_do (void ) {
1193+ Nob_Cmd cmd = { 0 };
1194+ Nob_String_Builder aur = { 0 };
1195+ br_str_t hash = { 0 };
1196+ if (false == generate_version_file (& hash )) return false;
1197+
1198+ if (false == nob_read_entire_file ("packages/aur/PKGBUILD" , & aur )) return false;
1199+ br_str_t aur_br_str = { .str = aur .items , .len = aur .count , .cap = aur .capacity };
1200+
1201+ if (false == br_str_replace_one1 (& aur_br_str , BR_STRL ("{VERSION}" ), BR_STRL (BR_VERSION_STR ))) return false;
1202+ if (false == br_str_replace_one1 (& aur_br_str , BR_STRL ("{VERSION}" ), BR_STRL (BR_VERSION_STR ))) return false;
1203+ if (false == br_str_replace_one1 (& aur_br_str , BR_STRL ("{HASH}" ), br_str_as_view (hash ))) return false;
1204+
1205+ nob_cmd_append (& cmd , "git" , "clone" , "ssh://aur@aur.archlinux.org/brplot-git.git" , "--" , "packages/aur/brplot-git" );
1206+ nob_cmd_run (& cmd );
1207+ nob_cmd_append (& cmd , "git" , "pull" , "ssh://aur@aur.archlinux.org/brplot-git.git" , "--" , "packages/aur/brplot-git" );
1208+ nob_cmd_run (& cmd );
1209+ if (false == nob_write_entire_file ("packages/aur/brplot-git/PKGBUILD" , aur_br_str .str , aur_br_str .len )) return false;
1210+
1211+ Nob_File_Paths children = { 0 };
1212+ nob_read_entire_dir ("packages/aur/brplot-git" , & children );
1213+ for (int i = 0 ; i < children .count ; ++ i ) {
1214+ if (NULL != strstr (children .items [i ], ".zst" )) {
1215+ nob_delete_file (nob_temp_sprintf ("packages/aur/brplot-git/%s" , children .items [i ]));
1216+ }
1217+ }
1218+ nob_da_free (children );
1219+
1220+ nob_cmd_append (& cmd , "namcap" , "packages/aur/brplot-git/PKGBUILD" );
1221+ if (false == nob_cmd_run (& cmd )) return false;
1222+
1223+ nob_cmd_append (& cmd , "makepkg" , "-D" , "packages/aur/brplot-git" , "-si" );
1224+ if (false == nob_cmd_run (& cmd )) return false;
1225+ return false;
1226+
1227+ nob_cmd_append (& cmd , "namcap" , "packages/aur/brplot-git/*.zst" );
1228+ if (false == nob_cmd_run (& cmd )) return false;
1229+
1230+ nob_cmd_append (& cmd , "makepkg" , "-D" , "packages/aur/brplot-git/" , "--printsrcinfo" );
1231+ if (false == nob_cmd_run (& cmd , .stdout_path = "packages/aur/brplot-git/.SRCINFO" )) return false;
1232+
1233+ nob_cmd_append (& cmd , "git" , "add" , "PKGBUILD" , ".SRCINFO" , "--" , "packages/aur/brplot-git/" );
1234+ if (false == nob_cmd_run (& cmd )) return false;
1235+
1236+ nob_cmd_append (& cmd , "git" , "commit" , "-m" , "Vesion bump." , "--" , "packages/aur/brplot-git/" );
1237+ if (false == nob_cmd_run (& cmd )) return false;
1238+
1239+ nob_cmd_append (& cmd , "git" , "push" , "origin" , "master" , "--" , "packages/aur/brplot-git/" );
1240+ if (false == nob_cmd_run (& cmd )) return false;
1241+
1242+ return true;
1243+ }
1244+
11851245static bool n_unittests_do (void ) {
11861246 if (false == n_generate_do ()) return false;
11871247
0 commit comments