From 3143167975f0d7891894bde5f479056096e0c25b Mon Sep 17 00:00:00 2001 From: Sethu Satheesh <118425907+WH1T3-E4GL3@users.noreply.github.com> Date: Tue, 29 Oct 2024 22:44:00 -0700 Subject: [PATCH] Update update-readme.yml --- .github/workflows/update-readme.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml index 54c9047..df27ace 100644 --- a/.github/workflows/update-readme.yml +++ b/.github/workflows/update-readme.yml @@ -15,15 +15,27 @@ jobs: with: token: ${{ secrets.PAT_TOKEN }} # Use PAT_TOKEN for checkout + - name: Determine Latest Version + id: get-latest-version + run: | + if [ "${{ github.event_name }}" = "release" ]; then + # Use the release tag if triggered by a release + latest_version="${{ github.event.release.tag_name }}" + else + # For manual dispatch, fetch the latest release tag using GitHub API + latest_version=$(curl -s -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ + https://api.github.com/repos/WH1T3-E4GL3/gixposed/releases/latest | jq -r .tag_name) + fi + echo "Latest version: $latest_version" + echo "latest_version=$latest_version" >> $GITHUB_ENV + - name: Update README.md with latest version id: update-readme run: | - # If triggered by a release, use the release tag; otherwise, default to 'v1.0.0' for testing - latest_version="${{ github.event.release.tag_name || 'v1.0.0' }}" - deb_file="gixposed_${latest_version#v}.deb" + deb_file="gixposed_${{ env.latest_version#v }}.deb" # Update README.md with the latest version and download link - sed -i "s|wget https://github.com/WH1T3-E4GL3/gixposed/releases/download/.*|wget https://github.com/WH1T3-E4GL3/gixposed/releases/download/${latest_version}/${deb_file}|" README.md + sed -i "s|wget https://github.com/WH1T3-E4GL3/gixposed/releases/download/.*|wget https://github.com/WH1T3-E4GL3/gixposed/releases/download/${{ env.latest_version }}/${deb_file}|" README.md sed -i "s|sudo dpkg -i .*|sudo dpkg -i ${deb_file}|" README.md - name: Commit changes @@ -33,5 +45,5 @@ jobs: git config --global user.name "GitHub Actions" git config --global user.email "actions@github.com" git add README.md - git commit -m "Update README.md for release ${{ github.event.release.tag_name || 'manual update' }}" + git commit -m "Update README.md for release ${{ env.latest_version }}" git push -u origin main # Ensure it pushes to the main branch