Skip to content
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

WIP: Tracker versioning #5198

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/tracker-version-bump.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions master-branch
Submodule master-branch added at dec510
1 change: 1 addition & 0 deletions tracker/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"reportedVersion": 1,
"scripts": {
"deploy": "node compile.js",
"test": "npm run deploy && npx playwright test",
Expand Down
Loading