598. Under Siege

Shabbos 2:23

If non-Jews attack a Jewish city on Shabbos, if their intention is mere financial profit, Shabbos is not violated and we do not go to war against them. If the city is located near the border (so that it is a security issue), we march against them with weapons and fight even if all they demand is hay or straw. If their intention is to kill, or if they engage a city in battle without specifying their intentions, we go to war against them and Shabbos is violated because of them. It is a mitzvah for every able-bodied Jew to go to the aid of their brethren who are in battle and to save them on Shabbos; one may not delay until Saturday night. After saving their brethren, they may return to their homes on Shabbos with their weapons so that they should not be unarmed prey for their enemies.

Shabbos 2:24                                     

Similarly, if a ship is sinking on Shabbos, or a city is threatened by a flood, it is a mitzvah to go on Shabbos and to use every means possible to save the victims. Even if one person is being pursued by enemies, a snake, or a bear intending to kill him, it is a mitzvah to save him, even though doing so may necessitate performing several different types of labors. It is even permitted to forge weapons for the purpose. Similarly, we should call out to God (such supplications normally being prohibited on Shabbos) and sound trumpets to summon help. We do not call out to God on Shabbos because of a plague.