From 4ca8d829aba233c7cc68509f7c4dbc84f9a63e62 Mon Sep 17 00:00:00 2001 From: Karl-Aksel Puulmann Date: Thu, 13 Mar 2025 18:18:18 +0200 Subject: [PATCH 1/2] WIP --- .github/workflows/tracker-version-bump.yml | 73 ++++++++++++++++++++++ tracker/package.json | 1 + 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/tracker-version-bump.yml diff --git a/.github/workflows/tracker-version-bump.yml b/.github/workflows/tracker-version-bump.yml new file mode 100644 index 000000000000..6339347a1764 --- /dev/null +++ b/.github/workflows/tracker-version-bump.yml @@ -0,0 +1,73 @@ +name: "Tracker: Increment Reported Version" + +on: + pull_request: + paths: + - 'tracker/src/**' + - 'tracker/package.json' + - 'tracker/package-lock.json' + +jobs: + tracker-increment-reported-version: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.PLAUSIBLE_BOT_GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Checkout master for comparison + uses: actions/checkout@v4 + with: + ref: master + path: master-branch + + - name: Install jq + run: sudo apt-get install jq -y + + - name: Compare and increment reportedVersion + id: increment + run: | + cd tracker + # Get current version from PR branch + PR_VERSION=$(jq '.reportedVersion' package.json) + + # Get version from master, default to 0 if not present + MASTER_VERSION=$(jq '.reportedVersion // 0' ../master-branch/tracker/package.json) + + echo "PR reportedVersion: $PR_VERSION" + echo "Master reportedVersion: $MASTER_VERSION" + + # Calculate new version + NEW_VERSION=$((PR_VERSION + 1)) + + # Check version conditions + if [ $PR_VERSION -lt $MASTER_VERSION ]; then + echo "::error::PR tracker reportedVersion ($PR_VERSION) is less than master ($MASTER_VERSION) and cannot be incremented." + echo "::error::Rebase or merge master into your PR to fix this." + exit 1 + elif [ $NEW_VERSION -eq $((MASTER_VERSION + 1)) ]; then + echo "Incrementing version from $PR_VERSION to $NEW_VERSION" + jq ".reportedVersion = $NEW_VERSION" package.json > package.json.tmp + mv package.json.tmp package.json + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "changed=true" >> $GITHUB_OUTPUT + else + echo "Already incremented reportedVersion in PR, skipping." + echo "version=$PR_VERSION" >> $GITHUB_OUTPUT + echo "changed=false" >> $GITHUB_OUTPUT + fi + + - name: Commit and push changes + uses: EndBug/add-and-commit@v9 + if: steps.increment.outputs.changed == 'true' + with: + message: 'chore: Bump tracker reportedVersion to ${{ steps.increment.outputs.version }}' + github_token: ${{ secrets.PLAUSIBLE_BOT_GITHUB_TOKEN }} + # Uncomment this once they're whitelisted by CLA agent + # default_author: github_actions diff --git a/tracker/package.json b/tracker/package.json index 31e5b48d06ea..ebdaaf5b884c 100644 --- a/tracker/package.json +++ b/tracker/package.json @@ -1,4 +1,5 @@ { + "reportedVersion": 0, "scripts": { "deploy": "node compile.js", "test": "npm run deploy && npx playwright test", From 55d5e6fb4dc2aca8eb163d69de4dcd1ac8bc7079 Mon Sep 17 00:00:00 2001 From: macobo Date: Thu, 13 Mar 2025 16:45:06 +0000 Subject: [PATCH 2/2] chore: Bump tracker reportedVersion to 1 --- master-branch | 1 + tracker/package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 160000 master-branch diff --git a/master-branch b/master-branch new file mode 160000 index 000000000000..dec510da1088 --- /dev/null +++ b/master-branch @@ -0,0 +1 @@ +Subproject commit dec510da1088c6848e41599e4724a86398cd3689 diff --git a/tracker/package.json b/tracker/package.json index ebdaaf5b884c..23720c3026fb 100644 --- a/tracker/package.json +++ b/tracker/package.json @@ -1,5 +1,5 @@ { - "reportedVersion": 0, + "reportedVersion": 1, "scripts": { "deploy": "node compile.js", "test": "npm run deploy && npx playwright test",