|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + |
| 7 | +concurrency: |
| 8 | + group: release |
| 9 | + cancel-in-progress: false |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + name: Release (on push to main) |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Compute next tag |
| 24 | + id: version |
| 25 | + shell: bash |
| 26 | + run: | |
| 27 | + set -euo pipefail |
| 28 | + latest_tag="$(git tag --list --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)" |
| 29 | + if [[ -z "${latest_tag}" ]]; then |
| 30 | + next_tag="1.0.0" |
| 31 | + else |
| 32 | + IFS='.' read -r major minor patch <<< "${latest_tag}" |
| 33 | + patch=$((patch + 1)) |
| 34 | + next_tag="${major}.${minor}.${patch}" |
| 35 | + fi |
| 36 | + echo "next_tag=${next_tag}" >> "${GITHUB_OUTPUT}" |
| 37 | +
|
| 38 | + - name: Package skill artifact |
| 39 | + shell: bash |
| 40 | + run: | |
| 41 | + set -euo pipefail |
| 42 | + python3 - <<'PY' |
| 43 | + from pathlib import Path |
| 44 | + import zipfile |
| 45 | + import sys |
| 46 | +
|
| 47 | + skill_path = Path("skills/STFilePath").resolve() |
| 48 | + out_dir = Path("skills/dist").resolve() |
| 49 | + skill_md = skill_path / "SKILL.md" |
| 50 | +
|
| 51 | + if not skill_md.exists(): |
| 52 | + print(f"[ERROR] SKILL.md not found at {skill_md}") |
| 53 | + sys.exit(1) |
| 54 | +
|
| 55 | + lines = skill_md.read_text(encoding="utf-8").lstrip("\ufeff").splitlines() |
| 56 | + if not lines or lines[0].strip() != "---": |
| 57 | + print("[ERROR] Missing YAML frontmatter in SKILL.md (no opening ---)") |
| 58 | + sys.exit(1) |
| 59 | + try: |
| 60 | + end_index = lines.index("---", 1) |
| 61 | + except ValueError: |
| 62 | + print("[ERROR] Missing YAML frontmatter in SKILL.md (no closing ---)") |
| 63 | + sys.exit(1) |
| 64 | +
|
| 65 | + frontmatter = lines[1:end_index] |
| 66 | + def get_field(name: str): |
| 67 | + prefix = f"{name}:" |
| 68 | + for line in frontmatter: |
| 69 | + if line.strip().startswith(prefix): |
| 70 | + return line.split(":", 1)[1].strip().strip('"').strip("'") |
| 71 | + return None |
| 72 | +
|
| 73 | + name = get_field("name") |
| 74 | + description = get_field("description") |
| 75 | + if not name or not description: |
| 76 | + print("[ERROR] SKILL.md frontmatter must include name and description") |
| 77 | + sys.exit(1) |
| 78 | +
|
| 79 | + out_dir.mkdir(parents=True, exist_ok=True) |
| 80 | + skill_filename = out_dir / f"{skill_path.name}.skill" |
| 81 | + skip_names = {".DS_Store"} |
| 82 | +
|
| 83 | + with zipfile.ZipFile(skill_filename, "w", zipfile.ZIP_DEFLATED) as zipf: |
| 84 | + for file_path in skill_path.rglob("*"): |
| 85 | + if file_path.is_file(): |
| 86 | + if file_path.name in skip_names: |
| 87 | + continue |
| 88 | + if any(part in ("__MACOSX",) for part in file_path.parts): |
| 89 | + continue |
| 90 | + arcname = file_path.relative_to(skill_path.parent) |
| 91 | + zipf.write(file_path, arcname) |
| 92 | + print(f" Added: {arcname}") |
| 93 | +
|
| 94 | + print(f"\n[OK] Successfully packaged skill to: {skill_filename}") |
| 95 | + PY |
| 96 | +
|
| 97 | + - name: Create GitHub Release |
| 98 | + uses: softprops/action-gh-release@v2 |
| 99 | + with: |
| 100 | + tag_name: ${{ steps.version.outputs.next_tag }} |
| 101 | + name: Release ${{ steps.version.outputs.next_tag }} |
| 102 | + generate_release_notes: true |
| 103 | + files: | |
| 104 | + skills/dist/STFilePath.skill |
0 commit comments