Skip to content

Commit 487d9a9

Browse files
authored
refactor: centralize release-tool version pin
Centralize the default release-tool PHAR version inside setup-release-tool, keep version as an optional override, remove stale internal pins, and preserve checksum verification. Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent fa74ed8 commit 487d9a9

7 files changed

Lines changed: 29 additions & 10 deletions

File tree

‎actions/release-plan/action.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ runs:
6161
- id: setup
6262
name: Setup release-tool
6363
uses: $/actions/setup-release-tool
64-
with:
65-
version: '0.2.0'
6664

6765
- id: plan
6866
name: Build ReleasePlan v1

‎actions/setup-release-tool/action.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ name: Setup release-tool
55
description: Install an exact LibreCode release-tool PHAR release and verify its published SHA-256.
66
inputs:
77
version:
8-
description: Exact release-tool semantic version, without a leading v.
9-
required: true
8+
description: Optional exact release-tool semantic version override, without a leading v.
9+
required: false
10+
default: ''
1011
outputs:
1112
path:
1213
description: Absolute path to the verified release-tool PHAR.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.5.0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
SPDX-License-Identifier: AGPL-3.0-or-later

‎actions/setup-release-tool/setup.sh‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
set -euo pipefail
66

7-
version="${RELEASE_TOOL_VERSION:?release-tool version is required}"
7+
version="${RELEASE_TOOL_VERSION:-}"
8+
if [[ -z "${version}" ]]; then
9+
version_file="${GITHUB_ACTION_PATH:?github action path is required}/release-tool-version"
10+
version="$(tr -d '[:space:]' < "${version_file}")"
11+
fi
812

913
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
1014
echo "::error::release-tool version must be an exact semantic version, got '${version}'"

‎tests/test_release_plan_action.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_action_uses_exact_verified_release_tool(self) -> None:
1414
content = ACTION.read_text(encoding="utf-8")
1515

1616
self.assertIn("uses: $/actions/setup-release-tool", content)
17-
self.assertIn("version: '0.2.0'", content)
17+
self.assertNotIn("with:\n version:", content)
1818
self.assertIn("release:plan", content)
1919
self.assertIn("--release-version", content)
2020
self.assertNotIn("python3", content)

‎tests/test_setup_release_tool_action.py‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
ROOT = Path(__file__).resolve().parents[1]
1111
SCRIPT = ROOT / "actions" / "setup-release-tool" / "setup.sh"
1212
ACTION = ROOT / "actions" / "setup-release-tool" / "action.yml"
13+
VERSION = ROOT / "actions" / "setup-release-tool" / "release-tool-version"
1314

1415

1516
class SetupReleaseToolActionTest(unittest.TestCase):
1617
def run_script(
1718
self,
18-
version: str,
19+
version: str | None,
1920
*,
2021
fake_download: bool = False,
2122
checksum_mismatch: bool = False,
@@ -26,12 +27,15 @@ def run_script(
2627
output = root / "output"
2728
path_file = root / "path"
2829
env = os.environ | {
29-
"RELEASE_TOOL_VERSION": version,
30+
"GITHUB_ACTION_PATH": str(SCRIPT.parent),
3031
"RUNNER_TEMP": str(root),
3132
"GITHUB_OUTPUT": str(output),
3233
"GITHUB_PATH": str(path_file),
3334
}
3435

36+
if version is not None:
37+
env["RELEASE_TOOL_VERSION"] = version
38+
3539
if fake_download:
3640
fake_bin = root / "bin"
3741
fake_bin.mkdir()
@@ -87,13 +91,21 @@ def run_script(
8791
path_file.read_text(encoding="utf-8") if path_file.exists() else "",
8892
)
8993

90-
def test_action_exposes_only_exact_version_input(self) -> None:
94+
def test_action_exposes_optional_exact_version_override(self) -> None:
9195
content = ACTION.read_text(encoding="utf-8")
9296

9397
self.assertIn("version:", content)
94-
self.assertNotIn("latest", content.lower())
98+
self.assertIn("required: false", content)
99+
self.assertIn("default: ''", content)
95100
self.assertIn("setup.sh", content)
96101

102+
def test_default_version_is_centralized_in_action_directory(self) -> None:
103+
result, output, path_file = self.run_script(None, fake_download=True)
104+
105+
self.assertEqual(0, result.returncode, result.stderr)
106+
self.assertIn("version=0.5.0", output)
107+
self.assertIn("librecode-release-tool/0.5.0", path_file)
108+
97109
def test_rejects_latest_before_network_access(self) -> None:
98110
result, _, _ = self.run_script("latest")
99111

@@ -141,6 +153,7 @@ def test_script_downloads_phar_and_published_checksum_from_same_exact_tag(self)
141153
self.assertIn("releases/download/v${version}", content)
142154
self.assertIn("release-tool.phar.sha256", content)
143155
self.assertIn("sha256sum", content)
156+
self.assertEqual("0.5.0", VERSION.read_text(encoding="utf-8").strip())
144157

145158

146159
if __name__ == "__main__":

0 commit comments

Comments
 (0)