release-artifacts.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. # GitHub actions workflow which builds the release artifacts.
  2. name: Build release artifacts
  3. on:
  4. # we build on PRs and develop to (hopefully) get early warning
  5. # of things breaking (but only build one set of debs)
  6. pull_request:
  7. push:
  8. branches: ["develop"]
  9. # we do the full build on tags.
  10. tags: ["v*"]
  11. concurrency:
  12. group: ${{ github.workflow }}-${{ github.ref }}
  13. cancel-in-progress: true
  14. permissions:
  15. contents: write
  16. jobs:
  17. get-distros:
  18. name: "Calculate list of debian distros"
  19. runs-on: ubuntu-latest
  20. steps:
  21. - uses: actions/checkout@v2
  22. - uses: actions/setup-python@v2
  23. - id: set-distros
  24. run: |
  25. # if we're running from a tag, get the full list of distros; otherwise just use debian:sid
  26. dists='["debian:sid"]'
  27. if [[ $GITHUB_REF == refs/tags/* ]]; then
  28. dists=$(scripts-dev/build_debian_packages --show-dists-json)
  29. fi
  30. echo "::set-output name=distros::$dists"
  31. # map the step outputs to job outputs
  32. outputs:
  33. distros: ${{ steps.set-distros.outputs.distros }}
  34. # now build the packages with a matrix build.
  35. build-debs:
  36. needs: get-distros
  37. name: "Build .deb packages"
  38. runs-on: ubuntu-latest
  39. strategy:
  40. matrix:
  41. distro: ${{ fromJson(needs.get-distros.outputs.distros) }}
  42. steps:
  43. - name: Checkout
  44. uses: actions/checkout@v2
  45. with:
  46. path: src
  47. - name: Set up Docker Buildx
  48. id: buildx
  49. uses: docker/setup-buildx-action@v1
  50. with:
  51. install: true
  52. - name: Set up docker layer caching
  53. uses: actions/cache@v2
  54. with:
  55. path: /tmp/.buildx-cache
  56. key: ${{ runner.os }}-buildx-${{ github.sha }}
  57. restore-keys: |
  58. ${{ runner.os }}-buildx-
  59. - name: Set up python
  60. uses: actions/setup-python@v2
  61. - name: Build the packages
  62. # see https://github.com/docker/build-push-action/issues/252
  63. # for the cache magic here
  64. run: |
  65. ./src/scripts-dev/build_debian_packages \
  66. --docker-build-arg=--cache-from=type=local,src=/tmp/.buildx-cache \
  67. --docker-build-arg=--cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-new \
  68. --docker-build-arg=--progress=plain \
  69. --docker-build-arg=--load \
  70. "${{ matrix.distro }}"
  71. rm -rf /tmp/.buildx-cache
  72. mv /tmp/.buildx-cache-new /tmp/.buildx-cache
  73. - name: Upload debs as artifacts
  74. uses: actions/upload-artifact@v2
  75. with:
  76. name: debs
  77. path: debs/*
  78. build-sdist:
  79. name: "Build pypi distribution files"
  80. runs-on: ubuntu-latest
  81. steps:
  82. - uses: actions/checkout@v2
  83. - uses: actions/setup-python@v2
  84. - run: pip install wheel
  85. - run: |
  86. python setup.py sdist bdist_wheel
  87. - uses: actions/upload-artifact@v2
  88. with:
  89. name: python-dist
  90. path: dist/*
  91. # if it's a tag, create a release and attach the artifacts to it
  92. attach-assets:
  93. name: "Attach assets to release"
  94. if: ${{ !failure() && !cancelled() && startsWith(github.ref, 'refs/tags/') }}
  95. needs:
  96. - build-debs
  97. - build-sdist
  98. runs-on: ubuntu-latest
  99. steps:
  100. - name: Download all workflow run artifacts
  101. uses: actions/download-artifact@v2
  102. - name: Build a tarball for the debs
  103. run: tar -cvJf debs.tar.xz debs
  104. - name: Attach to release
  105. uses: softprops/action-gh-release@a929a66f232c1b11af63782948aa2210f981808a # PR#109
  106. env:
  107. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  108. with:
  109. files: |
  110. python-dist/*
  111. debs.tar.xz
  112. # if it's not already published, keep the release as a draft.
  113. draft: true
  114. # mark it as a prerelease if the tag contains 'rc'.
  115. prerelease: ${{ contains(github.ref, 'rc') }}