diff --git a/.github/workflows/_push-entrypoint.yaml b/.github/workflows/_push-entrypoint.yaml index a65df1234..32f3ae15a 100644 --- a/.github/workflows/_push-entrypoint.yaml +++ b/.github/workflows/_push-entrypoint.yaml @@ -82,20 +82,8 @@ jobs: echo "ct-host=${CT_HOST}" | tee -a $GITHUB_OUTPUT echo "ct-docker=${CT_DOCKER}" | tee -a $GITHUB_OUTPUT - build_slim_packages: - if: ${{ needs.prepare.outputs.release != 'true' }} - needs: - - prepare - uses: ./.github/workflows/build_slim_packages.yaml - with: - runner: ${{ needs.prepare.outputs.runner }} - builder: ${{ needs.prepare.outputs.builder }} - builder_vsn: ${{ needs.prepare.outputs.builder_vsn }} - otp_vsn: ${{ needs.prepare.outputs.otp_vsn }} - elixir_vsn: ${{ needs.prepare.outputs.elixir_vsn }} - build_packages: - if: ${{ needs.prepare.outputs.release == 'true' }} + if: needs.prepare.outputs.release == 'true' needs: - prepare uses: ./.github/workflows/build_packages.yaml @@ -109,7 +97,7 @@ jobs: secrets: inherit build_and_push_docker_images: - if: ${{ needs.prepare.outputs.release == 'true' }} + if: needs.prepare.outputs.release == 'true' needs: - prepare uses: ./.github/workflows/build_and_push_docker_images.yaml @@ -124,7 +112,20 @@ jobs: runner: ${{ needs.prepare.outputs.runner }} secrets: inherit + build_slim_packages: + if: needs.prepare.outputs.release != 'true' + needs: + - prepare + uses: ./.github/workflows/build_slim_packages.yaml + with: + runner: ${{ needs.prepare.outputs.runner }} + builder: ${{ needs.prepare.outputs.builder }} + builder_vsn: ${{ needs.prepare.outputs.builder_vsn }} + otp_vsn: ${{ needs.prepare.outputs.otp_vsn }} + elixir_vsn: ${{ needs.prepare.outputs.elixir_vsn }} + compile: + if: needs.prepare.outputs.release != 'true' runs-on: ${{ needs.prepare.outputs.runner }} container: ${{ needs.prepare.outputs.builder }} needs: @@ -157,6 +158,7 @@ jobs: retention-days: 1 run_test_cases: + if: needs.prepare.outputs.release != 'true' needs: - prepare - compile @@ -169,6 +171,7 @@ jobs: ct-docker: ${{ needs.prepare.outputs.ct-docker }} run_conf_tests: + if: needs.prepare.outputs.release != 'true' needs: - prepare - compile @@ -178,6 +181,7 @@ jobs: builder: ${{ needs.prepare.outputs.builder }} static_checks: + if: needs.prepare.outputs.release != 'true' needs: - prepare - compile diff --git a/.github/workflows/build_packages.yaml b/.github/workflows/build_packages.yaml index cbe95b974..d33d46f11 100644 --- a/.github/workflows/build_packages.yaml +++ b/.github/workflows/build_packages.yaml @@ -264,7 +264,7 @@ jobs: path: _packages/${{ matrix.profile }}/ publish_artifacts: - runs-on: ${{ inputs.runner }} + runs-on: ubuntu-latest needs: - mac - linux @@ -280,7 +280,7 @@ jobs: name: ${{ matrix.profile }} path: packages/${{ matrix.profile }} - name: install dos2unix - run: apt-get update && apt install -y dos2unix + run: sudo apt-get update && sudo apt install -y dos2unix - name: get packages run: | set -eu @@ -300,7 +300,7 @@ jobs: env: PROFILE: ${{ matrix.profile }} run: | - set -e -u + set -eu if [ $PROFILE = 'emqx' ]; then s3dir='emqx-ce' elif [ $PROFILE = 'emqx-enterprise' ]; then diff --git a/build b/build index 50b3fd861..34f7e8edb 100755 --- a/build +++ b/build @@ -378,11 +378,11 @@ make_docker() { local EMQX_DOCKERFILE="${EMQX_DOCKERFILE:-deploy/docker/Dockerfile}" local PKG_VSN="${PKG_VSN:-$(./pkg-vsn.sh)}" # shellcheck disable=SC2155 - local VSN_MAJOR="$(echo "$PKG_VSN" | cut -d . -f 1)" + local VSN_MAJOR="$(scripts/semver.sh "$PKG_VSN" --major)" # shellcheck disable=SC2155 - local VSN_MINOR="$(echo "$PKG_VSN" | cut -d . -f 2)" + local VSN_MINOR="$(scripts/semver.sh "$PKG_VSN" --minor)" # shellcheck disable=SC2155 - local VSN_PATCH="$(echo "$PKG_VSN" | cut -d . -f 3)" + local VSN_MINOR="$(scripts/semver.sh "$PKG_VSN" --patch)" local SUFFIX='' if [[ "$PROFILE" = *-elixir ]]; then SUFFIX="-elixir" @@ -430,8 +430,6 @@ make_docker() { --label org.opencontainers.image.licenses="${LICENSE}" \ --label org.opencontainers.image.otp.version="${EMQX_BUILDER_OTP}" \ --tag "${EMQX_IMAGE_TAG}" \ - --tag "${EMQX_BASE_DOCKER_TAG}:${VSN_MAJOR}.${VSN_MINOR}${SUFFIX}" \ - --tag "${EMQX_BASE_DOCKER_TAG}:${VSN_MAJOR}.${VSN_MINOR}.${VSN_PATCH}${SUFFIX}" \ --provenance false \ --pull ) @@ -442,7 +440,9 @@ make_docker() { DOCKER_BUILDX_ARGS+=(--label org.opencontainers.image.elixir.version="${EMQX_BUILDER_ELIXIR}") fi if [ "${DOCKER_LATEST:-false}" = true ]; then - DOCKER_BUILDX_ARGS+=(--tag "${DOCKER_REGISTRY}/${DOCKER_ORG}/${PROFILE}:latest${SUFFIX}") + DOCKER_BUILDX_ARGS+=(--tag "${EMQX_BASE_DOCKER_TAG}:latest${SUFFIX}") + DOCKER_BUILDX_ARGS+=(--tag "${EMQX_BASE_DOCKER_TAG}:${VSN_MAJOR}.${VSN_MINOR}${SUFFIX}") + DOCKER_BUILDX_ARGS+=(--tag "${EMQX_BASE_DOCKER_TAG}:${VSN_MAJOR}.${VSN_MINOR}.${VSN_PATCH}${SUFFIX}") fi if [ "${DOCKER_PLATFORMS:-default}" != 'default' ]; then DOCKER_BUILDX_ARGS+=(--platform "${DOCKER_PLATFORMS}") diff --git a/scripts/semver.sh b/scripts/semver.sh new file mode 100755 index 000000000..065241355 --- /dev/null +++ b/scripts/semver.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e + +function parseSemver() { + local RE='^([0-9]+)\.([0-9]+)\.([0-9]+)(-([a-z]+\.[0-9]+))?$' + echo "$1" | grep -qE "$RE" || exit 1 + #shellcheck disable=SC2155 + local MAJOR=$( echo "$1" | sed -r "s#$RE#\1#") + #shellcheck disable=SC2155 + local MINOR=$( echo "$1" | sed -r "s#$RE#\2#") + #shellcheck disable=SC2155 + local PATCH=$( echo "$1" | sed -r "s#$RE#\3#") + #shellcheck disable=SC2155 + local SPECIAL=$(echo "$1" | sed -r "s#$RE#\5#") + case "${2}" in + --major) echo "${MAJOR}" ;; + --minor) echo "${MINOR}" ;; + --patch) echo "${PATCH}" ;; + --special) echo "${SPECIAL}" ;; + *) + cat <>>= 1 + +./semver.sh 5.1.0 +>>> +{"major": 5, "minor": 1, "patch": 0, "special": ""} +>>>= 0 + +./semver.sh 5.1.0-patch.3 +>>> +{"major": 5, "minor": 1, "patch": 0, "special": "patch.3"} +>>>= 0 + +./semver.sh 5.1.0-patch.3 --major +>>> +5 +>>>= 0 + +./semver.sh 5.1.0-patch.3 --minor +>>> +1 +>>>= 0 + +./semver.sh 5.1.0-patch.3 --patch +>>> +0 +>>>= 0 + +./semver.sh 5.1.0-patch.3 --special +>>> +patch.3 +>>>= 0