Skip to content

Commit 04b5ad1

Browse files
authored
feat: draft releases, version verification, and reusable workflows (#210)
* feat: draft releases, version verification, and reusable workflows * fix: run verify-version in parallel with pack and use msbuild for .csproj parsing - Remove `needs: [pack]` from verify-version so it runs immediately on tag pushes for fast failure - Add `pack` to publish's needs so it still gates on the artifact - Replace grep-based XML parsing with `dotnet msbuild -getProperty:Version` - Add trailing newline to file
1 parent 996f018 commit 04b5ad1

3 files changed

Lines changed: 36 additions & 27 deletions

File tree

.github/workflows/main.yaml

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,40 @@ jobs:
202202
artifact-pack/*.snupkg
203203
retention-days: 7
204204

205+
verify-version:
206+
runs-on: ubuntu-latest
207+
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-test')
208+
209+
steps:
210+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2
211+
212+
- name: Setup .NET
213+
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
214+
with:
215+
dotnet-version: 8.0.x
216+
217+
- name: Verify versions match
218+
run: |
219+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
220+
MANIFEST_VERSION=$(jq -r '.["."]' .release-please-manifest.json)
221+
CSPROJ_VERSION=$(dotnet msbuild src/OpenFga.Sdk/OpenFga.Sdk.csproj -getProperty:Version -p:TargetFramework=net8.0 -noRestore -nologo | tr -d '[:space:]')
222+
223+
echo "Tag: $TAG_VERSION | Manifest: $MANIFEST_VERSION | .csproj: $CSPROJ_VERSION"
224+
225+
if [[ "$TAG_VERSION" != "$MANIFEST_VERSION" ]]; then
226+
echo "ERROR: Tag version does not match manifest version"
227+
exit 1
228+
fi
229+
if [[ "$CSPROJ_VERSION" != "$MANIFEST_VERSION" ]]; then
230+
echo "ERROR: .csproj version does not match manifest version"
231+
exit 1
232+
fi
233+
echo "All versions verified: $TAG_VERSION"
234+
205235
publish:
206236
runs-on: ubuntu-latest
207237
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-test')
208-
needs: [pack]
238+
needs: [pack, verify-version]
209239
permissions:
210240
id-token: write # For OIDC authentication with NuGet.org
211241
packages: write # For publishing to the GitHub Nuget Registry
@@ -246,24 +276,9 @@ jobs:
246276

247277

248278

249-
create-release:
250-
runs-on: ubuntu-latest
279+
undraft-release:
251280
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-test')
252281
needs: [publish]
253-
254282
permissions:
255283
contents: write
256-
257-
steps:
258-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2
259-
with:
260-
fetch-depth: 0
261-
262-
- uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803 # v3.0.1
263-
with:
264-
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
265-
prerelease_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+-(alpha|beta|preview)\.[[:digit:]]+$
266-
changelog_file: CHANGELOG.md
267-
create_draft: true
268-
env:
269-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
284+
uses: openfga/sdk-generator/.github/workflows/undraft-release.yml@main

.github/workflows/pr-title-conventional-commit.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,8 @@ on:
77
- main
88

99
jobs:
10-
validate-pr-title:
11-
name: Validate PR Title
12-
runs-on: ubuntu-latest
10+
pr-title-check:
1311
permissions:
1412
pull-requests: read
15-
steps:
16-
- name: PR Conventional Commit Validation
17-
uses: ytanikin/pr-conventional-commits@639145d78959c53c43112365837e3abd21ed67c1 # v1.5.2
18-
with:
19-
task_types: '["feat","fix","docs","test","refactor","ci","perf","chore","revert","release"]'
20-
add_label: 'false'
13+
uses: openfga/sdk-generator/.github/workflows/pr-title-check.yml@main
2114

release-please-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
33
"release-type": "simple",
44
"pull-request-title-pattern": "release: v${version}",
5+
"draft": true,
56
"packages": {
67
".": {
78
"package-name": "",

0 commit comments

Comments
 (0)