Skip to content

Get latest release version #325

Get latest release version

Get latest release version #325

name: Get latest release version
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
get-release-version:
runs-on: ubuntu-latest
steps:
- name: Send telegram notification
uses: appleboy/telegram-action@v0.1.1
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
⚙️ Checking if new release is available.
📚 Repository: [ ${{ github.repository }} ](https://github.com/${{ github.repository }})
- name: Checkout
uses: actions/checkout@v4
with:
# Have to use custom PAT, because commits created with GITHUB_TOKEN will not trigger CI
# See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
token: ${{ secrets.REPO_SCOPED_TOKEN }}
- name: Fetch release version
id: pwsh_version
env:
release_url: https://api.github.com/repos/powershell/powershell/releases/latest
run: |
VERSION=$(curl -sL "https://api.github.com/repos/powershell/powershell/releases/latest" | jq -r ".tag_name")
if [ $VERSION != "null" ]; then
echo $VERSION > version.txt
echo "version=$(echo $VERSION | tr -d 'v')" >> $GITHUB_OUTPUT
else
echo "::error::Value of latest release is \"null\""
exit 1
fi
- name: Check for modified files
id: git-check
run: echo "modified=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")" >> $GITHUB_OUTPUT
- name: Commit latest release version
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
git commit -am "Update release version to ${{ steps.pwsh_version.outputs.version }}"
git push