pr-build.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. name: "PR Build"
  2. run-name: "PR Build ${{ inputs.DEPLOY_TARGET }} triggered by ${{ github.EVENT_NAME }} (@${{ github.ACTOR }})"
  3. on:
  4. pull_request:
  5. types: [opened, reopened]
  6. jobs:
  7. build-for-pr:
  8. runs-on: ubuntu-latest
  9. env:
  10. REPO_SELF: ${{ vars.REPO_SELF }}
  11. APP_PATH: "applications_user/subbrute"
  12. RELATIVE_PATH: "applications/external/subbrute"
  13. PREV_TAG: ""
  14. APP_NAME: ""
  15. ZIP_NAME: ""
  16. ZIP_TAG: ""
  17. TGZ_NAME: ""
  18. TGZ_TAG: ""
  19. SHA: ""
  20. FW_VERSION: ""
  21. RELEASE_VERSION: ""
  22. strategy:
  23. fail-fast: false
  24. matrix:
  25. firmware: [unlshd, official]
  26. include:
  27. - firmware: unlshd
  28. url: ${{ vars.REPO_UNLEASHED }}
  29. version: ${{ vars.FIRMWARE_VERSION }}
  30. src-included: 0
  31. - firmware: official
  32. url: ${{ vars.REPO_OFFICIAL }}
  33. version: official
  34. src-included: 0
  35. steps:
  36. - name: Copy Firmware Files
  37. uses: actions/checkout@v4
  38. with:
  39. repository: ${{ matrix.url }}
  40. clean: true
  41. submodules: true
  42. ref: dev
  43. - name: Copy Repo Files
  44. if: ${{ matrix.src-included == 0 }}
  45. uses: actions/checkout@v4
  46. with:
  47. repository: ${{ vars.REPO_SELF }}
  48. clean: true
  49. submodules: true
  50. path: ${{ env.APP_PATH }}
  51. - name: Remove other apps
  52. shell: pwsh
  53. # rm to remove problem FAP which includes non-existent files
  54. run: |
  55. Remove-Item -Force -Recurse ./applications/debug -ErrorAction SilentlyContinue
  56. Remove-Item -Force -Recurse ./applications/examples -ErrorAction SilentlyContinue
  57. Remove-Item -Force -Recurse ${{ env.RELATIVE_PATH }} -ErrorAction SilentlyContinue
  58. - name: Get SHA of our application and release version
  59. shell: pwsh
  60. env:
  61. GITHUB_TOKEN: ${{ secrets.FLIPPER_TOKEN }}
  62. INPUT_VERSION: ${{ inputs.version }}
  63. run: |
  64. Write-Output "::notice title=${{ matrix.firmware }} Input Version Number::v${{ inputs.version }}"
  65. $fwInfo = ((gh release view --json tagName,url -R ${{ matrix.url }}) | ConvertFrom-Json)
  66. cd '${{ env.APP_PATH }}'
  67. $sha = (git rev-parse --verify HEAD)
  68. $releaseVersion = ''
  69. $latestTag = ((gh release view --json tagName,url -R ${{ vars.REPO_SELF }}) | ConvertFrom-Json ).tagName
  70. if ( [string]::IsNullOrWhitespace($env:INPUT_VERSION) ) {
  71. Write-Output "::notice title=${{ matrix.firmware }} Latest tag::$latestTag"
  72. $lastIndex = $latestTag.LastIndexOf('.')
  73. $minorValue = $latestTag.Substring($latestTag.LastIndexOf('.') + 1)
  74. $minorValue = [Convert]::ToInt32($minorValue) + 1
  75. $newTag = $latestTag.Substring(0, $lastIndex)
  76. $releaseVersion = ('{0}.{1}' -f $newTag, $minorValue)
  77. } else {
  78. $releaseVersion = "$env:INPUT_VERSION"
  79. }
  80. if ( $releaseVersion.StartsWith('v') ) {
  81. $releaseVersion = $releaseVersion.Substring(1)
  82. }
  83. Write-Output "::notice title=${{ matrix.firmware }} PREV_TAG::$latestTag"
  84. Write-Output "::notice title=${{ matrix.firmware }} RELEASE_VERSION::$releaseVersion"
  85. Write-Output "::notice title=${{ matrix.firmware }} SHA::$sha"
  86. Write-Output ('::notice title=${{ matrix.firmware }} FW_VERSION::{0}' -f $fwInfo.tagName)
  87. Write-Output ('RELEASE_VERSION={0}' -f $releaseVersion) >> $env:GITHUB_ENV
  88. Write-Output ('SHA={0}' -f $sha) >> $env:GITHUB_ENV
  89. Write-Output ('FW_VERSION={0}' -f $fwInfo.tagName) >> $env:GITHUB_ENV
  90. Write-Output ('PREV_TAG={0}' -f $latestTag) >> $env:GITHUB_ENV
  91. - name: Build Firmware
  92. shell: bash
  93. if: ${{ success() }}
  94. env:
  95. FBT_NO_SYNC: 0
  96. DIST_SUFFIX: ${{ matrix.version }}
  97. WORKFLOW_BRANCH_OR_TAG: release-cfw
  98. run: |
  99. ./fbt COMPACT=1 DEBUG=0 FBT_NO_SYNC=0
  100. - name: Build FAPs
  101. shell: bash
  102. if: ${{ success() }}
  103. env:
  104. FBT_NO_SYNC: 0
  105. DIST_SUFFIX: ${{ matrix.version }}
  106. WORKFLOW_BRANCH_OR_TAG: release-cfw
  107. # rm to remove problem FAP which includes non-existent files
  108. run: |
  109. ./fbt COMPACT=1 DEBUG=0 FBT_NO_SYNC=0 fap_dist
  110. #EOF