update if nuglify released a new version #28813
This file contains 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 if nuglify released a new version | |
on: | |
schedule: | |
- cron: '0 */1 * * *' | |
workflow_dispatch: | |
jobs: | |
get-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '9.0.x' | |
- uses: actions/checkout@v2 | |
with: | |
ref: 'raif' | |
token: ${{ secrets.PAT }} | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v5 | |
with: | |
gpg_private_key: ${{ secrets.GPG_KEY }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Fetch NUglify version | |
run: | | |
NUGLIFY=$(curl -s https://www.nuget.org/packages/NUglify/atom.xml \ | |
| grep -oPm1 "(?<=<id>https://www.nuget.org/packages/NUglify/)[^<]+" \ | |
| head -n1); | |
echo "NUGLIFY=$NUGLIFY" >> "$GITHUB_ENV" | |
- name: Update NUglify version | |
if: env.NUGLIFY != '' | |
run: | | |
NUGLIFY=${{ env.NUGLIFY }} | |
sed -i "s#<PackageReference Include=\"NUglify\" Version=\".*\" />#<PackageReference Include=\"NUglify\" Version=\"$NUGLIFY\" />#" src/BundlerMinifier.Core/BundlerMinifier.Core.csproj | |
- name: Check for modified files | |
id: git-check | |
run: echo modified=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true") >> "$GITHUB_ENV" | |
- name: Commit latest release version | |
if: env.modified == 'true' | |
run: | | |
sed -i -r 's#<Version>(.*)\.([[:digit:]]+)</Version>#echo " <Version>\1\.$((\2+1))</Version>"#e' src/BundlerMinifier.Core/BundlerMinifier.Core.csproj | |
git commit -am "New version tracking new NUglify release ${{ env.NUGLIFY }}" | |
git push |