-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (84 loc) · 3.17 KB
/
release.yml
File metadata and controls
98 lines (84 loc) · 3.17 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
name: Create Release with OpenAPI Specs
on:
push:
tags:
- 'v*.*.*'
- 'v*.*.*-**'
workflow_dispatch:
inputs:
version:
description: 'Version tag to create release (e.g., v1.2.3 or v1.2.3-rc1)'
required: true
type: string
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version tag
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
# Allow hyphenated prerelease suffix (e.g., -rc1, -beta.2)
if [[ ! "$VERSION" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z\.-]+)?$ ]]; then
echo "::error::Invalid version format: $VERSION. Expected: v1.2.3 or v1.2.3-rc1"
exit 1
fi
# Ensure v prefix
if [[ ! "$VERSION" =~ ^v ]]; then
VERSION="v${VERSION}"
fi
# Any hyphen → prerelease
if [[ "$VERSION" == *-* ]]; then
IS_PRERELEASE=true
else
IS_PRERELEASE=false
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
echo "Using version: $VERSION (prerelease=$IS_PRERELEASE)"
- name: Verify OpenAPI files exist
run: |
if [ ! -f "openapi.yaml" ]; then
echo "::error::openapi.yaml not found in repository root"
exit 1
fi
if [ ! -f "openapi.json" ]; then
echo "::error::openapi.json not found in repository root"
exit 1
fi
echo "✓ OpenAPI files found"
- name: Prepare release assets with version
run: |
VERSION="${{ steps.version.outputs.version }}"
cp openapi.yaml "stayforge-api-${VERSION}-openapi.yaml"
cp openapi.json "stayforge-api-${VERSION}-openapi.json"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.version }}
name: "Stayforge API ${{ steps.version.outputs.version }}"
body: |
## Stayforge API OpenAPI Specification
This release contains the OpenAPI specification for Stayforge API version **${{ steps.version.outputs.version }}**.
### Files
- `stayforge-api-${{ steps.version.outputs.version }}-openapi.yaml`
- `stayforge-api-${{ steps.version.outputs.version }}-openapi.json`
### Version History
Historical versions are available in the `versions/` directory.
files: |
stayforge-api-${{ steps.version.outputs.version }}-openapi.yaml
stayforge-api-${{ steps.version.outputs.version }}-openapi.json
draft: false
prerelease: ${{ steps.version.outputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}