forked from github/spec-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (78 loc) · 3.48 KB
/
release.yml
File metadata and controls
84 lines (78 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Create Release
on:
push:
branches: [ main ]
paths:
- 'memory/**'
- 'scripts/**'
- 'templates/**'
- '.github/workflows/**'
workflow_dispatch:
inputs:
release_version:
description: 'Optional release version (e.g., 1.4.6 or v1.4.6). If omitted, workflow auto-selects.'
required: false
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get latest tag
id: get_tag
run: |
chmod +x .github/workflows/scripts/get-next-version.sh
.github/workflows/scripts/get-next-version.sh "${{ github.event.inputs.release_version || '' }}"
- name: Skip if nothing to release
if: steps.get_tag.outputs.skip_release == 'true'
run: |
echo "::notice::pyproject.toml version is already tagged. No release needed for this push."
- name: Validate release version matches pyproject.toml
if: steps.get_tag.outputs.skip_release != 'true'
run: |
pyproject_version=$(grep -oE '^[[:space:]]*version[[:space:]]*=[[:space:]]*"[0-9]+\.[0-9]+\.[0-9]+"' pyproject.toml | head -n1 | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+)"/\1/')
if [ -z "$pyproject_version" ]; then
echo "Unable to read version from pyproject.toml"
exit 1
fi
release_version="${{ steps.get_tag.outputs.new_version }}"
release_version="${release_version#v}"
if [ "$pyproject_version" != "$release_version" ]; then
echo "Version mismatch: pyproject.toml=$pyproject_version release=$release_version"
echo "Update pyproject.toml before creating a release to keep Spec Kit Spark and Specify CLI in sync."
exit 1
fi
echo "Version parity check passed: $release_version"
- name: Check if release already exists
if: steps.get_tag.outputs.skip_release != 'true'
id: check_release
run: |
chmod +x .github/workflows/scripts/check-release-exists.sh
.github/workflows/scripts/check-release-exists.sh ${{ steps.get_tag.outputs.new_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release package variants
if: steps.get_tag.outputs.skip_release != 'true' && steps.check_release.outputs.exists == 'false'
run: |
chmod +x .github/workflows/scripts/create-release-packages.sh
.github/workflows/scripts/create-release-packages.sh ${{ steps.get_tag.outputs.new_version }}
- name: Generate release notes
if: steps.get_tag.outputs.skip_release != 'true' && steps.check_release.outputs.exists == 'false'
id: release_notes
run: |
chmod +x .github/workflows/scripts/generate-release-notes.sh
.github/workflows/scripts/generate-release-notes.sh ${{ steps.get_tag.outputs.new_version }} ${{ steps.get_tag.outputs.latest_tag }}
- name: Create GitHub Release
if: steps.get_tag.outputs.skip_release != 'true' && steps.check_release.outputs.exists == 'false'
run: |
chmod +x .github/workflows/scripts/create-github-release.sh
.github/workflows/scripts/create-github-release.sh ${{ steps.get_tag.outputs.new_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}