Skip to content

Commit 1347a5a

Browse files
authored
ci: automate openapi artifact regeneration on release PRs (#967)
This pull request updates the release and CI automation to better manage versioning and OpenAPI artifact generation, especially during release PRs. The changes ensure that frontend and OpenAPI artifacts are kept in sync with backend releases and automates regeneration and committing of these artifacts when needed. **Release automation enhancements:** * [`.github/release-please-config.json`](diffhunk://#diff-b4c6ab25197e992b430b71d65743b6459f06f248f7c6b3364f1942e40d9f0039L7-R19): Configured `release-please` to update additional files on release, including `frontend/package.json` (version), `public/openapi.yaml`, and generated frontend API client files, ensuring all relevant artifacts are versioned together. **CI workflow improvements:** * [`.github/workflows/ci.yml`](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR52-R53): Updated the `actions/checkout` step to use a custom token if available, improving permissions for CI/CD workflows. * [`.github/workflows/ci.yml`](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR76-R94): Enhanced the OpenAPI verification step to allow release PRs to proceed even if OpenAPI artifacts are out of date, and added a new step that automatically regenerates and commits OpenAPI spec and client files during release PRs when needed. This reduces manual intervention and ensures that generated artifacts are always up to date in release branches.
1 parent 4f1c416 commit 1347a5a

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

.github/release-please-config.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
"release-type": "ruby",
55
"package-name": "html2rss-web",
66
"version-file": "config/version.rb",
7-
"changelog-path": "CHANGELOG.md"
7+
"changelog-path": "CHANGELOG.md",
8+
"extra-files": [
9+
{
10+
"type": "json",
11+
"path": "frontend/package.json",
12+
"jsonpath": "$.version"
13+
},
14+
"public/openapi.yaml",
15+
"frontend/src/api/generated/client.gen.ts",
16+
"frontend/src/api/generated/sdk.gen.ts",
17+
"frontend/src/api/generated/types.gen.ts",
18+
"frontend/src/api/generated/index.ts"
19+
]
820
}
921
}
1022
}

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ jobs:
4949
runs-on: ubuntu-latest
5050
steps:
5151
- uses: actions/checkout@v6
52+
with:
53+
token: ${{ secrets.RELEASE_PLEASE_TOKEN || github.token }}
5254

5355
- uses: ruby/setup-ruby@v1
5456
with:
@@ -71,7 +73,25 @@ jobs:
7173
working-directory: frontend
7274

7375
- name: Verify generated OpenAPI spec and client are up to date
76+
id: verify
7477
run: make openapi-verify
78+
continue-on-error: ${{ startsWith(github.head_ref, 'release-please--') }}
79+
80+
- name: Regenerate and commit OpenAPI artifacts on release PRs
81+
if: steps.verify.outcome == 'failure' && startsWith(github.head_ref, 'release-please--')
82+
run: |
83+
git config --global user.name "github-actions[bot]"
84+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
85+
86+
make openapi
87+
make openapi-client
88+
89+
git add public/openapi.yaml frontend/src/api/generated/
90+
git commit -m "chore: regenerate openapi spec and client for version bump"
91+
git push
92+
93+
echo "## OpenAPI artifacts regenerated" >> "$GITHUB_STEP_SUMMARY"
94+
echo "Version bump detected; OpenAPI spec and frontend client have been regenerated and committed." >> "$GITHUB_STEP_SUMMARY"
7595
7696
- name: Lint OpenAPI contract
7797
run: make openapi-lint

0 commit comments

Comments
 (0)