-
Notifications
You must be signed in to change notification settings - Fork 342
Add workflow to auto update generator version #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| name: Update TypeSpec Generator Version | ||
|
|
||
| on: | ||
| schedule: | ||
| # Run weekly on Mondays at 9 AM UTC | ||
| - cron: '0 9 * * 1' | ||
| workflow_dispatch: | ||
| # Allow manual triggering | ||
| repository_dispatch: | ||
| # Allow triggering from TypeSpec repository on new releases | ||
| types: [typespec-release] | ||
|
|
||
| jobs: | ||
| update-generator: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22.x' | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 8.x | ||
|
|
||
| - name: Check for generator updates | ||
| id: check-updates | ||
| run: | | ||
| # Get current version from both package.json files | ||
| CURRENT_VERSION_OPENAI=$(node -p "require('./dotnet/.plugin/package.json').dependencies['@typespec/http-client-csharp']" 2>/dev/null || echo "unknown") | ||
| CURRENT_VERSION_AZURE=$(node -p "require('./dotnet/.plugin.azure/package.json').dependencies['@typespec/http-client-csharp']" 2>/dev/null || echo "unknown") | ||
|
|
||
| echo "Current OpenAI version: $CURRENT_VERSION_OPENAI" | ||
| echo "Current Azure version: $CURRENT_VERSION_AZURE" | ||
|
|
||
| # Ensure both files have the same version | ||
| if [ "$CURRENT_VERSION_OPENAI" != "$CURRENT_VERSION_AZURE" ]; then | ||
| echo "Warning: Version mismatch between OpenAI and Azure package.json files" | ||
| echo "Using OpenAI version as current: $CURRENT_VERSION_OPENAI" | ||
| fi | ||
|
|
||
| CURRENT_VERSION="$CURRENT_VERSION_OPENAI" | ||
|
|
||
| # Get latest version from npm registry | ||
| LATEST_VERSION=$(npm view @typespec/http-client-csharp version 2>/dev/null || echo "unknown") | ||
| echo "Latest version from npm: $LATEST_VERSION" | ||
|
|
||
| # Validate we got valid versions | ||
| if [ "$CURRENT_VERSION" = "unknown" ] || [ "$LATEST_VERSION" = "unknown" ]; then | ||
| echo "Error: Failed to get version information" | ||
| echo "Current: $CURRENT_VERSION, Latest: $LATEST_VERSION" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Compare versions (simple string comparison for alpha versions) | ||
| if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | ||
| echo "Update needed: $CURRENT_VERSION -> $LATEST_VERSION" | ||
| echo "needs-update=true" >> $GITHUB_OUTPUT | ||
| echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | ||
| echo "latest-version=$LATEST_VERSION" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "No update needed - already at latest version: $CURRENT_VERSION" | ||
| echo "needs-update=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Update generator version and create PR | ||
| if: steps.check-updates.outputs.needs-update == 'true' | ||
| run: | | ||
| LATEST_VERSION="${{ steps.check-updates.outputs.latest-version }}" | ||
|
|
||
| # Use the PowerShell script to handle the entire update process (following TypeSpec pattern) | ||
| pwsh ./scripts/Submit-GeneratorUpdatePr.ps1 \ | ||
| -PackageVersion "$LATEST_VERSION" \ | ||
| -AuthToken "${{ secrets.GITHUB_TOKEN }}" \ | ||
| -RepoPath "." | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm a little confused with the new generator workflow here. Is
./dotnetthe correct path to use here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah probably this needs to be reconciled with the new structure. This was an exact copy from the private repo.