The book of Maccabees (1:2:31-41) tells the story of how the Hasmoneans originally refused to wage war on Shabbos and were slaughtered. After that, Matisyahu ruled that they must fight back on Shabbos. This account is repeated by Josephus (Antiquities 12:276). Prof. Louis Feldman (Jew & Gentile in the Ancient World, pp. 160-161) lists other ancient attestations to this refusal to fight on Shabbos, such as Strabo (16:2:40:763) and Dio Cassius (37:16). The question is why they refused. Isn’t it piku’ach nefesh?
R. Shlomo Goren (Meshiv Milchamah 1:2) addresses this question. He suggests that the Greeks knew how important Shabbos was to Jews and wished to force them to fight on that day. Thus, there was a shmad-gezerah specifically to fight on Shabbos and, therefore, the Hasmonean beis din ruled that it is yehareg ve-al ya’avor — when gentiles try to force us to violate a law we must choose martyrdom over violating it. In this case, they tried to force us to fight on Shabbos and the Hasmoneans chose martyrdom over violating Shabbos.
If that’s the case, then why did the beis din subsequently rule that they may fight back? When the Greeks continued this strategy and it became a threat to the
continuity of the Jewish people, the Hasmonean beis din ruled that the continuity of the Jewish people overrides the law of yehareg ve-al ya’avor and they may not choose martyrdom.