Skip to content

Commit 7eb7ce9

Browse files
committed
feat(ci): stable releases
1 parent 6c509a4 commit 7eb7ce9

1 file changed

Lines changed: 29 additions & 8 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: OpenAPI Specification CI
22

33
on:
4-
- push
5-
- pull_request
6-
- workflow_dispatch
4+
push:
5+
pull_request:
6+
workflow_dispatch:
77

88
jobs:
99
lint:
@@ -125,12 +125,31 @@ jobs:
125125
path: dist
126126
merge-multiple: true
127127

128-
- id: script
128+
- id: metadata
129129
run: |
130130
version=$(jq -r '.info.version' dist/openapi.json)
131-
commits_since_release=$(git log --oneline "release/$version"..HEAD | wc -l)
131+
echo "version=$version" >> $GITHUB_ENV
132+
133+
version_sha=$(
134+
git rev-list -n 1 "v$version" 2>/dev/null \
135+
|| git rev-list -n 1 "release/$version" 2>/dev/null \
136+
|| echo ""
137+
)
138+
echo "version_sha=$version_sha" >> $GITHUB_ENV
132139
133-
version=$(pnpm semver $version -i)-nightly.$commits_since_release
140+
echo "prerelease=$(test -z "$version_sha" && echo false || echo true)" >> $GITHUB_OUTPUT
141+
142+
- id: create_release
143+
if: !steps.metadata.outputs.prerelease
144+
env:
145+
GH_TOKEN: ${{ github.token }}
146+
run: gh release create v$version dist/* --generate-notes
147+
148+
- id: create_prerelease
149+
if: steps.metadata.outputs.prerelease
150+
run: |
151+
version=$(semver $version -i)-nightly.$(git rev-list --count "$version_sha"..HEAD)
152+
echo "version=$version" >> $GITHUB_ENV
134153
135154
jq --arg version "$version" '.info.version = $version' dist/openapi.json > dist/.openapi.json && mv dist/.openapi.json dist/openapi.json
136155
yq --arg version "$version" '.info.version = $version' dist/openapi.yaml > dist/.openapi.yaml && mv dist/.openapi.yaml dist/openapi.yaml
@@ -139,6 +158,10 @@ jobs:
139158
--generate-notes \
140159
--prerelease
141160
161+
- id: script
162+
env:
163+
GH_TOKEN: ${{ github.token }}
164+
run: |
142165
release=$(gh release view v$version --json id,tagName,url,isPrerelease,assets | jq --arg version "$version" -c '{
143166
id,
144167
url,
@@ -152,8 +175,6 @@ jobs:
152175
}')
153176
154177
echo "release=$release" >> $GITHUB_OUTPUT
155-
env:
156-
GH_TOKEN: ${{ github.token }}
157178
158179
release_dispatch:
159180
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)