-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (135 loc) Β· 5.33 KB
/
release.yml
File metadata and controls
159 lines (135 loc) Β· 5.33 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Release
on:
push:
tags:
- 'v*.*.*'
- 'v*.*.*-*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.2.3)'
required: true
type: string
prerelease:
description: 'Mark as pre-release'
required: false
type: boolean
default: false
permissions:
contents: write
discussions: write
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
is_prerelease: ${{ steps.version.outputs.is_prerelease }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version information
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.version }}"
IS_PRERELEASE="${{ github.event.inputs.prerelease }}"
else
TAG="${{ github.ref_name }}"
# Check if tag contains pre-release identifiers
if [[ "$TAG" == *"-"* ]]; then
IS_PRERELEASE=true
else
IS_PRERELEASE=false
fi
fi
VERSION=${TAG#v} # Remove 'v' prefix
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
echo "π·οΈ Tag: $TAG"
echo "π¦ Version: $VERSION"
echo "π§ͺ Pre-release: $IS_PRERELEASE"
- name: Validate version format
run: |
VERSION="${{ steps.version.outputs.version }}"
# Basic SemVer validation
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(\-[0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*)?(\+[0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*)?$'; then
echo "β Invalid version format: $VERSION"
echo "Version must follow Semantic Versioning 2.0.0"
exit 1
fi
echo "β
Version format is valid"
- name: Generate release notes
id: release_notes
run: |
TAG="${{ steps.version.outputs.tag }}"
VERSION="${{ steps.version.outputs.version }}"
# Get the previous tag for changelog
PREV_TAG=$(git tag --sort=-version:refname | grep -v "$TAG" | head -n1 || echo "")
# Create release notes
cat > release_notes.md << EOF
## π₯ Quick Installation
\`\`\`bash
# Download directly to your project
curl -o cmake/GitVersion.cmake https://github.com/tayne3/GitVersion.cmake/releases/download/$TAG/GitVersion.cmake
\`\`\`
## π Usage
\`\`\`cmake
include(cmake/GitVersion.cmake)
git_version_info(VERSION PROJECT_VERSION)
project(MyProject VERSION \${PROJECT_VERSION})
\`\`\`
## π Documentation
EOF
echo "For complete usage instructions and examples, see the [README](https://github.com/tayne3/GitVersion.cmake#readme)." >> release_notes.md
echo "Generated release notes:"
cat release_notes.md
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.tag }}
release_name: v${{ steps.version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: ${{ steps.version.outputs.is_prerelease }}
- name: Upload GitVersion.cmake
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: cmake/GitVersion.cmake
asset_name: GitVersion.cmake
asset_content_type: text/plain
update-badges:
name: Update Repository Badges
needs: create-release
runs-on: ubuntu-latest
if: ${{ !needs.create-release.outputs.is_prerelease }}
timeout-minutes: 5
steps:
- name: Update release badge cache
run: |
# Trigger shield.io cache refresh for release badge
curl -X POST "https://img.shields.io/github/v/release/tayne3/GitVersion.cmake?include_prereleases&label=release&logo=github&logoColor=white"
echo "π Badge cache refresh triggered"
notify-success:
name: Notify Release Success
needs: [create-release]
runs-on: ubuntu-latest
if: success()
timeout-minutes: 2
steps:
- name: Success notification
run: |
echo "π Successfully released GitVersion.cmake ${{ needs.create-release.outputs.version }}"
echo "π¦ Download URL: https://github.com/tayne3/GitVersion.cmake/releases/download/${{ needs.create-release.outputs.tag }}/GitVersion.cmake"
echo "π Release page: https://github.com/tayne3/GitVersion.cmake/releases/tag/${{ needs.create-release.outputs.tag }}"