diff --git a/.github/workflows/server-image.yml b/.github/workflows/server-image.yml index 8176cbcf..c8430762 100644 --- a/.github/workflows/server-image.yml +++ b/.github/workflows/server-image.yml @@ -141,8 +141,8 @@ jobs: steps: - name: Isolate logs, safe metadata and ephemeral auth run: | - printf 'METADATA_DIR=%s/server-image-metadata\nRESULTS=%s/server-image-results\nDOCKER_CONFIG=%s/server-image-auth\n' \ - "$RUNNER_TEMP" "$RUNNER_TEMP" "$RUNNER_TEMP" >> "$GITHUB_ENV" + printf 'METADATA_DIR=%s/server-image-metadata\nRESULTS=%s/server-image-results\nDOCKER_CONFIG=%s/server-image-auth\nRELEASE_POLICY=%s/release-policy/server_image_release.py\n' \ + "$RUNNER_TEMP" "$RUNNER_TEMP" "$RUNNER_TEMP" "$RUNNER_TEMP" >> "$GITHUB_ENV" - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: ref: master @@ -153,6 +153,10 @@ jobs: env: TAG: ${{ github.event.release.tag_name || inputs.tag }} run: python3 scripts/server_image_release.py source + - name: Keep master's publication policy (an older tag's helper must not decide visibility) + run: | + mkdir -p "$(dirname "$RELEASE_POLICY")" + cp scripts/server_image_release.py "$RELEASE_POLICY" - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: ref: ${{ steps.source.outputs.source_sha }} @@ -203,7 +207,7 @@ jobs: - name: Refuse unknown visibility, wrong association, and both existing tags env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: python3 scripts/server_image_release.py preflight + run: python3 "$RELEASE_POLICY" preflight - name: Login and publish only the two immutable tags (no rebuild) env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -219,7 +223,7 @@ jobs: id: readback env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: python3 scripts/server_image_release.py readback + run: python3 "$RELEASE_POLICY" readback - name: Remove ephemeral Docker credentials if: always() run: rm -rf -- "$DOCKER_CONFIG" diff --git a/docs/releasing.md b/docs/releasing.md index 8a5402db..9ef326d3 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -97,7 +97,10 @@ anyone may pull the image without a GitHub login. Publishing it does not make a server reachable; the server has no authentication and stays on a trusted LAN (see [nest storage](nest-storage.md#deploying-with-compose)). -The job uses only its scoped `GITHUB_TOKEN`. An existing package must be public +The job builds, tests and smokes the tag's own tree, but the publication policy +(preflight before upload and readback after it) always comes from `master`'s copy +of `scripts/server_image_release.py`, so an older tag publishes under the current +policy. The job uses only its scoped `GITHUB_TOKEN`. An existing package must be public and linked to `ajisaacs/OpenNest`; a private package or one linked to another repository stops the job before upload. The first publication creates the package: GitHub's own `Not Found` package response is accepted only when the diff --git a/scripts/test_server_image_release.py b/scripts/test_server_image_release.py index 93c92b95..184f76b2 100644 --- a/scripts/test_server_image_release.py +++ b/scripts/test_server_image_release.py @@ -724,6 +724,20 @@ class WorkflowBehavior(unittest.TestCase): self.assertNotIn("'release'", condition) self.assertIn("github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master'", condition) + def test_publication_policy_comes_from_master_not_the_tagged_tree(self): + # The tag's tree is built and tested, but an older tag's helper must not + # decide package visibility: preflight and readback run master's copy. + workflow = pathlib.Path(__file__).resolve().parents[1] / ".github/workflows/server-image.yml" + publish = workflow.read_text().split("\n publish:\n", 1)[1].split("\n verify-published:\n", 1)[0] + source = publish.index("server_image_release.py source") + copy = publish.index('cp scripts/server_image_release.py "$RELEASE_POLICY"') + tag_checkout = publish.index("ref: ${{ steps.source.outputs.source_sha }}") + self.assertLess(source, copy) + self.assertLess(copy, tag_checkout) + for operation in ("preflight", "readback"): + self.assertIn('python3 "$RELEASE_POLICY" ' + operation, publish) + self.assertNotIn("scripts/server_image_release.py " + operation, publish) + def test_build_log_pipeline_preserves_docker_failure(self): workflow = pathlib.Path(__file__).resolve().parents[1] / ".github/workflows/server-image.yml" lines = workflow.read_text().splitlines()