|
1 |
| -name: Publish to NPM |
| 1 | +name: Publish nopalm to npm registry |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - main
|
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
7 | 10 |
|
8 | 11 | jobs:
|
9 |
| - release: |
| 12 | + versioning: |
10 | 13 | runs-on: ubuntu-latest
|
11 |
| - |
12 | 14 | steps:
|
13 |
| - - name: Checkout repository |
14 |
| - uses: actions/checkout@v3 |
| 15 | + # Checkout the code |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v2 |
15 | 18 |
|
16 |
| - - name: Setup Node.js |
| 19 | + # Set up Node.js environment |
| 20 | + - name: Set up Node.js |
17 | 21 | uses: actions/setup-node@v3
|
18 | 22 | with:
|
19 | 23 | node-version: '20'
|
20 |
| - cache: 'yarn' |
21 | 24 |
|
| 25 | + # Install dependencies |
22 | 26 | - name: Install dependencies
|
23 |
| - run: yarn install |
| 27 | + run: yarn install --frozen-lockfile --production |
24 | 28 |
|
25 |
| - - name: Automate versioning and changelog |
26 |
| - id: version |
27 |
| - uses: actions-ecosystem/action-update-semver@v2 |
28 |
| - with: |
29 |
| - update_type: auto # Options: major, minor, patch, or auto |
| 29 | + # Run linting |
| 30 | + - name: Run lint |
| 31 | + run: yarn lint |
30 | 32 |
|
31 |
| - - name: Set Yarn version |
32 |
| - run: yarn version --new-version ${{ steps.version.outputs.new_version }} --no-git-tag-version |
| 33 | + # Run tests |
| 34 | + - name: Run tests |
| 35 | + run: yarn test |
33 | 36 |
|
34 |
| - - name: Publish to NPM |
35 |
| - env: |
36 |
| - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
37 |
| - run: yarn publish --non-interactive |
| 37 | + # Build production version of react client |
| 38 | + - name: Build client |
| 39 | + run: yarn build-client |
38 | 40 |
|
39 |
| - - name: Push changes back to repo |
| 41 | + # Semantic release step: Automatically determine the version and release |
| 42 | + - name: Semantic Release for versioning |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
40 | 46 | run: |
|
41 |
| - git config user.name "github-actions[bot]" |
42 |
| - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
43 |
| - git add package.json yarn.lock |
44 |
| - git commit -m "chore(release): publish ${{ steps.version.outputs.new_version }}" |
45 |
| - git tag v${{ steps.version.outputs.new_version }} |
46 |
| - git push --follow-tags |
| 47 | + yarn release |
| 48 | +
|
| 49 | + # Optionally, you can include a job to deploy to npm |
| 50 | + publish: |
| 51 | + needs: release |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + # Publish to npm |
| 55 | + - name: Publish to npm |
| 56 | + run: yarn publish --non-interactive |
| 57 | + env: |
| 58 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments