Skip to content

update library refs #18

update library refs

update library refs #18

name: Update Library References
run-name: update library refs
on:
push:
branches:
- lib
jobs:
update-hash-and-version:
name: Update hash and version
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout lib branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update Library Reference
run: |
set -e
echo "Checking git version....."
git --version
COMMIT_HASH=$(git rev-parse HEAD)
echo "Current commit hash: $COMMIT_HASH"
git fetch origin main
git worktree add ../main origin/main
cd ../main
echo "Files to patch SHA:"
find ./f95 ./lc -type f
find ./f95 ./lc -type f -exec sed -i -E "s/[a-f0-9]{40}/$COMMIT_HASH/g" {} +
- name: Bump @version patch
run: |
set -e
TARGET_DIRS=(./f95 ./lc)
ls -la $TARGET_DIRS
for DIR in "${TARGET_DIRS[@]}"; do
find "$DIR" -type f -name "*.user.js" | while read -r FILE; do
echo "Processing: $FILE"
VERSION_LINE=$(grep -E "//\s*@version\s+[0-9]+\.[0-9]+(\.[0-9]+)?" "$FILE")
CURRENT_VERSION=$(echo "$VERSION_LINE" | grep -oE "[0-9]+\.[0-9]+(\.[0-9]+)?")
if [[ "$CURRENT_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
CURRENT_VERSION="${CURRENT_VERSION}.0"
fi
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
sed -i "s|@version $CURRENT_VERSION|@version $NEW_VERSION|" "$FILE"
echo "Updated $FILE to version $NEW_VERSION"
done
done
- name: Commit bumped versions
run: |
git config --global user.name ${{ secrets.USER_NAME }}
git config --global user.email ${{ secrets.EMAIL }}
git add -A
git commit -m "Fix library references"
git push --force origin HEAD:main