Update non-npm dependencies #692
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 non-npm dependencies | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
dependency: ['swipl', 'emsdk', 'zlib', 'pcre2'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
# Consider using lts | |
node-version: 20.x | |
- name: Commit latest release version | |
run: | | |
npm ci | |
pth=".config.${{ matrix.dependency }}.version" | |
before=$(cat ./package.json | jq "$pth") | |
npm run "update:dep:${{ matrix.dependency }}" | |
current=$(cat ./package.json | jq "$pth") | |
readarray -d . -t before <<<"${before:1:-1}" | |
readarray -d . -t after <<<"${current:1:-1}" | |
if [ ! ${before[0]} == ${after[0]} ] | |
then | |
version="BREAKING CHANGE" | |
branchHead="breaking" | |
elif [ ! ${before[1]} == ${after[1]} ] | |
then | |
version="feat" | |
branchHead="feat" | |
elif [ ! ${before[2]} == ${after[2]} ] | |
then | |
version="fix" | |
branchHead="fix" | |
fi | |
# The name of the new branch if we need to create one | |
branch=$branchHead/update-${{ matrix.dependency }}-v${current:1:-1} | |
msg="$version: update to ${{ matrix.dependency }} v${current:1:-1}" | |
if [ $branchHead ]; then | |
git config --global user.name 'Jesse Wright' | |
git config --global user.email '[email protected]' | |
git checkout -b $branch | |
git commit -am "$msg" | |
git push --set-upstream origin $branch | |
gh pr create -t "$msg" -b "$msg" | |
if [ ! $branchHead == "breaking" ]; then | |
gh pr merge $branch --auto --squash | |
fi | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} |