feat: allow a custom draft release tag prefix (#159)

This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-06 16:06:01 -05:00
1 parent 91428662bf
commit dd3d987521
2 files changed
+38 -1

No files matched your search

+5 -1
View File
@@ -15,6 +15,9 @@ inputs:
github-token:
description: "GitHub token for authenticating gh CLI"
required: true
tag-prefix:
description: "Release tag prefix"
default: "v"
signing-key:
description: "ASCII-armored OpenPGP secret key (LINUX_SIGNING_KEY) that signs the Linux packages and SHA256SUMS.txt; empty publishes them unsigned"
required: false
@@ -72,13 +75,14 @@ runs:
shell: bash
working-directory: artifacts
env:
TAG_PREFIX: ${{ inputs.tag-prefix }}
VERSION: ${{ inputs.version }}
APP_TITLE: ${{ inputs.app-title }}
PRERELEASE: ${{ inputs.prerelease }}
GH_TOKEN: ${{ inputs.github-token }}
GH_REPO: ${{ github.repository }}
run: |
tag="v$VERSION"
tag="${TAG_PREFIX}$VERSION"
title="$APP_TITLE v$VERSION"
pre=()
if [ "$PRERELEASE" = "true" ]; then pre=(--prerelease); fi
+33
View File
@@ -0,0 +1,33 @@
"""Exercise draft release tag selection without contacting GitHub."""
import json
import os
from pathlib import Path
import subprocess
import tempfile
import unittest
import yaml
class ReleaseTagPrefixTests(unittest.TestCase):
def test_default_and_custom_tags(self):
action = yaml.load(
(Path(__file__).resolve().parents[1] / "actions/draft-release/action.yml").read_text(),
Loader=yaml.BaseLoader,
)
step = next(s for s in action["runs"]["steps"] if s["name"] == "Create or update draft release")
self.assertEqual(step["env"]["TAG_PREFIX"], "${{ inputs.tag-prefix }}")
for prefix in (action["inputs"]["tag-prefix"]["default"], "artcraft-linux-v"):
with self.subTest(prefix=prefix), tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
gh = root / "gh"
gh.write_text('#!/usr/bin/env python3\nimport json,sys\nfrom pathlib import Path\nwith Path("calls").open("a") as f: f.write(json.dumps(sys.argv[1:])+"\\n")\nsys.exit(1 if sys.argv[1:3] == ["release", "view"] else 0)\n')
gh.chmod(0o755)
(root / "SHA256SUMS.txt").write_text("checksum package.deb\n")
subprocess.run(["bash", "-e", "-c", step["run"]], cwd=root, check=True,
capture_output=True, env=dict(os.environ, PATH=f"{root}:{os.environ['PATH']}",
TAG_PREFIX=prefix, VERSION="0.42.0", APP_TITLE="Studio", PRERELEASE="false",
GITHUB_SHA="a" * 40, GITHUB_STEP_SUMMARY=str(root / "summary")))
calls = [json.loads(line) for line in (root / "calls").read_text().splitlines()]
self.assertEqual(calls[0][:3], ["release", "view", prefix + "0.42.0"])
self.assertEqual(calls[1][:3], ["release", "create", prefix + "0.42.0"])