debian.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: Build Debian Package
  2. on:
  3. release:
  4. types: [published]
  5. workflow_dispatch:
  6. inputs:
  7. dput:
  8. description: 'Upload to PPA'
  9. required: true
  10. default: false
  11. type: boolean
  12. version:
  13. description: 'Version'
  14. required: false
  15. env:
  16. JAVA_VERSION: 19
  17. jobs:
  18. build:
  19. name: Build Debian Package
  20. runs-on: ubuntu-20.04
  21. steps:
  22. - uses: actions/checkout@v3
  23. with:
  24. fetch-depth: 0
  25. - name: Install build tools
  26. run: |
  27. sudo add-apt-repository ppa:coffeelibs/openjdk
  28. sudo apt-get update
  29. sudo apt-get install debhelper devscripts dput coffeelibs-jdk-19
  30. - name: Setup Java
  31. uses: actions/setup-java@v3
  32. with:
  33. distribution: 'zulu'
  34. java-version: ${{ env.JAVA_VERSION }}
  35. cache: 'maven'
  36. - id: versions
  37. name: Apply version information
  38. run: |
  39. if [[ $GITHUB_REF =~ refs/tags/[0-9]+\.[0-9]+\.[0-9]+.* ]]; then
  40. SEM_VER_STR=${GITHUB_REF##*/}
  41. mvn versions:set -DnewVersion=${SEM_VER_STR}
  42. elif [[ "${{ github.event.inputs.version }}" =~ [0-9]+\.[0-9]+\.[0-9]+.* ]]; then
  43. SEM_VER_STR="${{ github.event.inputs.version }}"
  44. mvn versions:set -DnewVersion=${SEM_VER_STR}
  45. else
  46. SEM_VER_STR=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
  47. fi
  48. SEM_VER_NUM=`echo ${SEM_VER_STR} | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/'`
  49. REVCOUNT=`git rev-list --count HEAD`
  50. echo "::set-output name=semVerStr::${SEM_VER_STR}"
  51. echo "::set-output name=semVerNum::${SEM_VER_NUM}"
  52. echo "::set-output name=revNum::${REVCOUNT}"
  53. echo "::set-output name=ppaVerStr::${SEM_VER_STR/-/\~}-${REVCOUNT}"
  54. - name: Validate Version
  55. uses: skymatic/semver-validation-action@v1
  56. with:
  57. version: ${{ steps.versions.outputs.semVerStr }}
  58. - name: Run maven
  59. run: mvn -B clean package -Pdependency-check,linux -DskipTests
  60. - name: Create orig.tar.gz with common/ libs/ mods/
  61. run: |
  62. mkdir pkgdir
  63. cp -r target/libs pkgdir
  64. cp -r target/mods pkgdir
  65. cp -r dist/linux/common/ pkgdir
  66. cp target/cryptomator-*.jar pkgdir/mods
  67. tar -cJf cryptomator_${{ steps.versions.outputs.ppaVerStr }}.orig.tar.xz -C pkgdir .
  68. - name: Patch and rename pkgdir
  69. run: |
  70. cp -r dist/linux/debian/ pkgdir
  71. export RFC2822_TIMESTAMP=`date --rfc-2822`
  72. envsubst '${SEMVER_STR} ${VERSION_NUM} ${REVISION_NUM}' < dist/linux/debian/rules > pkgdir/debian/rules
  73. envsubst '${PPA_VERSION} ${RFC2822_TIMESTAMP}' < dist/linux/debian/changelog > pkgdir/debian/changelog
  74. find . -name "*.jar" >> pkgdir/debian/source/include-binaries
  75. mv pkgdir cryptomator_${{ steps.versions.outputs.ppaVerStr }}
  76. env:
  77. SEMVER_STR: ${{ steps.versions.outputs.semVerStr }}
  78. VERSION_NUM: ${{ steps.versions.outputs.semVerNum }}
  79. REVISION_NUM: ${{ steps.versions.outputs.revNum }}
  80. PPA_VERSION: ${{ steps.versions.outputs.ppaVerStr }}-0ppa1
  81. - name: Prepare GPG-Agent for signing with key 615D449FE6E6A235
  82. run: |
  83. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  84. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --dry-run --sign README.md
  85. env:
  86. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  87. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  88. - name: debuild
  89. run: |
  90. debuild -S -sa -d
  91. debuild -b -sa -d
  92. env:
  93. DEBSIGN_PROGRAM: gpg --batch --pinentry-mode loopback
  94. DEBSIGN_KEYID: 615D449FE6E6A235
  95. working-directory: cryptomator_${{ steps.versions.outputs.ppaVerStr }}
  96. - name: Create detached GPG signatures
  97. run: |
  98. gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator_*_amd64.deb
  99. - name: Upload artifacts
  100. uses: actions/upload-artifact@v3
  101. with:
  102. name: linux-deb-package
  103. path: |
  104. cryptomator_*.dsc
  105. cryptomator_*.orig.tar.xz
  106. cryptomator_*.debian.tar.xz
  107. cryptomator_*_source.buildinfo
  108. cryptomator_*_source.changes
  109. cryptomator_*_amd64.deb
  110. cryptomator_*.asc
  111. - name: Publish on PPA
  112. if: startsWith(github.ref, 'refs/tags/') || inputs.dput
  113. run: dput ppa:sebastian-stenzel/cryptomator-beta cryptomator_*_source.changes
  114. - name: Publish Debian package on GitHub Releases
  115. if: startsWith(github.ref, 'refs/tags/')
  116. uses: softprops/action-gh-release@v1
  117. with:
  118. fail_on_unmatched_files: true
  119. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  120. files: |
  121. cryptomator_*_amd64.deb
  122. cryptomator_*.asc