emqx/.github/workflows/build_packages.yaml

235 lines
7.3 KiB
YAML

name: Cross build packages
concurrency:
group: build-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
on:
schedule:
- cron: '0 */6 * * *'
push:
branches:
- 'ci/**'
tags:
- v*
- e*
workflow_dispatch:
inputs:
branch_or_tag:
required: false
profile:
required: false
jobs:
prepare:
runs-on: ubuntu-20.04
container: ghcr.io/emqx/emqx-builder/5.0-27:1.13.4-24.3.4.2-1-ubuntu20.04
outputs:
BUILD_PROFILE: ${{ steps.get_profile.outputs.BUILD_PROFILE }}
IS_EXACT_TAG: ${{ steps.get_profile.outputs.IS_EXACT_TAG }}
VERSION: ${{ steps.get_profile.outputs.VERSION }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch_or_tag }} # when input is not given, the event tag is used
path: source
fetch-depth: 0
- name: Get profile to build
id: get_profile
run: |
cd source
git config --global --add safe.directory "$(pwd)"
tag=${{ github.ref }}
if git describe --tags --match "[v|e]*" --exact; then
echo "WARN: This is an exact git tag, will publish release"
is_exact_tag='true'
else
echo "WARN: This is NOT an exact git tag, will not publish release"
is_exact_tag='false'
fi
echo "IS_EXACT_TAG=${is_exact_tag}" >> $GITHUB_OUTPUT
case $tag in
refs/tags/v*)
PROFILE='emqx'
;;
refs/tags/e*)
PROFILE=emqx-enterprise
;;
*)
PROFILE=${{ github.event.inputs.profile }}
case "$PROFILE" in
emqx)
true
;;
emqx-enterprise)
true
;;
*)
# maybe triggered from schedule
echo "WARN: \"$PROFILE\" is not a valid profile."
echo "building the default profile 'emqx' instead"
PROFILE='emqx'
;;
esac
;;
esac
echo "BUILD_PROFILE=$PROFILE" >> $GITHUB_OUTPUT
echo "VERSION=$(./pkg-vsn.sh $PROFILE)" >> $GITHUB_OUTPUT
- name: get_all_deps
run: |
make -C source deps-all
zip -ryq source.zip source/* source/.[^.]*
- uses: actions/upload-artifact@v3
with:
name: source
path: source.zip
linux:
needs: prepare
runs-on: ${{ matrix.build_machine }}
container:
image: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
profile:
- ${{ needs.prepare.outputs.BUILD_PROFILE }}
otp:
- 24.3.4.2-1
arch:
- amd64
- arm64
os:
- ubuntu20.04
- ubuntu18.04
- debian11
- debian10
- el8
- el7
- amzn2
build_machine:
- aws-arm64
- ubuntu-20.04
builder:
- 5.0-27
elixir:
- 1.13.4
exclude:
- arch: arm64
build_machine: ubuntu-20.04
- arch: amd64
build_machine: aws-arm64
include:
- profile: emqx
otp: 25.1.2-2
arch: amd64
os: ubuntu20.04
build_machine: ubuntu-20.04
builder: 5.0-27
elixir: 1.13.4
release_with: elixir
- profile: emqx
otp: 25.1.2-2
arch: amd64
os: amzn2
build_machine: ubuntu-20.04
builder: 5.0-27
elixir: 1.13.4
release_with: elixir
defaults:
run:
shell: bash
steps:
- uses: AutoModality/action-clean@v1
if: matrix.build_machine == 'aws-arm64'
- uses: actions/download-artifact@v3
with:
name: source
path: .
- name: unzip source code
run: unzip -q source.zip
- name: build emqx packages
working-directory: source
env:
ELIXIR: ${{ matrix.elixir }}
PROFILE: ${{ matrix.profile }}
run: |
set -eu
git config --global --add safe.directory "/__w/emqx/emqx"
export ACLOCAL_PATH="/usr/share/aclocal:/usr/local/share/aclocal"
# Align path for CMake caches
if [ ! "$PWD" = "/emqx" ]; then
ln -s $PWD /emqx
cd /emqx
fi
echo "pwd is $PWD"
if [ ${{ matrix.release_with }} == 'elixir' ]; then
make ${PROFILE}-elixir-tgz
./scripts/pkg-tests.sh ${PROFILE}-elixir-tgz
else
make ${PROFILE}-pkg
./scripts/pkg-tests.sh ${PROFILE}-pkg
fi
- uses: actions/upload-artifact@v3
if: success()
with:
name: ${{ matrix.profile }}
path: source/_packages/${{ matrix.profile }}/
- name: Send notification to Slack
uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.event_name == 'schedule'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
payload: |
{"text": "Scheduled run of ${{ github.workflow }}@${{ matrix.os }} failed: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}
packagecloud:
runs-on: ubuntu-20.04
needs: [prepare, linux]
strategy:
fail-fast: false
matrix:
profile:
- ${{ needs.prepare.outputs.BUILD_PROFILE }}
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.profile }}
path: packages/${{ matrix.profile }}
- name: Push to packagecloud.io
env:
PROFILE: ${{ needs.prepare.outputs.BUILD_PROFILE }}
VERSION: ${{ needs.prepare.outputs.VERSION }}
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
run: |
set -eu
REPO=$PROFILE
if [ $PROFILE = 'emqx-enterprise' ]; then
REPO='emqx-enterprise5'
fi
function push() {
docker run -t --rm -e PACKAGECLOUD_TOKEN=$PACKAGECLOUD_TOKEN -v $(pwd)/$2:/w/$2 -w /w ghcr.io/emqx/package_cloud push id/$REPO/$1 $2
}
push "debian/buster" "packages/$PROFILE/$PROFILE-$VERSION-debian10-amd64.deb"
push "debian/buster" "packages/$PROFILE/$PROFILE-$VERSION-debian10-arm64.deb"
push "debian/bullseye" "packages/$PROFILE/$PROFILE-$VERSION-debian11-amd64.deb"
push "debian/bullseye" packages/$PROFILE/$PROFILE-$VERSION-debian11-arm64.deb
push "ubuntu/bionic" "packages/$PROFILE/$PROFILE-$VERSION-ubuntu18.04-amd64.deb"
push "ubuntu/bionic" "packages/$PROFILE/$PROFILE-$VERSION-ubuntu18.04-arm64.deb"
push "ubuntu/focal" "packages/$PROFILE/$PROFILE-$VERSION-ubuntu20.04-amd64.deb"
push "ubuntu/focal" "packages/$PROFILE/$PROFILE-$VERSION-ubuntu20.04-arm64.deb"
push "el/7" "packages/$PROFILE/$PROFILE-$VERSION-el7-amd64.rpm"
push "el/7" "packages/$PROFILE/$PROFILE-$VERSION-el7-arm64.rpm"
push "el/8" "packages/$PROFILE/$PROFILE-$VERSION-el8-amd64.rpm"
push "el/8" "packages/$PROFILE/$PROFILE-$VERSION-el8-arm64.rpm"
push "el/6" "packages/$PROFILE/$PROFILE-$VERSION-amzn2-amd64.rpm"
push "el/6" "packages/$PROFILE/$PROFILE-$VERSION-amzn2-arm64.rpm"