From 831fa64157fa234cbc82952b37b13d8a04c20b26 Mon Sep 17 00:00:00 2001 From: senseix21 Date: Thu, 20 Nov 2025 12:45:13 +0600 Subject: [PATCH 1/5] feat: add automated up-spec compatibility badge --- .github/workflows/up-spec-badge.yml | 94 +++++++++++++++++++++++++++++ README.md | 5 ++ 2 files changed, 99 insertions(+) create mode 100644 .github/workflows/up-spec-badge.yml diff --git a/.github/workflows/up-spec-badge.yml b/.github/workflows/up-spec-badge.yml new file mode 100644 index 0000000..0316b71 --- /dev/null +++ b/.github/workflows/up-spec-badge.yml @@ -0,0 +1,94 @@ +name: Update up-spec compatibility badge + +on: + push: + branches: [ main ] + workflow_dispatch: + +permissions: + contents: write + +jobs: + badge: + runs-on: ubuntu-latest + steps: + - name: Checkout (with submodules) + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Fetch tags for up-spec submodule + run: | + git -C up-spec fetch --tags || true + + - name: Determine current up-spec tag + id: current + run: | + if CUR=$(git -C up-spec describe --tags --exact-match 2>/dev/null); then + echo "current_tag=$CUR" >> $GITHUB_OUTPUT + else + CUR=$(git -C up-spec describe --tags --abbrev=0 2>/dev/null || echo "unknown") + echo "current_tag=$CUR" >> $GITHUB_OUTPUT + fi + + - name: Get latest up-spec tag (including pre-releases) + id: latest + run: | + TAGS=$(curl -s https://api.github.com/repos/eclipse-uprotocol/up-spec/tags | jq -r '.[].name') + if [ -z "$TAGS" ]; then + echo "Failed to retrieve tags" + exit 1 + fi + # Sort semver with pre-release awareness (simple approach). + LATEST=$(printf "%s\n" $TAGS | sort -V | tail -n1) + echo "latest_tag=$LATEST" >> $GITHUB_OUTPUT + + - name: Decide badge color + id: color + run: | + if [ "${{ steps.current.outputs.current_tag }}" = "${{ steps.latest.outputs.latest_tag }}" ]; then + echo "color=green" >> $GITHUB_OUTPUT + else + echo "color=red" >> $GITHUB_OUTPUT + fi + + - name: Build badge line + id: badge + run: | + CUR=${{ steps.current.outputs.current_tag }} + COLOR=${{ steps.color.outputs.color }} + BADGE_URL="https://img.shields.io/badge/up--spec-${CUR//-/%2D}-${COLOR}" + LINK_URL="https://github.com/eclipse-uprotocol/up-spec/tree/${CUR}" + echo "badge_line=[![up-spec](${BADGE_URL})](${LINK_URL})" >> $GITHUB_OUTPUT + + - name: Update README + run: | + README="README.md" + START="" + END="" + NEW="${{ steps.badge.outputs.badge_line }}" + if grep -q "$START" "$README"; then + EXISTING=$(awk "/$START/{getline; print}" "$README") + if [ "$EXISTING" = "$NEW" ]; then + echo "No change needed." + exit 0 + fi + awk -v s="$START" -v e="$END" -v n="$NEW" ' + $0==s { print; getline; print n; next } + { print } + ' "$README" > README.tmp && mv README.tmp "$README" + else + printf "%s\n%s\n%s\n\n" "$START" "$NEW" "$END" | cat - "$README" > README.tmp && mv README.tmp "$README" + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add README.md + git commit -m "chore: update up-spec compatibility badge" || echo "Nothing to commit" + git push || echo "Push skipped (likely not on main)." + + - name: Summary + run: | + echo "Current: ${{ steps.current.outputs.current_tag }}" >> $GITHUB_STEP_SUMMARY + echo "Latest: ${{ steps.latest.outputs.latest_tag }}" >> $GITHUB_STEP_SUMMARY + echo "Color: ${{ steps.color.outputs.color }}" >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/README.md b/README.md index efb4a16..0440183 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Eclipse uProtocol Rust library + +[![up-spec](https://img.shields.io/badge/up--spec-v1.2.3--beta.4-green)](https://github.com/eclipse-uprotocol/up-spec/tree/v1.2.3-beta.4) + + + This is the [uProtocol v1.6.0-alpha.7 Language Library](https://github.com/eclipse-uprotocol/uprotocol-spec/blob/v1.6.0-alpha.7/languages.adoc) for the Rust programming language. The crate can be used to From dd3987aecf026991eaa8e94e9cf46be29576bc77 Mon Sep 17 00:00:00 2001 From: senseix21 Date: Thu, 20 Nov 2025 12:54:52 +0600 Subject: [PATCH 2/5] Update up-spec badge to v1.6.0-alpha.7 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0440183..2334905 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Eclipse uProtocol Rust library -[![up-spec](https://img.shields.io/badge/up--spec-v1.2.3--beta.4-green)](https://github.com/eclipse-uprotocol/up-spec/tree/v1.2.3-beta.4) +[![up-spec](https://img.shields.io/badge/up--spec-v1.6.0--alpha.7-green)](https://github.com/eclipse-uprotocol/up-spec/tree/v1.6.0-alpha.7) From 7a1d2467bc406773332376ab8f9e9b6c0d826bc2 Mon Sep 17 00:00:00 2001 From: Mehedi Hasan <117451901+senseix21@users.noreply.github.com> Date: Thu, 20 Nov 2025 14:31:55 +0600 Subject: [PATCH 3/5] Update .github/workflows/up-spec-badge.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/up-spec-badge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/up-spec-badge.yml b/.github/workflows/up-spec-badge.yml index 0316b71..8dceaf8 100644 --- a/.github/workflows/up-spec-badge.yml +++ b/.github/workflows/up-spec-badge.yml @@ -75,7 +75,7 @@ jobs: exit 0 fi awk -v s="$START" -v e="$END" -v n="$NEW" ' - $0==s { print; getline; print n; next } + $0==s { print; getline; print n; while (getline && $0!=e); print e; next } { print } ' "$README" > README.tmp && mv README.tmp "$README" else From dd5cf465ffcabc4786839678423a2baca6a8290f Mon Sep 17 00:00:00 2001 From: Mehedi Hasan <117451901+senseix21@users.noreply.github.com> Date: Thu, 20 Nov 2025 14:32:08 +0600 Subject: [PATCH 4/5] Update .github/workflows/up-spec-badge.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/up-spec-badge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/up-spec-badge.yml b/.github/workflows/up-spec-badge.yml index 8dceaf8..089c78d 100644 --- a/.github/workflows/up-spec-badge.yml +++ b/.github/workflows/up-spec-badge.yml @@ -35,7 +35,7 @@ jobs: - name: Get latest up-spec tag (including pre-releases) id: latest run: | - TAGS=$(curl -s https://api.github.com/repos/eclipse-uprotocol/up-spec/tags | jq -r '.[].name') + TAGS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-uprotocol/up-spec/tags | jq -r '.[].name') if [ -z "$TAGS" ]; then echo "Failed to retrieve tags" exit 1 From 4a1f3a21ccced6db4a00302154df4636104c14f6 Mon Sep 17 00:00:00 2001 From: Mehedi Hasan <117451901+senseix21@users.noreply.github.com> Date: Thu, 20 Nov 2025 14:32:18 +0600 Subject: [PATCH 5/5] Update .github/workflows/up-spec-badge.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/up-spec-badge.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/up-spec-badge.yml b/.github/workflows/up-spec-badge.yml index 089c78d..44f06c8 100644 --- a/.github/workflows/up-spec-badge.yml +++ b/.github/workflows/up-spec-badge.yml @@ -10,6 +10,7 @@ permissions: jobs: badge: + if: github.event.head_commit.author.name != 'github-actions[bot]' runs-on: ubuntu-latest steps: - name: Checkout (with submodules)