diff --git a/.github/workflows/publish-pal.yml b/.github/workflows/publish-pal.yml index a108cfd9c..d2ce182c3 100644 --- a/.github/workflows/publish-pal.yml +++ b/.github/workflows/publish-pal.yml @@ -203,7 +203,8 @@ jobs: # that AltStore.json on main lists the same build (D-26). The release must exist already: the tool finds it # by the version's tag and never creates one (D-19). The permissions come from the project, never from the # encrypted variants (owner decision, 20-08): each bundle's CODE_SIGN_ENTITLEMENTS and INFOPLIST_FILE, held to - # project.pbxproj by test_workflows.py. + # project.pbxproj by test_workflows.py. The runner's /bin/bash is 3.2, where an empty array under `set -u` is + # unbound, so the dry-run flag expands only when it is set. python3 "$PAL_PUBLISH_TOOL_PATH" publish \ --adp "$RUNNER_TEMP/adp" \ --repo "$GITHUB_REPOSITORY" \ @@ -213,7 +214,7 @@ jobs: --info-plist App/Info.plist \ --info-plist ShareExtension/Info.plist \ --work "$RUNNER_TEMP/pal-publish" \ - "${dry_run[@]}" + ${dry_run[@]+"${dry_run[@]}"} { if [[ "$DRY_RUN" != "false" ]]; then echo "### AltStore PAL $VERSION: dry run" diff --git a/actions-tool/tests/test_workflows.py b/actions-tool/tests/test_workflows.py index a8419b39e..0dc22ea2f 100644 --- a/actions-tool/tests/test_workflows.py +++ b/actions-tool/tests/test_workflows.py @@ -1418,6 +1418,32 @@ def test_dry_run_is_passed_through(self): self.assertRegex(self.run_text(self.job, "Publish to AltStore PAL"), r'"\$DRY_RUN" (==|!=) "?(true|false)"?') self.assertNotIn("dry_run", json.dumps(self.process)) + def test_the_publish_step_runs_in_the_runners_bash_with_and_without_dry_run(self): + # The macOS runner's /bin/bash is 3.2, where "${array[@]}" of an empty array under `set -u` stops the step + # with "unbound variable" before the tool runs: the 3.1.0 publish with dry_run off failed that way. + step = step_named(self.job, "Publish to AltStore PAL") + bash = "/bin/bash" if pathlib.Path("/bin/bash").exists() else shutil.which("bash") + with tempfile.TemporaryDirectory() as directory: + folder = pathlib.Path(directory) + tool = folder / "pal_publish.py" + arguments = folder / "arguments.json" + tool.write_text("import json, sys\n" + f"open({str(arguments)!r}, 'w').write(json.dumps(sys.argv[1:]))\n", encoding="utf-8") + for dry_run, expected in (("false", False), ("true", True)): + with self.subTest(dry_run=dry_run): + summary = folder / f"summary-{dry_run}.md" + result = subprocess.run( + [bash, "-e", "-c", step["run"]], capture_output=True, text=True, timeout=30, + env={"PATH": os.environ.get("PATH", ""), "PAL_PUBLISH_TOOL_PATH": str(tool), + "RUNNER_TEMP": str(folder), "GITHUB_REPOSITORY": "EhPanda-Team/EhPanda", + "RELEASE_NOTES_DIR": "./ReleaseNotes", "MARKETPLACE_ID": "1", "ADP_ID": "adp", + "VERSION": "3.1.0", "DRY_RUN": dry_run, "GITHUB_STEP_SUMMARY": str(summary)}) + self.assertEqual(result.returncode, 0, result.stderr) + passed = json.loads(arguments.read_text(encoding="utf-8")) + self.assertEqual(passed[0], "publish") + self.assertEqual("--dry-run" in passed, expected) + self.assertIn("dry run" if expected else "published", summary.read_text(encoding="utf-8")) + def test_gh_gets_the_job_token_only(self): step = step_named(self.job, "Publish to AltStore PAL") self.assertEqual(step["env"]["GH_TOKEN"], "${{ github.token }}")