66 - lib
77
88jobs :
9- update-hash :
10- name : Update hash
9+ update-hash-and-version :
10+ name : Update hash and version
1111 permissions :
1212 contents : write
13- runs-on : windows -latest
13+ runs-on : ubuntu -latest
1414 steps :
1515 - name : Checkout lib branch
1616 uses : actions/checkout@v4
1717 with :
1818 fetch-depth : 0
1919
20- - name : Establish Library Reference
21- shell : pwsh
20+ - name : Update Library Reference
2221 run : |
23- $CommitHash = (git rev-parse HEAD)
22+ set -e
23+ COMMIT_HASH = $(git rev-parse HEAD)
2424 git fetch origin main
2525 git worktree add ../main origin/main
26- Set-Location ../main
27- Get-Item "./f95/*", "./lc/*" | ForEach-Object -Process {(Get-Content $_) -replace '[a-f0-9]{40}', $CommitHash | Set-Content $_}
26+ cd ../main
27+
28+ find ./f95 ./lc -type f -exec sed -i -E "s/[a-f0-9]{40}/$COMMIT_HASH/g" {} +
29+
30+ - name : Bump @version patch
31+ run : |
32+ set -e
33+ TARGET_DIRS=(./f95 ./lc)
34+
35+ for DIR in "${TARGET_DIRS[@]}"; do
36+ find "$DIR" -type f -name "*.user.js" | while read -r FILE; do
37+ echo "Processing: $FILE"
38+
39+ VERSION_LINE=$(grep -E "//\s*@version\s+[0-9]+\.[0-9]+(\.[0-9]+)?" "$FILE")
40+ CURRENT_VERSION=$(echo "$VERSION_LINE" | grep -oE "[0-9]+\.[0-9]+(\.[0-9]+)?")
41+
42+ if [[ "$CURRENT_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
43+ CURRENT_VERSION="${CURRENT_VERSION}.0"
44+ fi
45+
46+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
47+ NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
48+
49+ sed -i "s|@version $CURRENT_VERSION|@version $NEW_VERSION|" "$FILE"
50+ echo "Updated $FILE to version $NEW_VERSION"
51+ done
52+ done
53+
54+ - name : Commit bumped versions
55+ run : |
2856 git config --global user.name ${{ secrets.USER_NAME }}
2957 git config --global user.email ${{ secrets.EMAIL }}
3058 git add -A
3159 git commit -m "Fix library references"
32- git push --force origin HEAD:main
60+ git push --force origin HEAD:main
0 commit comments