2021-07-12 17:20:11 -06:00
|
|
|
# GitHub actions workflow which builds the release artifacts.
|
2021-07-12 12:03:14 -06:00
|
|
|
|
2021-07-12 17:20:11 -06:00
|
|
|
name: Build release artifacts
|
2021-07-12 12:03:14 -06:00
|
|
|
|
|
|
|
on:
|
2021-07-14 07:41:23 -06:00
|
|
|
# we build on PRs and develop to (hopefully) get early warning
|
|
|
|
# of things breaking (but only build one set of debs)
|
|
|
|
pull_request:
|
2021-07-12 12:03:14 -06:00
|
|
|
push:
|
2022-02-22 04:33:37 -07:00
|
|
|
branches: ["develop", "release-*"]
|
2021-07-12 12:03:14 -06:00
|
|
|
|
2021-07-14 07:41:23 -06:00
|
|
|
# we do the full build on tags.
|
2021-07-12 17:20:11 -06:00
|
|
|
tags: ["v*"]
|
|
|
|
|
2021-07-22 04:35:06 -06:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2021-07-12 12:03:14 -06:00
|
|
|
permissions:
|
2021-07-13 04:50:14 -06:00
|
|
|
contents: write
|
2021-07-12 12:03:14 -06:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
get-distros:
|
2021-07-14 07:41:23 -06:00
|
|
|
name: "Calculate list of debian distros"
|
2021-07-12 12:03:14 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
- id: set-distros
|
|
|
|
run: |
|
2021-07-14 07:41:23 -06:00
|
|
|
# if we're running from a tag, get the full list of distros; otherwise just use debian:sid
|
|
|
|
dists='["debian:sid"]'
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
2022-03-02 11:00:26 -07:00
|
|
|
dists=$(scripts-dev/build_debian_packages.py --show-dists-json)
|
2021-07-14 07:41:23 -06:00
|
|
|
fi
|
|
|
|
echo "::set-output name=distros::$dists"
|
2021-07-12 12:03:14 -06:00
|
|
|
# map the step outputs to job outputs
|
|
|
|
outputs:
|
|
|
|
distros: ${{ steps.set-distros.outputs.distros }}
|
|
|
|
|
|
|
|
# now build the packages with a matrix build.
|
|
|
|
build-debs:
|
|
|
|
needs: get-distros
|
|
|
|
name: "Build .deb packages"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
distro: ${{ fromJson(needs.get-distros.outputs.distros) }}
|
|
|
|
|
|
|
|
steps:
|
2021-07-26 04:36:01 -06:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2021-07-12 12:03:14 -06:00
|
|
|
with:
|
|
|
|
path: src
|
2021-07-26 04:36:01 -06:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
with:
|
|
|
|
install: true
|
|
|
|
|
|
|
|
- name: Set up docker layer caching
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
|
|
|
|
- name: Set up python
|
|
|
|
uses: actions/setup-python@v2
|
|
|
|
|
|
|
|
- name: Build the packages
|
|
|
|
# see https://github.com/docker/build-push-action/issues/252
|
|
|
|
# for the cache magic here
|
|
|
|
run: |
|
2022-03-02 11:00:26 -07:00
|
|
|
./src/scripts-dev/build_debian_packages.py \
|
2021-07-26 04:36:01 -06:00
|
|
|
--docker-build-arg=--cache-from=type=local,src=/tmp/.buildx-cache \
|
|
|
|
--docker-build-arg=--cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-new \
|
|
|
|
--docker-build-arg=--progress=plain \
|
|
|
|
--docker-build-arg=--load \
|
|
|
|
"${{ matrix.distro }}"
|
|
|
|
rm -rf /tmp/.buildx-cache
|
|
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
|
|
|
|
|
|
- name: Upload debs as artifacts
|
|
|
|
uses: actions/upload-artifact@v2
|
2021-07-12 12:03:14 -06:00
|
|
|
with:
|
2021-07-12 17:20:11 -06:00
|
|
|
name: debs
|
2021-07-12 12:03:14 -06:00
|
|
|
path: debs/*
|
2021-07-12 17:20:11 -06:00
|
|
|
|
|
|
|
build-sdist:
|
|
|
|
name: "Build pypi distribution files"
|
2022-02-22 04:33:37 -07:00
|
|
|
uses: "matrix-org/backend-meta/.github/workflows/packaging.yml@v1"
|
2021-07-13 04:50:14 -06:00
|
|
|
|
|
|
|
# if it's a tag, create a release and attach the artifacts to it
|
|
|
|
attach-assets:
|
|
|
|
name: "Attach assets to release"
|
2021-07-14 07:41:23 -06:00
|
|
|
if: ${{ !failure() && !cancelled() && startsWith(github.ref, 'refs/tags/') }}
|
2021-07-13 04:50:14 -06:00
|
|
|
needs:
|
|
|
|
- build-debs
|
|
|
|
- build-sdist
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Download all workflow run artifacts
|
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
- name: Build a tarball for the debs
|
|
|
|
run: tar -cvJf debs.tar.xz debs
|
|
|
|
- name: Attach to release
|
|
|
|
uses: softprops/action-gh-release@a929a66f232c1b11af63782948aa2210f981808a # PR#109
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
files: |
|
2022-03-08 08:11:50 -07:00
|
|
|
Sdist/*
|
|
|
|
Wheel/*
|
2021-07-13 04:50:14 -06:00
|
|
|
debs.tar.xz
|
|
|
|
# if it's not already published, keep the release as a draft.
|
|
|
|
draft: true
|
|
|
|
# mark it as a prerelease if the tag contains 'rc'.
|
|
|
|
prerelease: ${{ contains(github.ref, 'rc') }}
|