create-new-release.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. name: Create new release
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. new_version:
  6. description: 'New version'
  7. required: true
  8. type: string
  9. jobs:
  10. set-new-version:
  11. runs-on: ubuntu-latest
  12. outputs:
  13. commit_hash: ${{steps.commit_new_version.outputs.commit_hash}}
  14. steps:
  15. - uses: actions/checkout@v3
  16. - name: Set new version format
  17. run: |
  18. if [[ "${{ inputs.new_version }}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]];
  19. then
  20. echo "New version looks okay";
  21. MAJOR="${BASH_REMATCH[1]}"
  22. MINOR="${BASH_REMATCH[2]}"
  23. PATCH="${BASH_REMATCH[3]}"
  24. sed -r -i "s/TOTP_APP_VERSION_MAJOR\\s+\\([0-9]+\\)/TOTP_APP_VERSION_MAJOR ($MAJOR)/g" totp/version.h
  25. sed -r -i "s/TOTP_APP_VERSION_MINOR\\s+\\([0-9]+\\)/TOTP_APP_VERSION_MINOR ($MINOR)/g" totp/version.h
  26. sed -r -i "s/TOTP_APP_VERSION_PATCH\\s+\\([0-9]+\\)/TOTP_APP_VERSION_PATCH ($PATCH)/g" totp/version.h
  27. sed -r -i "s/fap_version=\"[0-9]+\\.[0-9]+\"/fap_version=\"$MAJOR.$MINOR$PATCH\"/g" totp/application.fam
  28. else
  29. echo "Invalid version format";
  30. exit 1
  31. fi
  32. - id: commit_new_version
  33. uses: stefanzweifel/git-auto-commit-action@v4.16.0
  34. with:
  35. commit_message: Updated version
  36. push_options: '--force'
  37. build:
  38. runs-on: ubuntu-latest
  39. needs: set-new-version
  40. env:
  41. FBT_NO_SYNC: "true"
  42. TARGETS: f7
  43. DEFAULT_TARGET: f7
  44. steps:
  45. - name: 'Decontaminate previous build leftovers'
  46. run: |
  47. if [ -d .git ]; then
  48. git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
  49. fi
  50. - uses: actions/checkout@v3
  51. with:
  52. ref: "${{needs.set-new-version.outputs.commit_hash}}"
  53. fetch-depth: 0
  54. submodules: 'recursive'
  55. - name: Build
  56. run: ./build.ps1
  57. shell: pwsh
  58. - uses: ncipollo/release-action@v1.12.0
  59. with:
  60. artifacts: "build/*.zip,build/checksums.sha256"
  61. bodyFile: ".github/release-body.md"
  62. artifactErrorsFailBuild: true
  63. updateOnlyUnreleased: true
  64. allowUpdates: true
  65. removeArtifacts: true
  66. draft: true
  67. tag: "v${{ inputs.new_version }}"
  68. commit: "${{needs.set-new-version.outputs.commit_hash}}"