Get latest release version #556
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: 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/[email protected] | |
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 '[email protected]' | |
git commit -am "Update release version to ${{ steps.pwsh_version.outputs.version }}" | |
git push |