Merge pull request #11422 from id/0810-ci-fix-publishing-packages

This commit is contained in:
Ivan Dyachkov 2023-08-10 12:04:32 +02:00 committed by GitHub
commit b3082c3f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 90 additions and 25 deletions

View File

@ -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

View File

@ -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

12
build
View File

@ -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}")

29
scripts/semver.sh Executable file
View File

@ -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 <<EOF
{"major": ${MAJOR}, "minor": ${MINOR}, "patch": ${PATCH}, "special": "${SPECIAL}"}
EOF
;;
esac
}
parseSemver "$1" "$2"

View File

@ -7,13 +7,13 @@ exit_code=0
for test in shelltest/*.test; do
echo "Running $test"
/bin/sh "${test%.test}.setup"
[ -f "${test%.test}.setup" ] && /bin/sh "${test%.test}.setup"
shelltest -c --diff --all --precise -- "$test"
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
exit_code=1
fi
/bin/sh "${test%.test}.cleanup"
[ -f "${test%.test}.cleanup" ] && /bin/sh "${test%.test}.cleanup"
done
exit $exit_code

View File

@ -0,0 +1,32 @@
./semver.sh 5.2.0.1
>>>= 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