name: Update tag

on: [push]

jobs:
  update-nightly:

    runs-on: ubuntu-latest
    permissions: write-all
    steps:

    - uses: actions/checkout@v6
      with:
        fetch-depth: 0

    - name: detect revision
      run: |
        echo "revision=`tools/get_revision.sh`" >> $GITHUB_ENV

    - name: set current head to nightly
      uses: richardsimko/update-tag@v1
      with:
          tag_name: Nightly
      env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    - name: rename the release to include revision
      uses: meeDamian/github-release@2.0
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        tag: Nightly
        name: Nightly build r${{ env.revision }}
        allow_override: true
