Skip to content

Commit dcf6574

Browse files
feat: Add tooling updating workflow (#6)
poor mans dependabot
1 parent 22a6369 commit dcf6574

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Update trx-to-vsplaylist version
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # every night at 2am UTC
6+
workflow_dispatch:
7+
8+
jobs:
9+
update-tool-version:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Get latest trx-to-vsplaylist version from NuGet
16+
id: get_version
17+
shell: pwsh
18+
run: |
19+
$packageInfo = Invoke-RestMethod -Uri "https://api.nuget.org/v3/registration5-gz-semver2/trx-to-vsplaylist/index.json"
20+
$allVersions = $packageInfo.items[0].items | Where-Object { -not $_.catalogEntry.version.Contains('-') }
21+
$latest = $allVersions | Sort-Object { [version]$_.catalogEntry.version } | Select-Object -Last 1
22+
$latestVersion = $latest.catalogEntry.version
23+
Write-Host "Latest NuGet package version: $latestVersion"
24+
echo "latest=$latestVersion" >> $env:GITHUB_OUTPUT
25+
26+
- name: Get current version from action.yml
27+
id: get_current
28+
run: |
29+
CURRENT=$(grep -oP 'dotnet tool install --global trx-to-vsplaylist --version \K[0-9.]+(?=)' action.yml | head -1)
30+
echo "Current version: $CURRENT"
31+
echo "current=$CURRENT" >> $GITHUB_OUTPUT
32+
33+
- name: Check if update is needed
34+
id: check
35+
run: |
36+
if [ "${{ steps.get_version.outputs.latest }}" = "${{ steps.get_current.outputs.current }}" ]; then
37+
echo "No update needed."
38+
echo "update=false" >> $GITHUB_OUTPUT
39+
else
40+
echo "Update needed."
41+
echo "update=true" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Update action.yml with new version
45+
if: steps.check.outputs.update == 'true'
46+
run: |
47+
sed -i "s/dotnet tool install --global trx-to-vsplaylist --version [0-9.][0-9.]*/dotnet tool install --global trx-to-vsplaylist --version ${{ steps.get_version.outputs.latest }}/g" action.yml
48+
49+
- name: Commit and push changes
50+
if: steps.check.outputs.update == 'true'
51+
run: |
52+
git config user.name "github-actions[bot]"
53+
git config user.email "github-actions[bot]@users.noreply.github.com"
54+
git checkout -b update-trx-to-vsplaylist-${{ steps.get_version.outputs.latest }}
55+
git add action.yml
56+
git commit -m "chore: bump trx-to-vsplaylist to ${{ steps.get_version.outputs.latest }}"
57+
git push origin update-trx-to-vsplaylist-${{ steps.get_version.outputs.latest }}
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: Create Pull Request
62+
if: steps.check.outputs.update == 'true'
63+
run: |
64+
gh pr create -B ${{ github.event.repository.default_branch }} -H update-trx-to-vsplaylist-${{ steps.get_version.outputs.latest }} \
65+
--title "chore: bump trx-to-vsplaylist to ${{ steps.get_version.outputs.latest }}" \
66+
--body "Automated PR to update trx-to-vsplaylist tool version in action.yml to ${{ steps.get_version.outputs.latest }}."
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)