autodeploy.yml 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. name: AutoDeploy
  2. on:
  3. push:
  4. branches:
  5. - 'dev'
  6. - 'master'
  7. jobs:
  8. build:
  9. name: "Сборка и публикация версии 🔨"
  10. runs-on: ubuntu-latest
  11. permissions:
  12. contents: write
  13. steps:
  14. - name: Checkout code
  15. uses: actions/checkout@v4
  16. - name: Setup Node.js
  17. uses: actions/setup-node@v3
  18. with:
  19. node-version: '21'
  20. - name: Install pnpm
  21. run: npm -g i pnpm
  22. - name: Install dependencies
  23. run: pnpm i
  24. - name: Install semantic-release packages
  25. run: pnpm i @semantic-release/changelog @semantic-release/git @semantic-release/github
  26. - name: Get next release version (dry-run)
  27. id: get_version
  28. env:
  29. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  30. run: |
  31. # Run dry-run and save output to file
  32. npx semantic-release --dry-run --no-ci | tee release.log
  33. # Extract version (now supports pre-releases like -dev.23, -beta.5, etc.)
  34. NEXT_VERSION=$(grep 'The next release version is' release.log \
  35. | sed -E 's/.* ([0-9]+\.[0-9]+\.[0-9]+[-.0-9a-zA-Z]*).*$/\1/')
  36. echo "APP_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
  37. echo "Got version: $NEXT_VERSION"
  38. - name: Create .env file
  39. run: |
  40. echo "Writing..."
  41. echo "API_URL=https://hapticx.ru/api" >> .env
  42. echo "APP_VERSION=${APP_VERSION}" >> .env
  43. - name: Build android
  44. run: pnpm build:mobile
  45. - name: Upload APK artifact
  46. uses: actions/upload-artifact@v4
  47. with:
  48. name: "ktc-${{ env.APP_VERSION }}.apk"
  49. path: "${{ env.APP_VERSION }}.apk"
  50. if-no-files-found: 'error'
  51. retention-days: 1
  52. compression-level: 0
  53. - name: Publishing release
  54. run: npx semantic-release
  55. env:
  56. GH_TOKEN: ${{ secrets.GH_TOKEN }}
  57. # deploy_dev:
  58. # name: "Уведомление в Telegram 🔔"
  59. # runs-on: ubuntu-latest
  60. # needs: build
  61. # steps:
  62. # - uses: actions/checkout@v4
  63. # - name: Escape bad symbols in variables
  64. # id: escape_vars
  65. # run: |
  66. # escaped_message=$(echo "${{ github.event.head_commit.message }}" | perl -pe 's/([&~\`\*\_\[\]()#\+\-\=\|\{\}\.\!])/\\\\$1/g')
  67. # escaped_actor=$(echo "${{ github.actor }}" | perl -pe 's/([&~\`\*\_\[\]()#\+\-\=\|\{\}\.\!])/\\\\$1/g')
  68. # escaped_branch=$(echo "${{ github.ref_name }}" | perl -pe 's/([&~\`\*\_\[\]()#\+\-\=\|\{\}\.\!])/\\\\$1/g')
  69. # echo "escaped_message=$escaped_message" >> $GITHUB_ENV
  70. # echo "escaped_actor=$escaped_actor" >> $GITHUB_ENV
  71. # echo "escaped_branch=$escaped_branch" >> $GITHUB_ENV
  72. # - name: Send Telegram Message
  73. # run: |
  74. # curl \
  75. # --data-urlencode 'chat_id=${{ secrets.TELEGRAM_CHAT_ID }}' \
  76. # --data-urlencode 'message_thread_id=${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }}' \
  77. # --data-urlencode 'link_preview_options={"url":"${{ github.event.head_commit.url }}"}' \
  78. # --data-urlencode 'parse_mode=markdownv2' \
  79. # --data-urlencode $'text=🔨 *Frontend deploy* 🔨\n\n>${{ env.escaped_message }}\n_by [${{ env.escaped_actor }}](https://github.com/${{ env.escaped_actor }})_ at `${{ env.escaped_branch }}`\n\n[commit link](${{ github.event.head_commit.url }})' \
  80. # curl "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage"