build-release.yaml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: Build Release
  2. on:
  3. push:
  4. tags:
  5. - '*' #
  6. workflow_dispatch:
  7. inputs:
  8. auto-bump-version:
  9. description: 'Auto bump project version before building release'
  10. required: false
  11. type: boolean
  12. jobs:
  13. BuildRelease:
  14. runs-on: ubuntu-latest
  15. steps:
  16. - name: Checkout Repository
  17. uses: actions/checkout@v3
  18. with:
  19. fetch-depth: 0
  20. - name: Checkout submodules
  21. run: git submodule update --init --recursive --remote
  22. - name: Setup Java
  23. uses: actions/setup-java@v3
  24. with:
  25. distribution: 'zulu'
  26. java-version: 17
  27. - name: Setup Go
  28. uses: actions/setup-go@v3
  29. with:
  30. go-version: "1.20"
  31. - uses: actions/cache@v3
  32. with:
  33. path: |
  34. ~/.cache/go-build
  35. ~/go/pkg/mod
  36. key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
  37. restore-keys: |
  38. ${{ runner.os }}-go-
  39. # If auto-bump-version is chosen BEGIN
  40. - name: Configure Git
  41. if: ${{ inputs.auto-bump-version }}
  42. run: |
  43. git config --global user.name 'GitHub Action'
  44. git config --global user.email 'action@github.com'
  45. - name: Auto bump project version
  46. if: ${{ inputs.auto-bump-version }}
  47. id: bump-version
  48. run: |
  49. versionCode=$(grep -oP 'versionCode = \K\d+' build.gradle.kts)
  50. versionName=$(grep -oP 'versionName = "\K[0-9.]+' build.gradle.kts)
  51. major=$(echo $versionName | cut -d. -f1)
  52. minor=$(echo $versionName | cut -d. -f2)
  53. patch=$(echo $versionName | cut -d. -f3)
  54. newPatch=$((patch + 1))
  55. newVersionName="$major.$minor.$newPatch"
  56. newVersionCode=$((versionCode + 1))
  57. sed -i "s/versionCode = $versionCode/versionCode = $newVersionCode/" build.gradle.kts
  58. sed -i "s/versionName = \"$versionName\"/versionName = \"$newVersionName\"/" build.gradle.kts
  59. echo "::set-output name=newVersionName::$newVersionName"
  60. echo "::set-output name=newVersionCode::$newVersionCode"
  61. - name: Commit modified version code and make new tag
  62. if: ${{ inputs.auto-bump-version }}
  63. run: |
  64. newVersionName=${{ steps.bump-version.outputs.newVersionName }}
  65. newVersionCode=${{ steps.bump-version.outputs.newVersionCode }}
  66. git commit -am "Bump version to $newVersionName ($newVersionCode)"
  67. git tag "v$newVersionName"
  68. git push --follow-tags
  69. # If auto-bump-version is chosen END
  70. - name: Signing properties
  71. env:
  72. SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
  73. SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
  74. SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
  75. run: |
  76. touch signing.properties
  77. echo keystore.password="$SIGNING_STORE_PASSWORD" > signing.properties
  78. echo key.alias="$SIGNING_KEY_ALIAS" >> signing.properties
  79. echo key.password="$SIGNING_KEY_PASSWORD" >> signing.properties
  80. echo "cat signing.properties"
  81. cat signing.properties
  82. - name: Release Build
  83. if: success()
  84. uses: gradle/gradle-build-action@v2
  85. with:
  86. arguments: --no-daemon app:assembleMetaRelease
  87. - name: Get real tag value (current or auto-bumped?)
  88. id: real_tag
  89. run: |
  90. if [[ "${{ inputs.auto-bump-version }}" == "true" ]]; then
  91. echo "::set-output name=tag::v${{ steps.bump-version.outputs.newVersionName }}"
  92. else
  93. echo "::set-output name=tag::$(git describe --tags --abbrev=0)"
  94. fi
  95. - name: Tag Repo
  96. uses: richardsimko/update-tag@v1
  97. with:
  98. tag_name: ${{ steps.real_tag.outputs.tag }}
  99. env:
  100. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  101. - name: Upload Release
  102. uses: softprops/action-gh-release@v1
  103. if: ${{ success() }}
  104. with:
  105. tag_name: ${{ steps.real_tag.outputs.tag }}
  106. files: app/build/outputs/apk/meta/release/*
  107. generate_release_notes: true
  108. - name: Release Changelog Builder
  109. uses: mikepenz/release-changelog-builder-action@v3.6.0