Skip to content

Build and Publish

Build and Publish #426

name: Build and Publish
on:
schedule:
- cron: '0 0 * * *' # This will run the action daily at midnight.
workflow_dispatch: # This allows for manual triggering of the workflow.
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
env:
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
- name: Check for changes
run: |
git diff --quiet && exit 0 || echo "Changes detected!"
- name: Run Tests
run: npm test
- name: Commit changes before npm publish
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git commit -m "Build artifacts" || echo "No changes to commit"
git push
- name: Publish to npm
run: npm version minor --force && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Commit changes after npm publish
run: |
git add -A
git commit -m "Bump version in package.json" || echo "No changes to commit"
git push