release-artifacts.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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", "release-*"]
  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.py --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.py \
  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. uses: "matrix-org/backend-meta/.github/workflows/packaging.yml@v1"
  81. # if it's a tag, create a release and attach the artifacts to it
  82. attach-assets:
  83. name: "Attach assets to release"
  84. if: ${{ !failure() && !cancelled() && startsWith(github.ref, 'refs/tags/') }}
  85. needs:
  86. - build-debs
  87. - build-sdist
  88. runs-on: ubuntu-latest
  89. steps:
  90. - name: Download all workflow run artifacts
  91. uses: actions/download-artifact@v2
  92. - name: Build a tarball for the debs
  93. run: tar -cvJf debs.tar.xz debs
  94. - name: Attach to release
  95. uses: softprops/action-gh-release@a929a66f232c1b11af63782948aa2210f981808a # PR#109
  96. env:
  97. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  98. with:
  99. files: |
  100. Sdist/*
  101. Wheel/*
  102. debs.tar.xz
  103. # if it's not already published, keep the release as a draft.
  104. draft: true
  105. # mark it as a prerelease if the tag contains 'rc'.
  106. prerelease: ${{ contains(github.ref, 'rc') }}