Release sync #164
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: Release sync | |
on: | |
workflow_dispatch: ~ | |
schedule: | |
# Every sunday 12:00 UTC, 05:00 PDT | |
- cron: '0 12 * * 0' | |
jobs: | |
keep-alive: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Keep cronjob based triggers of GitHub workflows alive | |
uses: PhrozenByte/gh-workflow-immortality@v1 | |
with: | |
secret: ${{ secrets.GH_TOKEN }} | |
repos: ${{ github.repository }} | |
release-sync: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: 'https://registry.npmjs.org' | |
- run: | | |
TAG=`curl --silent "https://api.github.com/repos/clj-kondo/clj-kondo/releases/latest" | jq -r .tag_name` | |
FIRST_LETTER="${TAG:0:1}" | |
NEW_VERSION_STRING="${TAG:1}" | |
OLD_VERSION_STRING=`cat package.json | jq -r '."version-string"'` | |
if [ "$FIRST_LETTER" == "v" ] && [ "$OLD_VERSION_STRING" != "$NEW_VERSION_STRING" ]; then | |
echo "Updating to" $NEW_VERSION_STRING | |
sed -i'.bak' -e 's/'$OLD_VERSION_STRING'/'$NEW_VERSION_STRING'/g' package.json | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git add . | |
git commit -m "fix: update to $NEW_VERSION_STRING" | |
git push | |
yarn | |
yarn publish | |
else | |
echo "No new version found" | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |