-
Notifications
You must be signed in to change notification settings - Fork 14
92 lines (81 loc) · 2.63 KB
/
release.yml
File metadata and controls
92 lines (81 loc) · 2.63 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
name: Create Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Extract version
id: version
run: |
VERSION=$(grep -oP '(?<=version: ")[^"]+' main.tsp)
if [ -z "$VERSION" ]; then
echo "::error::Failed to extract version from main.tsp — check the @info decorator format" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Check if release already exists
id: check_tag
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
git fetch --tags
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists — skipping release"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Build all schemas
if: steps.check_tag.outputs.skip == 'false'
run: |
./build-schema.sh core
./build-schema.sh core --swagger
./build-schema.sh gcp
./build-schema.sh gcp --swagger
- name: Prepare release assets
if: steps.check_tag.outputs.skip == 'false'
run: |
cp schemas/core/openapi.yaml core-openapi.yaml
cp schemas/core/swagger.yaml core-swagger.yaml
cp schemas/gcp/openapi.yaml gcp-openapi.yaml
cp schemas/gcp/swagger.yaml gcp-swagger.yaml
- name: Create release tag
if: steps.check_tag.outputs.skip == 'false'
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
- name: Create GitHub Release
if: steps.check_tag.outputs.skip == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
generate_release_notes: true
draft: false
prerelease: false
files: |
core-openapi.yaml
core-swagger.yaml
gcp-openapi.yaml
gcp-swagger.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}