debian.yml 4.9 KB

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