|
| 1 | +name: Service Update |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [codebelt-service-update] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + source_repo: |
| 9 | + description: 'Triggering source repo name (e.g. cuemon)' |
| 10 | + required: false |
| 11 | + default: '' |
| 12 | + source_version: |
| 13 | + description: 'Version released by source (e.g. 10.3.0)' |
| 14 | + required: false |
| 15 | + default: '' |
| 16 | + dry_run: |
| 17 | + type: boolean |
| 18 | + description: 'Dry run — show changes but do not commit or open PR' |
| 19 | + default: false |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: write |
| 23 | + pull-requests: write |
| 24 | + |
| 25 | +jobs: |
| 26 | + service-update: |
| 27 | + runs-on: ubuntu-24.04 |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + |
| 35 | + - name: Resolve trigger inputs |
| 36 | + id: trigger |
| 37 | + run: | |
| 38 | + SOURCE="${{ github.event.client_payload.source_repo || github.event.inputs.source_repo }}" |
| 39 | + VERSION="${{ github.event.client_payload.source_version || github.event.inputs.source_version }}" |
| 40 | + echo "source=$SOURCE" >> $GITHUB_OUTPUT |
| 41 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 42 | +
|
| 43 | + - name: Determine new version for this repo |
| 44 | + id: newver |
| 45 | + run: | |
| 46 | + CURRENT=$(grep -oP '(?<=## \[)[\d.]+(?=\])' CHANGELOG.md | head -1) |
| 47 | + NEW=$(echo "$CURRENT" | awk -F. '{printf "%s.%s.%d", $1, $2, $3+1}') |
| 48 | + BRANCH="v${NEW}/service-update" |
| 49 | + echo "current=$CURRENT" >> $GITHUB_OUTPUT |
| 50 | + echo "new=$NEW" >> $GITHUB_OUTPUT |
| 51 | + echo "branch=$BRANCH" >> $GITHUB_OUTPUT |
| 52 | +
|
| 53 | + - name: Generate codebelt-aicia token |
| 54 | + id: app-token |
| 55 | + uses: actions/create-github-app-token@v1 |
| 56 | + with: |
| 57 | + app-id: ${{ vars.CODEBELT_AICIA_APP_ID }} |
| 58 | + private-key: ${{ secrets.CODEBELT_AICIA_PRIVATE_KEY }} |
| 59 | + owner: codebeltnet |
| 60 | + |
| 61 | + - name: Bump NuGet packages |
| 62 | + run: python3 .github/scripts/bump-nuget.py |
| 63 | + env: |
| 64 | + TRIGGER_SOURCE: ${{ steps.trigger.outputs.source }} |
| 65 | + TRIGGER_VERSION: ${{ steps.trigger.outputs.version }} |
| 66 | + |
| 67 | + - name: Update PackageReleaseNotes.txt |
| 68 | + run: | |
| 69 | + NEW="${{ steps.newver.outputs.new }}" |
| 70 | + for f in .nuget/*/PackageReleaseNotes.txt; do |
| 71 | + [ -f "$f" ] || continue |
| 72 | + TFM=$(grep -m1 "^Availability:" "$f" | sed 's/Availability: //' || echo ".NET 10, .NET 9 and .NET Standard 2.0") |
| 73 | + ENTRY="Version: ${NEW}\nAvailability: ${TFM}\n \n# ALM\n- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs)\n \n" |
| 74 | + { printf "$ENTRY"; cat "$f"; } > "$f.tmp" && mv "$f.tmp" "$f" |
| 75 | + done |
| 76 | +
|
| 77 | + - name: Update CHANGELOG.md |
| 78 | + run: | |
| 79 | + python3 - <<'EOF' |
| 80 | + import os, re |
| 81 | + from datetime import date |
| 82 | + new_ver = os.environ['NEW_VERSION'] |
| 83 | + today = date.today().isoformat() |
| 84 | + entry = f"## [{new_ver}] - {today}\n\nThis is a service update that focuses on package dependencies.\n\n" |
| 85 | + with open("CHANGELOG.md") as f: |
| 86 | + content = f.read() |
| 87 | + idx = content.find("## [") |
| 88 | + content = (content[:idx] + entry + content[idx:]) if idx != -1 else (content + entry) |
| 89 | + with open("CHANGELOG.md", "w") as f: |
| 90 | + f.write(content) |
| 91 | + print(f"CHANGELOG updated for v{new_ver}") |
| 92 | + EOF |
| 93 | + env: |
| 94 | + NEW_VERSION: ${{ steps.newver.outputs.new }} |
| 95 | + |
| 96 | + # Note: Docker image bumps removed in favor of manual updates |
| 97 | + # The automated selection was picking wrong variants (e.g., mono-* instead of standard) |
| 98 | + # TODO: Move to hosted service for smarter image selection |
| 99 | + |
| 100 | + - name: Show diff (dry run) |
| 101 | + if: ${{ github.event.inputs.dry_run == 'true' }} |
| 102 | + run: git diff |
| 103 | + |
| 104 | + - name: Create branch and open PR |
| 105 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
| 106 | + env: |
| 107 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 108 | + run: | |
| 109 | + NEW="${{ steps.newver.outputs.new }}" |
| 110 | + BRANCH="${{ steps.newver.outputs.branch }}" |
| 111 | + SOURCE="${{ steps.trigger.outputs.source }}" |
| 112 | + SRC_VER="${{ steps.trigger.outputs.version }}" |
| 113 | +
|
| 114 | + git config user.name "codebelt-aicia[bot]" |
| 115 | + git config user.email "codebelt-aicia[bot]@users.noreply.github.com" |
| 116 | + git checkout -b "$BRANCH" |
| 117 | + git add -A |
| 118 | + git diff --cached --quiet && echo "Nothing changed - skipping PR." && exit 0 |
| 119 | + git commit -m "V${NEW}/service update" |
| 120 | + git push origin "$BRANCH" |
| 121 | +
|
| 122 | + echo "This is a service update that focuses on package dependencies." > pr_body.txt |
| 123 | + echo "" >> pr_body.txt |
| 124 | + echo "Automated changes:" >> pr_body.txt |
| 125 | + echo "- Codebelt/Cuemon package versions bumped to latest compatible" >> pr_body.txt |
| 126 | + echo "- PackageReleaseNotes.txt updated for v${NEW}" >> pr_body.txt |
| 127 | + echo "- CHANGELOG.md entry added for v${NEW}" >> pr_body.txt |
| 128 | + echo "" >> pr_body.txt |
| 129 | + echo "Note: Third-party packages (Microsoft.Extensions.*, BenchmarkDotNet, etc.) are not auto-updated." >> pr_body.txt |
| 130 | + echo "Use Dependabot or manual updates for those." >> pr_body.txt |
| 131 | + echo "" >> pr_body.txt |
| 132 | + echo "Generated by codebelt-aicia" >> pr_body.txt |
| 133 | + if [ -n "$SOURCE" ] && [ -n "$SRC_VER" ]; then |
| 134 | + echo "Triggered by: ${SOURCE} @ ${SRC_VER}" >> pr_body.txt |
| 135 | + else |
| 136 | + echo "Triggered by: manual workflow dispatch" >> pr_body.txt |
| 137 | + fi |
| 138 | +
|
| 139 | + gh pr create --title "V${NEW}/service update" --body-file pr_body.txt --base main --head "$BRANCH" --assignee gimlichael |
0 commit comments