Update Nvidia Driver versions #3095
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Nvidia Driver versions | |
| on: | |
| # Set schedule to run every 4 hours | |
| schedule: | |
| - cron: '0 */4 * * *' | |
| # Allow to trigger action manually | |
| workflow_dispatch: | |
| jobs: | |
| update-branches: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 1 | |
| - name: Install dependencies | |
| run: sudo apt-get -y install jq tidy wget | |
| - name: Grab Nvidia Driver versions and update versions.json | |
| run: | | |
| # Get driver versions from json | |
| CUR_PRB="$(jq -r '.branches.production.current' versions.json)" | |
| CUR_NFB="$(jq -r '.branches.newfeature.current' versions.json)" | |
| CUR_BETA="$(jq -r '.branches.beta.current' versions.json)" | |
| CUR_LEGACY="$(jq -r '.branches.legacy.current' versions.json)" | |
| CUR_CONTAINER_TOOLKIT="$(jq -r '.runtimes.containertoolkit.current' versions.json)" | |
| CUR_LIBNVIDIA="$(jq -r '.runtimes.libnvidia.current' versions.json)" | |
| # Get driver versions | |
| RAW_DATA="$(wget -qO- https://www.nvidia.com/en-us/drivers/unix/ | tidy -quiet -wrap 4096 2>/dev/null | grep -A8 "Linux x86_64/AMD64/EM64T")" | |
| PRB="$(echo "${RAW_DATA}" | grep -i "Latest Production Branch" | grep -oE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b')" | |
| NFB="$(echo "${RAW_DATA}" | grep -i "Latest New Feature Branch" | grep -oE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b')" | |
| BETA="$(echo "${RAW_DATA}" | grep -i "Latest Beta" | grep -oE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b')" | |
| LEGACY="$(echo "${RAW_DATA}" | grep -i "Latest Legacy" | grep "(5" | head -1 | grep -oE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b' || true)" | |
| # Fall back to alternative URL to get versions | |
| if [ -z "${RAW_DATA}" ]; then | |
| RAW_DATA="$(wget -qO- https://forums.developer.nvidia.com/t/current-graphics-driver-releases/28500 | tidy -quiet -wrap 4096 2>/dev/null || true)" | |
| PRB="$(echo "${RAW_DATA}" | grep -i "^Current production branch" | grep -oE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b')" | |
| NFB="$(echo "${RAW_DATA}" | grep -i "^Current new feature branch" | grep -oE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b')" | |
| BETA="$(echo "${RAW_DATA}" | grep -i "^Current beta" | grep -oE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b')" | |
| LEGACY="$(echo "${RAW_DATA}" | grep -i -A1 '>Legacy releases' | grep -oE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b' | tail -1)" | |
| fi | |
| # Fallback for "new" legacy driver (since it seems Nvidia didn't update their main site with the "new" 580.x legacy drivers - still the old ones 470.x) | |
| if [ -z "$LEGACY" ]; then | |
| RAW_DATA="$(wget -qO- https://forums.developer.nvidia.com/t/current-graphics-driver-releases/28500 | tidy -quiet -wrap 4096 2>/dev/null || true)" | |
| LEGACY="$(echo "${RAW_DATA}" | grep -i -A1 '>Legacy releases' | grep -oE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b' | tail -1)" | |
| fi | |
| #Get latest containertoolkit and libnvida versions | |
| CONTAINER_TOOLKIT="$(curl -u ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} -s https://api.github.com/repos/unraid/nvidia-container-toolkit/releases/latest | jq -r '.tag_name')" | |
| LIBNVIDIA="$(curl -u ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} -s https://api.github.com/repos/unraid/libnvidia-container/releases/latest | jq -r '.tag_name')" | |
| # Exit if no versions are returned | |
| if [ -z "${RAW_DATA}" ]; then | |
| exit 1 | |
| fi | |
| # Display driver versions | |
| echo "Current versions:" | |
| echo "Production Branch: $CUR_PRB" | |
| echo "New Feature Branch: $CUR_NFB" | |
| echo "Beta Branch: $CUR_BETA" | |
| echo "Legacy Branch: $CUR_LEGACY" | |
| echo "Container Toolkit: $CUR_CONTAINER_TOOLKIT" | |
| echo "libnvidia Container: $CUR_LIBNVIDIA" | |
| echo | |
| echo "Newly grabbed versions:" | |
| echo "Production Branch: $PRB" | |
| echo "New Feature Branch: $NFB" | |
| echo "Beta Branch: $BETA" | |
| echo "Legacy Branch: $LEGACY" | |
| echo "Container Toolkit: $CONTAINER_TOOLKIT" | |
| echo "libnvidia Container: $LIBNVIDIA" | |
| # Make sure jq command is valid even if nothing changed | |
| JQ_COMMAND='.' | |
| # Check if new versions are version numbers and if they are newer | |
| if echo "${PRB}" | grep -qE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b' ; then | |
| if [ "${CUR_PRB}" != "${PRB}" ]; then | |
| JQ_COMMAND+=" | .branches.production.current = \$prb_current" | |
| JQ_COMMAND+=" | .branches.production.last_prb = \$last_prb" | |
| # Trigger build | |
| curl -s -X POST -L --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} "${{ secrets.JENKINS_URL }}?PACKAGES=nvidia-prb" | |
| fi | |
| fi | |
| if echo "${NFB}" | grep -qE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b' ; then | |
| if [ "${CUR_NFB}" != "${NFB}" ]; then | |
| JQ_COMMAND+=" | .branches.newfeature.current = \$nfb_current" | |
| JQ_COMMAND+=" | .branches.newfeature.last_nfb = \$last_nfb" | |
| # Trigger build | |
| curl -s -X POST -L --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} "${{ secrets.JENKINS_URL }}?PACKAGES=nvidia-nfb" | |
| fi | |
| fi | |
| if echo "${BETA}" | grep -qE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b' ; then | |
| if [ "${CUR_BETA}" != "${BETA}" ]; then | |
| JQ_COMMAND+=" | .branches.beta.current = \$beta" | |
| curl -s -X POST -L --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} "${{ secrets.JENKINS_URL }}?PACKAGES=nvidia-beta" | |
| fi | |
| fi | |
| if echo "${LEGACY}" | grep -qE '\b[0-9]+\.[0-9]+(\.[0-9]+)?\b' ; then | |
| if [ "${CUR_LEGACY}" != "${LEGACY}" ]; then | |
| JQ_COMMAND+=" | .branches.legacy.current = \$legacy" | |
| fi | |
| fi | |
| if echo "${CONTAINER_TOOLKIT}" | grep -qE '^\b[0-9]+(\.[0-9]+)*\b$'; then | |
| JQ_COMMAND+=" | .runtimes.containertoolkit.current = \$containertoolkit" | |
| fi | |
| if echo "${LIBNVIDIA}" | grep -qE '^\b[0-9]+(\.[0-9]+)*\b$'; then | |
| JQ_COMMAND+=" | .runtimes.libnvidia.current = \$libnvidia" | |
| fi | |
| # Execute jq command | |
| jq --arg prb_current "$PRB" \ | |
| --arg last_prb "$CUR_PRB" \ | |
| --arg nfb_current "$NFB" \ | |
| --arg last_nfb "$CUR_NFB" \ | |
| --arg beta "$BETA" \ | |
| --arg legacy "$LEGACY" \ | |
| --arg containertoolkit "$CONTAINER_TOOLKIT" \ | |
| --arg libnvidia "$LIBNVIDIA" \ | |
| "$JQ_COMMAND" versions.json > tmp.json && mv tmp.json versions.json | |
| # Check if commit is necessary | |
| if [[ -z $(git status --porcelain) ]]; then | |
| echo "No changes, skipping commit" | |
| echo "COMMIT=false" >> $GITHUB_ENV | |
| else | |
| echo "COMMIT=true" >> $GITHUB_ENV | |
| fi | |
| - name: Commit and push changes | |
| if: env.COMMIT == 'true' | |
| run: | | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add versions.json | |
| git commit -m "Update versions" | |
| git push | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |