-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (43 loc) · 1.35 KB
/
build_and_publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
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