Version Increment #2
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
## See https://github.com/marella/material-symbols/blob/main/.github/workflows/update.yml where inspiration for this script came from | |
name: Version Increment | |
on: | |
schedule: | |
- cron: '23 1 * * MON' # Runs at 01:23 UTC on Monday | |
workflow_dispatch: | |
inputs: | |
force: | |
description: Force Update | |
default: '0' | |
dry: | |
description: Dry Run | |
default: '1' | |
bump: | |
type: choice | |
description: Bump Version | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
env: | |
HAVE_GIT_DEPLOY_KEY: ${{ secrets.DEPLOY_KEY != '' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
- uses: git-actions/set-user@v1 | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
- uses: actions/setup-node@v4 #setup registry to github package repo | |
with: | |
node-version: 20 | |
- run: npm ci | |
- name: Update | |
run: | | |
force="${{ github.event.inputs.force }}" | |
dry="${{ github.event.inputs.dry }}" | |
bump="${{ github.event.inputs.bump }}" | |
if [ "$bump" = "" ]; then | |
bump="patch" | |
fi | |
# Bump Version | |
npm version "$bump" | |
- name: Push git tags | |
if: ${{ env.HAVE_GIT_DEPLOY_KEY == 'true' }} | |
run: | | |
dry="${{ github.event.inputs.dry }}" | |
# Push | |
if [ "$dry" = "1" ]; then | |
exit 0 | |
fi | |
git push --follow-tags | |
- name: Git Commit - Is Skipped | |
if: ${{ env.HAVE_GIT_DEPLOY_KEY != 'true' }} | |
run: | | |
echo "### Deployment config not configured" >> $GITHUB_STEP_SUMMARY | |
echo "secrets.DEPLOY_KEY not existing, npm version can't be pushed" >> $GITHUB_STEP_SUMMARY | |
echo "If this is a fork, please setup your own personal service account to publish to your own repo" >> $GITHUB_STEP_SUMMARY | |
echo "## We recommend using a service account with the least permissions necessary." >> $GITHUB_STEP_SUMMARY | |
echo "[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)" >> $GITHUB_STEP_SUMMARY |