ci: build only one profile at a time

This commit is contained in:
Zaiming (Stone) Shi 2022-06-18 00:40:03 +02:00
parent 12b96702f4
commit 536b056b01
2 changed files with 54 additions and 33 deletions

View File

@ -23,10 +23,10 @@ jobs:
container: "ghcr.io/emqx/emqx-builder/5.0-16:1.13.4-24.2.1-1-ubuntu20.04" container: "ghcr.io/emqx/emqx-builder/5.0-16:1.13.4-24.2.1-1-ubuntu20.04"
outputs: outputs:
BUILD_PROFILES: ${{ steps.get_profiles.outputs.BUILD_PROFILES }} BUILD_PROFILE: ${{ steps.get_profile.outputs.BUILD_PROFILE }}
IS_DOCKER_LATEST: ${{ steps.get_profiles.outputs.IS_DOCKER_LATEST }} IS_DOCKER_LATEST: ${{ steps.get_profile.outputs.IS_DOCKER_LATEST }}
IS_EXACT_TAG: ${{ steps.get_profiles.outputs.IS_EXACT_TAG }} IS_EXACT_TAG: ${{ steps.get_profile.outputs.IS_EXACT_TAG }}
DOCKER_TAG_VERSION: ${{ steps.get_profiles.outputs.DOCKER_TAG_VERSION }} DOCKER_TAG_VERSION: ${{ steps.get_profile.outputs.DOCKER_TAG_VERSION }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -36,7 +36,7 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Get profiles to build - name: Get profiles to build
id: get_profiles id: get_profile
run: | run: |
cd source cd source
tag=${{ github.ref }} tag=${{ github.ref }}
@ -48,17 +48,19 @@ jobs:
fi fi
echo "::set-output name=IS_DOCKER_LATEST::${docker_latest}" echo "::set-output name=IS_DOCKER_LATEST::${docker_latest}"
if git describe --tags --match "[v|e]*" --exact; then if git describe --tags --match "[v|e]*" --exact; then
echo "This is an exact git tag, will publish images"
is_exact='true' is_exact='true'
else else
echo "This is NOT an exact git tag, will not publish images"
is_exact='false' is_exact='false'
fi fi
echo "::set-output name=IS_EXACT_TAG::${is_exact}" echo "::set-output name=IS_EXACT_TAG::${is_exact}"
case $tag in case $tag in
refs/tags/v*) refs/tags/v*)
echo "::set-output name=BUILD_PROFILES::[\"emqx\"]" PROFILE='emqx'
;; ;;
refs/tags/e*) refs/tags/e*)
echo "::set-output name=BUILD_PROFILES::[\"emqx-enterprise\"]" PROFILE=emqx-enterprise
;; ;;
*) *)
PROFILE=${{ github.event.inputs.profile }} PROFILE=${{ github.event.inputs.profile }}
@ -74,12 +76,12 @@ jobs:
exit 1 exit 1
;; ;;
esac esac
echo "::set-output name=BUILD_PROFILES::[\"$PROFILE\"]" ;;
esac
echo "::set-output name=BUILD_PROFILE::$PROFILE"
VSN="$(./pkg-vsn.sh "$PROFILE")" VSN="$(./pkg-vsn.sh "$PROFILE")"
echo "Building $PROFILE image with tag $VSN (latest=$docker_latest)" echo "Building $PROFILE image with tag $VSN (latest=$docker_latest)"
echo "::set-output name=DOCKER_TAG_VERSION::$VSN" echo "::set-output name=DOCKER_TAG_VERSION::$VSN"
;;
esac
- name: get_all_deps - name: get_all_deps
run: | run: |
make -C source deps-all make -C source deps-all
@ -99,7 +101,8 @@ jobs:
os: os:
- [alpine3.15.1, "alpine:3.15.1", "deploy/docker/Dockerfile.alpine"] - [alpine3.15.1, "alpine:3.15.1", "deploy/docker/Dockerfile.alpine"]
- [debian11, "debian:11-slim", "deploy/docker/Dockerfile"] - [debian11, "debian:11-slim", "deploy/docker/Dockerfile"]
profile: ${{ fromJson(needs.prepare.outputs.BUILD_PROFILES) }} profile:
- ${{ needs.prepare.outputs.BUILD_PROFILE }}
# NOTE: for docker, only support latest otp and elixir # NOTE: for docker, only support latest otp and elixir
# versions, not a matrix # versions, not a matrix
otp: otp:
@ -226,7 +229,8 @@ jobs:
os: os:
- [alpine3.15.1, "alpine:3.15.1", "deploy/docker/Dockerfile.alpine"] - [alpine3.15.1, "alpine:3.15.1", "deploy/docker/Dockerfile.alpine"]
- [debian11, "debian:11-slim", "deploy/docker/Dockerfile"] - [debian11, "debian:11-slim", "deploy/docker/Dockerfile"]
profile: ${{ fromJson(needs.prepare.outputs.BUILD_PROFILES) }} profile:
- ${{ needs.prepare.outputs.BUILD_PROFILE }}
# NOTE: for docker, only support latest otp version, not a matrix # NOTE: for docker, only support latest otp version, not a matrix
otp: otp:
- 24.2.1-1 # update to latest - 24.2.1-1 # update to latest

