|
1 | | -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created |
2 | | -# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages |
3 | | - |
4 | | -name: Publish Mesh SDK Contract |
| 1 | +name: Publish Package |
5 | 2 |
|
6 | 3 | on: |
7 | 4 | pull_request: |
|
13 | 10 | jobs: |
14 | 11 | build: |
15 | 12 | runs-on: ubuntu-latest |
| 13 | + if: github.event.pull_request.merged == true |
16 | 14 | strategy: |
17 | 15 | matrix: |
18 | 16 | node-version: [20] |
19 | 17 | steps: |
20 | 18 | - uses: actions/checkout@v4 |
21 | 19 | - name: Use Node.js ${{ matrix.node-version }} |
22 | 20 | uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: ${{ matrix.node-version }} |
23 | 23 | - name: Install dependencies |
24 | 24 | run: npm install |
25 | 25 | - name: Lint |
|
29 | 29 |
|
30 | 30 | check-version: |
31 | 31 | runs-on: ubuntu-latest |
| 32 | + needs: [build] |
32 | 33 | if: github.event.pull_request.merged == true |
33 | 34 | outputs: |
34 | 35 | version-updated: ${{ steps.compare-versions.outputs.version-updated }} |
|
38 | 39 | with: |
39 | 40 | ref: ${{ github.event.pull_request.base.sha }} |
40 | 41 |
|
41 | | - - name: Get package version from main branch before merge |
| 42 | + - name: Get version before merge |
42 | 43 | id: pre-merge-version |
43 | 44 | run: | |
44 | 45 | PRE_MERGE_VERSION=$(node -p "require('./package.json').version") |
|
47 | 48 | - name: Checkout main branch at commit after merge |
48 | 49 | uses: actions/checkout@v4 |
49 | 50 | with: |
50 | | - ref: "main" |
| 51 | + ref: main |
51 | 52 |
|
52 | | - - name: Get package version from main branch after merge |
| 53 | + - name: Get version after merge |
53 | 54 | id: post-merge-version |
54 | 55 | run: | |
55 | 56 | POST_MERGE_VERSION=$(node -p "require('./package.json').version") |
|
64 | 65 | echo "version-updated=false" >> "$GITHUB_OUTPUT" |
65 | 66 | fi |
66 | 67 |
|
67 | | - publish-meshsdk-contract: |
| 68 | + publish: |
68 | 69 | needs: [build, check-version] |
69 | 70 | if: needs.check-version.outputs.version-updated == 'true' |
70 | 71 | runs-on: ubuntu-latest |
|
74 | 75 | with: |
75 | 76 | node-version: 20 |
76 | 77 | registry-url: https://registry.npmjs.org/ |
77 | | - - run: npm install && npm run build |
| 78 | + - run: npm install |
| 79 | + - run: npm run build |
78 | 80 | - run: npm publish --access public |
79 | 81 | env: |
80 | | - NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
| 82 | + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} |
0 commit comments