Skip to content

Commit 6fbda95

Browse files
committed
feat: add GitHub workflows for release and schema generation
- Introduced a release workflow that automates the bundling of OpenAPI specifications and uploads them as release assets. - Added a schema generation workflow that validates and promotes TypeSpec schemas, ensuring they are generated correctly and uploaded as artifacts.
1 parent 103df1d commit 6fbda95

2 files changed

Lines changed: 186 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Release and Bundle
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags: [ 'v*' ]
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '18'
20+
cache: 'npm'
21+
cache-dependency-path: data_models/package-lock.json
22+
23+
- name: Install TypeSpec dependencies
24+
run: |
25+
cd data_models
26+
npm ci
27+
28+
- name: Install Redocly CLI
29+
run: npm install -g @redocly/cli
30+
31+
- name: Generate TypeSpec schemas
32+
run: |
33+
cd data_models
34+
npx tsp compile . --emit=@typespec/json-schema
35+
chmod +x promote.sh
36+
./promote.sh
37+
38+
- name: Bundle OpenAPI v5 specification
39+
run: |
40+
redocly bundle v5.yaml -o v5-bundled.yaml
41+
42+
- name: Bundle OpenAPI v6 specification
43+
run: |
44+
redocly bundle v6.yaml -o v6-bundled.yaml
45+
46+
- name: Validate bundled specifications
47+
run: |
48+
redocly lint v5-bundled.yaml
49+
redocly lint v6-bundled.yaml
50+
51+
- name: Upload bundled specifications
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: bundled-specs
55+
path: |
56+
v5-bundled.yaml
57+
v6-bundled.yaml
58+
retention-days: 90
59+
60+
- name: Upload schemas
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: schemas
64+
path: schemas/
65+
retention-days: 90
66+
67+
- name: Create Release
68+
if: startsWith(github.ref, 'refs/tags/')
69+
uses: actions/create-release@v1
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
tag_name: ${{ github.ref_name }}
74+
release_name: Release ${{ github.ref_name }}
75+
body: |
76+
## Changes
77+
78+
This release includes updated OpenAPI specifications and JSON schemas.
79+
80+
### Artifacts
81+
- `v5-bundled.yaml` - Bundled OpenAPI v5 specification
82+
- `v6-bundled.yaml` - Bundled OpenAPI v6 specification
83+
- `schemas.zip` - All generated JSON schemas
84+
85+
draft: false
86+
prerelease: false
87+
88+
- name: Upload Release Asset - v5 Bundle
89+
if: startsWith(github.ref, 'refs/tags/')
90+
uses: actions/upload-release-asset@v1
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
with:
94+
upload_url: ${{ steps.create_release.outputs.upload_url }}
95+
asset_path: ./v5-bundled.yaml
96+
asset_name: v5-bundled.yaml
97+
asset_content_type: application/yaml
98+
99+
- name: Upload Release Asset - v6 Bundle
100+
if: startsWith(github.ref, 'refs/tags/')
101+
uses: actions/upload-release-asset@v1
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
with:
105+
upload_url: ${{ steps.create_release.outputs.upload_url }}
106+
asset_path: ./v6-bundled.yaml
107+
asset_name: v6-bundled.yaml
108+
asset_content_type: application/yaml
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Schema Generation and Validation
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
push:
7+
branches: [ master ]
8+
9+
jobs:
10+
generate-schemas:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '18'
21+
cache: 'npm'
22+
cache-dependency-path: data_models/package-lock.json
23+
24+
- name: Install dependencies
25+
run: |
26+
cd data_models
27+
npm ci
28+
29+
- name: Run linting
30+
run: |
31+
cd data_models
32+
npm run lint
33+
34+
- name: Run formatting check
35+
run: |
36+
cd data_models
37+
npm run format:check
38+
39+
- name: Run tests
40+
run: |
41+
cd data_models
42+
npm test
43+
44+
- name: Generate TypeSpec schemas
45+
run: |
46+
cd data_models
47+
npx tsp compile . --emit=@typespec/json-schema
48+
49+
- name: Promote schemas
50+
run: |
51+
cd data_models
52+
chmod +x promote.sh
53+
./promote.sh
54+
55+
- name: Verify schemas were generated
56+
run: |
57+
if [ ! -d "schemas" ] || [ -z "$(ls -A schemas)" ]; then
58+
echo "Error: schemas directory is empty or doesn't exist"
59+
exit 1
60+
fi
61+
echo "Generated $(ls schemas | wc -l) schema files"
62+
63+
- name: Upload generated schemas
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: generated-schemas
67+
path: schemas/
68+
retention-days: 30
69+
70+
- name: Check for schema changes
71+
if: github.event_name == 'pull_request'
72+
run: |
73+
git add schemas/
74+
if ! git diff --cached --quiet; then
75+
echo "Schema files have changed. Please commit the updated schemas."
76+
git diff --cached --name-only
77+
exit 1
78+
fi

0 commit comments

Comments
 (0)