build-release.yaml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. name: Build Release
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. release-tag:
  6. description: 'Release Tag (v2.x.x)'
  7. required: true
  8. jobs:
  9. BuildRelease:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Checkout Repository
  13. uses: actions/checkout@v3
  14. with:
  15. fetch-depth: 0
  16. - name: Checkout submodules
  17. run: git submodule update --init --recursive --remote
  18. - name: Setup Java
  19. uses: actions/setup-java@v3
  20. with:
  21. distribution: 'zulu'
  22. java-version: 17
  23. - name: Setup Go
  24. uses: actions/setup-go@v3
  25. with:
  26. go-version: "1.20"
  27. - uses: actions/cache@v3
  28. with:
  29. path: |
  30. ~/.cache/go-build
  31. ~/go/pkg/mod
  32. key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
  33. restore-keys: |
  34. ${{ runner.os }}-go-
  35. - name: Convert and set version env
  36. id: process-version
  37. run: |
  38. VERSION_TAG=${{ inputs.release-tag }}
  39. VERSION_TAG=${VERSION_TAG#v} # remove the 'v' prefix
  40. IFS='.' read -ra VERSION_PARTS <<< "$VERSION_TAG" # split into array
  41. VERSION_CODE=$(printf "%1d%02d%03d" "${VERSION_PARTS[0]}" "${VERSION_PARTS[1]}" "${VERSION_PARTS[2]}")
  42. echo "versonName=$VERSION_TAG" >> $GITHUB_OUTPUT # "1.2.3"
  43. echo "versonCode=$VERSION_CODE" >> $GITHUB_OUTPUT # "102003"
  44. # Re-write version in build.gradle.kts
  45. - name: Re-write version
  46. uses: Devofure/advance-android-version-actions@v1.4
  47. with:
  48. gradlePath: build.gradle.kts
  49. versionCode: ${{ steps.process-version.outputs.versonCode }}
  50. versionName: ${{ steps.process-version.outputs.versonName }}
  51. # If any change found, commit it and push
  52. - name: Commit and push if changes
  53. run: |
  54. changes=$(git diff --name-only origin/main | wc -l)
  55. if [ $changes -gt 0 ]
  56. then
  57. newVersionName=${{ steps.process-version.outputs.versonName }}
  58. newVersionCode=${{ steps.process-version.outputs.versonCode }}
  59. git config --global user.name 'GitHub Action'
  60. git config --global user.email 'action@github.com'
  61. git add build.gradle.kts
  62. git commit -am "Bump version to $newVersionName ($newVersionCode)"
  63. git tag "v$newVersionName"
  64. git push --follow-tags
  65. fi
  66. - name: Signing properties
  67. env:
  68. SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
  69. SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
  70. SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
  71. run: |
  72. touch signing.properties
  73. echo keystore.password="$SIGNING_STORE_PASSWORD" > signing.properties
  74. echo key.alias="$SIGNING_KEY_ALIAS" >> signing.properties
  75. echo key.password="$SIGNING_KEY_PASSWORD" >> signing.properties
  76. echo "cat signing.properties"
  77. cat signing.properties
  78. - name: Release Build
  79. if: success()
  80. uses: gradle/gradle-build-action@v2
  81. with:
  82. arguments: --no-daemon app:assembleMetaRelease
  83. - name: Tag Repo
  84. uses: richardsimko/update-tag@v1
  85. with:
  86. tag_name: ${{ inputs.release-tag }}
  87. env:
  88. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  89. - name: Upload Release
  90. uses: softprops/action-gh-release@v1
  91. if: ${{ success() }}
  92. with:
  93. tag_name: ${{ inputs.release-tag }}
  94. files: app/build/outputs/apk/meta/release/*
  95. generate_release_notes: true
  96. - name: Release Changelog Builder
  97. uses: mikepenz/release-changelog-builder-action@v3.6.0
  98. with:
  99. configurationJson: |
  100. {
  101. "ignore_labels": [
  102. "Update"
  103. ],
  104. }