autodeploy.yml 3.4 KB

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