-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (74 loc) · 2.34 KB
/
Copy pathrelease.yml
File metadata and controls
87 lines (74 loc) · 2.34 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
84
85
86
87
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (example: v1.2.3)"
required: true
type: string
permissions:
contents: write
concurrency:
group: release-${{ github.ref_name || inputs.tag }}
cancel-in-progress: false
jobs:
publish-release:
name: Publish GitHub Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve and validate release tag
id: tag
shell: bash
run: |
git fetch --force --tags origin
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAG="${{ inputs.tag }}"
else
TAG="${{ github.ref_name }}"
fi
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.]+)?$ ]]; then
echo "Invalid release tag: $TAG"
exit 1
fi
git rev-parse "$TAG" >/dev/null 2>&1
echo "value=$TAG" >> "$GITHUB_OUTPUT"
- name: Generate release notes
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
RELEASE_NOTES_MODEL: ${{ secrets.RELEASE_NOTES_MODEL }}
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
run: |
export RELEASE_NOTES_MODEL="${RELEASE_NOTES_MODEL:-gpt-4o-mini}"
export OPENAI_BASE_URL="${OPENAI_BASE_URL:-https://api.openai.com/v1/chat/completions}"
python3 scripts/generate_release_notes.py \
--tag "${{ steps.tag.outputs.value }}" \
--output ".github/release-notes.md"
- name: Create or update GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.tag.outputs.value }}
shell: bash
run: |
title="$TAG"
prerelease=""
if [[ "$TAG" == *-* ]]; then
prerelease="--prerelease"
fi
if gh release view "$TAG" >/dev/null 2>&1; then
gh release edit "$TAG" \
--title "$title" \
--notes-file ".github/release-notes.md"
else
gh release create "$TAG" \
--title "$title" \
--verify-tag \
--notes-file ".github/release-notes.md" \
$prerelease
fi