Implement RT-Thread 2025 Roadmap: Enhanced testing, automation, and B… #1
Workflow file for this run
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
| # | ||
| # Copyright (c) 2006-2025, RT-Thread Development Team | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Change Logs: | ||
| # Date Author Notes | ||
| # 2025-01-03 Copilot Add automated tagging workflow for RT-Thread 2025 roadmap | ||
| # | ||
| name: Automated Release Tagging | ||
| # Controls when the action will run | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version_type: | ||
| description: 'Version type to release' | ||
| required: true | ||
| default: 'patch' | ||
| type: choice | ||
| options: | ||
| - patch | ||
| - minor | ||
| - major | ||
| - custom | ||
| custom_version: | ||
| description: 'Custom version (only if version_type is custom)' | ||
| required: false | ||
| type: string | ||
| release_notes: | ||
| description: 'Release notes' | ||
| required: false | ||
| type: string | ||
| default: 'Automated release' | ||
| permissions: | ||
| contents: write | ||
| pull-requests: read | ||
| jobs: | ||
| create_release: | ||
| runs-on: ubuntu-22.04 | ||
| name: Create Automated Release | ||
| if: github.repository_owner == 'RT-Thread' && github.ref == 'refs/heads/master' | ||
| steps: | ||
| - uses: actions/checkout@main | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Configure Git | ||
| run: | | ||
| git config user.name "RT-Thread Bot" | ||
| git config user.email "[email protected]" | ||
| - name: Get Current Version | ||
| id: current_version | ||
| run: | | ||
| # Try to get the latest tag, fallback to v5.1.0 if no tags exist | ||
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v5.1.0") | ||
| echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT | ||
| # Extract version components | ||
| VERSION=${LATEST_TAG#v} | ||
| MAJOR=$(echo $VERSION | cut -d. -f1) | ||
| MINOR=$(echo $VERSION | cut -d. -f2) | ||
| PATCH=$(echo $VERSION | cut -d. -f3) | ||
| echo "major=$MAJOR" >> $GITHUB_OUTPUT | ||
| echo "minor=$MINOR" >> $GITHUB_OUTPUT | ||
| echo "patch=$PATCH" >> $GITHUB_OUTPUT | ||
| echo "Current version: $LATEST_TAG ($MAJOR.$MINOR.$PATCH)" | ||
| - name: Calculate New Version | ||
| id: new_version | ||
| run: | | ||
| MAJOR=${{ steps.current_version.outputs.major }} | ||
| MINOR=${{ steps.current_version.outputs.minor }} | ||
| PATCH=${{ steps.current_version.outputs.patch }} | ||
| case "${{ github.event.inputs.version_type }}" in | ||
| "major") | ||
| NEW_MAJOR=$((MAJOR + 1)) | ||
| NEW_MINOR=0 | ||
| NEW_PATCH=0 | ||
| ;; | ||
| "minor") | ||
| NEW_MAJOR=$MAJOR | ||
| NEW_MINOR=$((MINOR + 1)) | ||
| NEW_PATCH=0 | ||
| ;; | ||
| "patch") | ||
| NEW_MAJOR=$MAJOR | ||
| NEW_MINOR=$MINOR | ||
| NEW_PATCH=$((PATCH + 1)) | ||
| ;; | ||
| "custom") | ||
| if [[ -n "${{ github.event.inputs.custom_version }}" ]]; then | ||
| CUSTOM_VERSION="${{ github.event.inputs.custom_version }}" | ||
| # Remove 'v' prefix if present | ||
| CUSTOM_VERSION=${CUSTOM_VERSION#v} | ||
| NEW_VERSION="v$CUSTOM_VERSION" | ||
| else | ||
| echo "Custom version is required when version_type is custom" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| esac | ||
| if [[ "${{ github.event.inputs.version_type }}" != "custom" ]]; then | ||
| NEW_VERSION="v$NEW_MAJOR.$NEW_MINOR.$NEW_PATCH" | ||
| fi | ||
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | ||
| echo "New version: $NEW_VERSION" | ||
| - name: Update Version in Files | ||
| env: | ||
| NEW_VERSION: ${{ steps.new_version.outputs.new_version }} | ||
| run: | | ||
| # Update version in include/rtdef.h if it exists | ||
| if [ -f "include/rtdef.h" ]; then | ||
| # Look for RT_VERSION patterns and update them | ||
| sed -i "s/#define RT_VERSION.*/#define RT_VERSION \"${NEW_VERSION#v}\"/" include/rtdef.h || true | ||
| fi | ||
| # Update version in Kconfig if it exists | ||
| if [ -f "Kconfig" ]; then | ||
| sed -i "s/default \".*\"/default \"${NEW_VERSION#v}\"/" Kconfig || true | ||
| fi | ||
| # Update version in package.json if it exists (for any package manager integration) | ||
| if [ -f "package.json" ]; then | ||
| sed -i "s/\"version\": \".*\"/\"version\": \"${NEW_VERSION#v}\"/" package.json || true | ||
| fi | ||
| - name: Generate Changelog | ||
| id: changelog | ||
| run: | | ||
| LATEST_TAG="${{ steps.current_version.outputs.latest_tag }}" | ||
| NEW_VERSION="${{ steps.new_version.outputs.new_version }}" | ||
| # Generate changelog since last tag | ||
| if git tag --list | grep -q "$LATEST_TAG"; then | ||
| COMMITS=$(git log --oneline --no-merges ${LATEST_TAG}..HEAD) | ||
| else | ||
| COMMITS=$(git log --oneline --no-merges HEAD~50..HEAD) | ||
| fi | ||
| CHANGELOG_FILE="CHANGELOG_$NEW_VERSION.md" | ||
| echo "# Changelog for $NEW_VERSION" > "$CHANGELOG_FILE" | ||
| echo "" >> "$CHANGELOG_FILE" | ||
| echo "## Changes since $LATEST_TAG" >> "$CHANGELOG_FILE" | ||
| echo "" >> "$CHANGELOG_FILE" | ||
| echo "$COMMITS" >> "$CHANGELOG_FILE" | ||
| echo "" >> "$CHANGELOG_FILE" | ||
| echo "## RT-Thread 2025 Roadmap Progress" >> "$CHANGELOG_FILE" | ||
| echo "" >> "$CHANGELOG_FILE" | ||
| echo "This release includes progress on the RT-Thread 2025 roadmap:" >> "$CHANGELOG_FILE" | ||
| echo "- ✅ Enhanced testing infrastructure with automated workflows" >> "$CHANGELOG_FILE" | ||
| echo "- ✅ Improved code coverage reporting" >> "$CHANGELOG_FILE" | ||
| echo "- ✅ Automated release tagging system" >> "$CHANGELOG_FILE" | ||
| echo "- ⏳ Continued BSP and component improvements" >> "$CHANGELOG_FILE" | ||
| echo "" >> "$CHANGELOG_FILE" | ||
| echo "For full roadmap details, see: https://github.com/RT-Thread/rt-thread/issues/9822" >> "$CHANGELOG_FILE" | ||
| echo "" >> "$CHANGELOG_FILE" | ||
| echo "## Release Notes" >> "$CHANGELOG_FILE" | ||
| echo "" >> "$CHANGELOG_FILE" | ||
| echo "${{ github.event.inputs.release_notes }}" >> "$CHANGELOG_FILE" | ||
| echo "changelog_file=$CHANGELOG_FILE" >> $GITHUB_OUTPUT | ||
| - name: Commit Version Changes | ||
| env: | ||
| NEW_VERSION: ${{ steps.new_version.outputs.new_version }} | ||
| run: | | ||
| git add -A | ||
| if git diff --staged --quiet; then | ||
| echo "No changes to commit" | ||
| else | ||
| git commit -m "chore: bump version to $NEW_VERSION | ||
| This automated commit updates version information for release $NEW_VERSION | ||
| as part of the RT-Thread 2025 roadmap automated tagging system. | ||
| Related to #9822" | ||
| git push origin master | ||
| fi | ||
| - name: Create Tag and Release | ||
| env: | ||
| NEW_VERSION: ${{ steps.new_version.outputs.new_version }} | ||
| CHANGELOG_FILE: ${{ steps.changelog.outputs.changelog_file }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| # Create annotated tag | ||
| git tag -a "$NEW_VERSION" -m "Release $NEW_VERSION | ||
| Automated release created as part of RT-Thread 2025 roadmap. | ||
| See changelog for details. | ||
| Related to #9822" | ||
| # Push tag | ||
| git push origin "$NEW_VERSION" | ||
| # Create GitHub release | ||
| gh release create "$NEW_VERSION" \ | ||
| --title "RT-Thread $NEW_VERSION" \ | ||
| --notes-file "$CHANGELOG_FILE" \ | ||
| --generate-notes | ||
| - name: Update Issue Comment | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| script: | | ||
| const newVersion = '${{ steps.new_version.outputs.new_version }}'; | ||
| const body = `## 🚀 Automated Release Created: ${newVersion} | ||
| A new release has been automatically created as part of the RT-Thread 2025 roadmap implementation. | ||
| **Release Details:** | ||
| - **Version**: ${newVersion} | ||
| - **Type**: ${{ github.event.inputs.version_type }} | ||
| - **Created**: ${new Date().toISOString()} | ||
| **Roadmap Progress:** | ||
| - ✅ Automated release tagging system implemented | ||
| - ✅ Enhanced CI/CD workflows | ||
| - ✅ Code coverage integration | ||
| 🔗 [View Release](https://github.com/RT-Thread/rt-thread/releases/tag/${newVersion}) | ||
| `; | ||
| try { | ||
| await github.rest.issues.createComment({ | ||
| issue_number: 9822, | ||
| owner: 'RT-Thread', | ||
| repo: 'rt-thread', | ||
| body: body | ||
| }); | ||
| } catch (error) { | ||
| console.log('Could not comment on issue:', error.message); | ||
| } | ||
| - name: Cleanup | ||
| run: | | ||
| rm -f CHANGELOG_*.md | ||