View File

@ -20,37 +20,54 @@ on:
jobs: jobs:
prepare: prepare:
runs-on: ubuntu-20.04
# prepare source with any OTP version, no need for a matrix
container: "ghcr.io/emqx/emqx-builder/5.0-16:1.13.4-24.2.1-1-ubuntu20.04"
outputs: outputs:
BUILD_PROFILES: ${{ steps.get_profiles.outputs.BUILD_PROFILES }} BUILD_PROFILE: ${{ steps.get_profile.outputs.BUILD_PROFILE }}
IS_EXACT_TAG: ${{ steps.get_profile.outputs.IS_EXACT_TAG }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
ref: ${{ github.event.inputs.which_branch }} ref: ${{ github.event.inputs.branch_or_tag }} # when input is not given, the event tag is used
path: source path: source
fetch-depth: 0 fetch-depth: 0
- name: Get profiles to build - name: Get profile to build
id: get_profiles id: get_profile
run: | run: |
cd source
tag=${{ github.ref }} tag=${{ github.ref }}
if git describe --tags --match "[v|e]*" --exact; then
echo "This is an exact git tag, will publish release"
is_exact='true'
else
echo "This is NOT an exact git tag, will not publish release"
is_exact='false'
fi
echo "::set-output name=IS_EXACT_TAG::${is_exact}"
case $tag in case $tag in
refs/tags/v*) refs/tags/v*)
echo "::set-output name=BUILD_PROFILES::[\"emqx\"]" PROFILE='emqx'
;; ;;
refs/tags/e*) refs/tags/e*)
echo "::set-output name=BUILD_PROFILES::[\"emqx-enterprise\"]" PROFILE=emqx-enterprise
;; ;;
*) *)
echo "Not a tag? $tag. Trying to build with manual input args" PROFILE=${{ github.event.inputs.profile }}
# this is for testing ? case "$PROFILE" in
echo "::set-output name=BUILD_PROFILES::[\"emqx\",\"emqx-enterprise\"]" emqx)
true
;;
emqx-enterprise)
true
;;
*)
echo "ERROR: Failed to resolve build profile"
exit 1
;; ;;
esac esac
;;
esac
echo "::set-output name=BUILD_PROFILE::$PROFILE"
- name: get_all_deps - name: get_all_deps
run: | run: |
make -C source deps-all make -C source deps-all
@ -113,7 +130,8 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
profile: ${{ fromJson(needs.prepare.outputs.BUILD_PROFILES) }} profile:
- ${{ needs.prepare.outputs.BUILD_PROFILE }}
otp: otp:
- 24.2.1-1 - 24.2.1-1
os: os:
@ -198,7 +216,8 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
profile: ${{ fromJson(needs.prepare.outputs.BUILD_PROFILES) }} profile:
- ${{ needs.prepare.outputs.BUILD_PROFILE }}
otp: otp:
- 24.2.1-1 # we test with OTP 23, but only build package on OTP 24 versions - 24.2.1-1 # we test with OTP 23, but only build package on OTP 24 versions
elixir: elixir:
@ -316,15 +335,13 @@ jobs:
publish_artifacts: publish_artifacts:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/')
needs: [prepare, mac, linux, docker] needs: [prepare, mac, linux, docker]
if: ${{ needs.prepare.outputs.IS_EXACT_TAG }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
profile: ${{ fromJson(needs.prepare.outputs.BUILD_PROFILES) }} profile:
- ${{ needs.prepare.outputs.BUILD_PROFILE }}
otp: otp:
- 24.2.1-1 - 24.2.1-1
include: include: