You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

181 lines
5.1 KiB

  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-wheels:
  79. name: Build wheels on ${{ matrix.os }}
  80. runs-on: ${{ matrix.os }}
  81. strategy:
  82. matrix:
  83. os: [ubuntu-20.04, macos-10.15]
  84. is_pr:
  85. - ${{ startsWith(github.ref, 'refs/pull/') }}
  86. exclude:
  87. # Don't build macos wheels on PR CI.
  88. - is_pr: true
  89. os: "macos-10.15"
  90. steps:
  91. - uses: actions/checkout@v3
  92. - uses: actions/setup-python@v3
  93. - name: Install cibuildwheel
  94. run: python -m pip install cibuildwheel==2.9.0 poetry==1.2.0
  95. # Only build a single wheel in CI.
  96. - name: Set env vars.
  97. run: |
  98. echo "CIBW_BUILD="cp37-manylinux_x86_64"" >> $GITHUB_ENV
  99. if: startsWith(github.ref, 'refs/pull/')
  100. - name: Build wheels
  101. run: python -m cibuildwheel --output-dir wheelhouse
  102. env:
  103. # Skip testing for platforms which various libraries don't have wheels
  104. # for, and so need extra build deps.
  105. CIBW_TEST_SKIP: pp39-* *i686* *musl* pp37-macosx*
  106. - uses: actions/upload-artifact@v3
  107. with:
  108. name: Wheel
  109. path: ./wheelhouse/*.whl
  110. build-sdist:
  111. name: Build sdist
  112. runs-on: ubuntu-latest
  113. if: ${{ !startsWith(github.ref, 'refs/pull/') }}
  114. steps:
  115. - uses: actions/checkout@v3
  116. - uses: actions/setup-python@v4
  117. with:
  118. python-version: '3.10'
  119. - run: pip install build
  120. - name: Build sdist
  121. run: python -m build --sdist
  122. - uses: actions/upload-artifact@v2
  123. with:
  124. name: Sdist
  125. path: dist/*.tar.gz
  126. # if it's a tag, create a release and attach the artifacts to it
  127. attach-assets:
  128. name: "Attach assets to release"
  129. if: ${{ !failure() && !cancelled() && startsWith(github.ref, 'refs/tags/') }}
  130. needs:
  131. - build-debs
  132. - build-wheels
  133. - build-sdist
  134. runs-on: ubuntu-latest
  135. steps:
  136. - name: Download all workflow run artifacts
  137. uses: actions/download-artifact@v2
  138. - name: Build a tarball for the debs
  139. run: tar -cvJf debs.tar.xz debs
  140. - name: Attach to release
  141. uses: softprops/action-gh-release@a929a66f232c1b11af63782948aa2210f981808a # PR#109
  142. env:
  143. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  144. with:
  145. files: |
  146. Sdist/*
  147. Wheel/*
  148. debs.tar.xz
  149. # if it's not already published, keep the release as a draft.
  150. draft: true
  151. # mark it as a prerelease if the tag contains 'rc'.
  152. prerelease: ${{ contains(github.ref, 'rc') }}