build-release.yaml 4.2 KB

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