build.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. name: build
  2. on:
  3. push:
  4. branches: ['*']
  5. tags: ['v[0-9]+.[0-9]+.[0-9]+']
  6. pull_request:
  7. jobs:
  8. build:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - name: Checkout
  12. uses: actions/checkout@v2
  13. - uses: actions/setup-node@v1
  14. with:
  15. node-version: 12
  16. - run: yarn install
  17. - run: cargo install zkutil
  18. - run: yarn circuit
  19. - run: yarn test
  20. - run: yarn lint
  21. - name: Telegram Failure Notification
  22. uses: appleboy/telegram-action@0.0.7
  23. if: failure()
  24. with:
  25. message: ❗ Build failed for [${{ github.repository }}](https://github.com/${{ github.repository }}/actions) because of ${{ github.actor }}
  26. format: markdown
  27. to: ${{ secrets.TELEGRAM_CHAT_ID }}
  28. token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
  29. publish:
  30. runs-on: ubuntu-latest
  31. needs: build
  32. if: startsWith(github.ref, 'refs/tags')
  33. steps:
  34. - name: Checkout
  35. uses: actions/checkout@v2
  36. - name: NPM login
  37. # NPM doesn't understand env vars and needs auth file lol
  38. run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
  39. env:
  40. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
  41. - name: Set vars
  42. id: vars
  43. run: |
  44. echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/v})"
  45. echo "::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/})"
  46. - name: Check package.json version vs tag
  47. run: |
  48. [ ${{ steps.vars.outputs.version }} = $(grep '"version":' package.json | grep -o "[0-9.]*") ] || (echo "Git tag doesn't match version in package.json" && false)
  49. - name: Publish to npm
  50. run: npm publish
  51. - name: Create GitHub Release Draft
  52. uses: actions/create-release@v1
  53. with:
  54. tag_name: ${{ github.ref }}
  55. release_name: Release ${{ steps.vars.outputs.version }}
  56. draft: true
  57. env:
  58. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  59. - name: Telegram Notification
  60. uses: appleboy/telegram-action@0.0.7
  61. with:
  62. message: 🚀 Published a [${{ steps.vars.outputs.repo_name }}](https://github.com/${{ github.repository }}) version [${{ steps.vars.outputs.version }}](https://hub.docker.com/repository/docker/${{ github.repository }}) to docker hub
  63. format: markdown
  64. to: ${{ secrets.TELEGRAM_CHAT_ID }}
  65. token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
  66. - name: Telegram Failure Notification
  67. uses: appleboy/telegram-action@0.0.7
  68. if: failure()
  69. with:
  70. message: ❗ Failed to publish [${{ steps.vars.outputs.repo_name }}](https://github.com/${{ github.repository }}/actions) because of ${{ github.actor }}
  71. format: markdown
  72. to: ${{ secrets.TELEGRAM_CHAT_ID }}
  73. token: ${{ secrets.TELEGRAM_BOT_TOKEN }}