|
1 | 1 | name: Publish to npm |
| 2 | + |
2 | 3 | on: |
3 | 4 | push: |
4 | 5 | branches: |
|
8 | 9 | jobs: |
9 | 10 | publish: |
10 | 11 | runs-on: ubuntu-latest |
| 12 | + |
11 | 13 | steps: |
12 | | - - uses: actions/checkout@v1 |
13 | | - - uses: actions/setup-node@v1 |
| 14 | + - uses: actions/checkout@v3 |
| 15 | + |
| 16 | + - uses: actions/setup-node@v3 |
14 | 17 | with: |
15 | 18 | node-version: 20 |
16 | | - - run: cd ./packages/core |
| 19 | + registry-url: 'https://registry.npmjs.org' |
17 | 20 |
|
18 | | - - name: Create .env file |
| 21 | + - name: Set up .npmrc |
19 | 22 | run: | |
20 | | - echo "VITE_HELIUS_API_KEY=${{ secrets.VITE_HELIUS_API_KEY }}" >> .env |
| 23 | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc |
21 | 24 |
|
22 | | - - run: cd ../../ |
23 | | - - run: yarn |
24 | | - - run: yarn build |
| 25 | + - name: Create .env file |
| 26 | + run: echo "VITE_HELIUS_API_KEY=${{ secrets.VITE_HELIUS_API_KEY }}" >> .env |
25 | 27 |
|
26 | | - - name: Authenticate with npm |
| 28 | + - name: Install dependencies |
| 29 | + run: yarn |
| 30 | + |
| 31 | + - name: Build all packages |
| 32 | + run: yarn build |
| 33 | + |
| 34 | + - name: Detect changes in @ecency/sdk |
| 35 | + id: detect_sdk |
27 | 36 | run: | |
28 | | - echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc |
| 37 | + git fetch --depth=2 origin ${{ github.ref_name }} |
| 38 | + if git diff --quiet origin/${{ github.ref_name }}...HEAD -- packages/core; then |
| 39 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 40 | + else |
| 41 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Detect changes in @ecency/sdk-wallets |
| 45 | + id: detect_wallets |
| 46 | + run: | |
| 47 | + git fetch --depth=2 origin ${{ github.ref_name }} |
| 48 | + if git diff --quiet origin/${{ github.ref_name }}...HEAD -- packages/wallets; then |
| 49 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 50 | + else |
| 51 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 52 | + fi |
29 | 53 |
|
30 | 54 | - name: Publish @ecency/sdk |
| 55 | + if: steps.detect_sdk.outputs.changed == 'true' |
31 | 56 | run: | |
32 | 57 | cd packages/core |
33 | 58 | npm publish --access public |
34 | 59 |
|
35 | 60 | - name: Publish @ecency/sdk-wallets |
| 61 | + if: steps.detect_wallets.outputs.changed == 'true' |
36 | 62 | run: | |
37 | 63 | cd packages/wallets |
38 | 64 | npm publish --access public |
0 commit comments