Update #456
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 | |
on: | |
schedule: | |
- cron: "0 12 * * *" | |
workflow_dispatch: | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- run: npm install | |
- run: node update | |
- id: dirty | |
name: Check if dirty | |
run: | | |
git status | |
if [[ -z $(git status -s) ]]; then | |
echo "Dirty=false" >>"$GITHUB_OUTPUT" | |
else | |
echo "Dirty=true" >>"$GITHUB_OUTPUT" | |
fi | |
- run: | | |
echo "Dirty: ${{ steps.dirty.outputs.Dirty }}" | |
- if: steps.dirty.outputs.Dirty == 'true' | |
name: Ensure tests still pass | |
run: npm test | |
- if: steps.dirty.outputs.Dirty == 'true' | |
name: Commit changes | |
run: | | |
git config --global user.email "mathiesonstephen8@gmail.com" | |
git config --global user.name "Stephen Mathieson" | |
git add index.json | |
git commit -m "Update list" | |
git push | |
- if: steps.dirty.outputs.Dirty == 'true' | |
name: Update metadata | |
id: metadata | |
run: | | |
CurrentVersion=$(jq -r .version package.json) | |
NextVersion=$(npx semver --increment=minor "$CurrentVersion") | |
Date=$(date +'%Y-%m-%d') | |
ChangelogEntry="# v$NextVersion / $Date\n\n- Update list" | |
ExistingChangelog=$(cat CHANGELOG.md) | |
echo -e "$ChangelogEntry\n\n$ExistingChangelog" >CHANGELOG.md | |
node -e "const p = require('./package.json'); \ | |
p.version = '$NextVersion';\ | |
require('fs').writeFileSync('./package.json', JSON.stringify(p, null, 2) + '\n');" | |
echo "NextVersion=$NextVersion" >>"$GITHUB_OUTPUT" | |
- if: steps.dirty.outputs.Dirty == 'true' | |
name: Publish changes | |
run: | | |
git add CHANGELOG.md package.json | |
git commit -m "Release v${{ steps.metadata.outputs.NextVersion }}" | |
git tag -a "${{ steps.metadata.outputs.NextVersion }}" HEAD -m "Release v${{ steps.metadata.outputs.NextVersion }}" | |
git push origin master --tags | |
npm config set "//registry.npmjs.org/:_authToken" "${{ secrets.NPM_TOKEN }}" | |
npm publish |