Cross build packages #5332
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cross build packages | |
concurrency: | |
group: build-packages-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_call: | |
inputs: | |
profile: | |
required: true | |
type: string | |
publish: | |
required: true | |
type: boolean | |
otp_vsn: | |
required: true | |
type: string | |
elixir_vsn: | |
required: true | |
type: string | |
builder_vsn: | |
required: true | |
type: string | |
secrets: | |
AWS_ACCESS_KEY_ID: | |
required: true | |
AWS_SECRET_ACCESS_KEY: | |
required: true | |
AWS_DEFAULT_REGION: | |
required: true | |
AWS_S3_BUCKET: | |
required: true | |
AWS_CLOUDFRONT_ID: | |
required: true | |
APPLE_ID_PASSWORD: | |
required: true | |
APPLE_DEVELOPER_IDENTITY: | |
required: true | |
APPLE_DEVELOPER_ID_BUNDLE: | |
required: true | |
APPLE_DEVELOPER_ID_BUNDLE_PASSWORD: | |
required: true | |
workflow_dispatch: | |
inputs: | |
ref: | |
required: false | |
profile: | |
required: false | |
publish: | |
required: false | |
type: boolean | |
default: false | |
otp_vsn: | |
required: false | |
type: string | |
default: '26.2.1-2' | |
elixir_vsn: | |
required: false | |
type: string | |
default: '1.15.7' | |
builder_vsn: | |
required: false | |
type: string | |
default: '5.3-2' | |
permissions: | |
contents: read | |
jobs: | |
mac: | |
strategy: | |
fail-fast: false | |
matrix: | |
profile: | |
- ${{ inputs.profile }} | |
os: | |
- macos-12 | |
- macos-12-arm64 | |
- macos-13 | |
otp: | |
- ${{ inputs.otp_vsn }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
ref: ${{ github.event.inputs.ref }} | |
fetch-depth: 0 | |
- uses: ./.github/actions/package-macos | |
with: | |
profile: ${{ matrix.profile }} | |
otp: ${{ matrix.otp }} | |
os: ${{ matrix.os }} | |
apple_id_password: ${{ secrets.APPLE_ID_PASSWORD }} | |
apple_developer_identity: ${{ secrets.APPLE_DEVELOPER_IDENTITY }} | |
apple_developer_id_bundle: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE }} | |
apple_developer_id_bundle_password: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE_PASSWORD }} | |
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 | |
if: success() | |
with: | |
name: ${{ matrix.profile }}-${{ matrix.os }}-${{ matrix.otp }} | |
path: _packages/${{ matrix.profile }}/ | |
retention-days: 7 | |
linux: | |
runs-on: [self-hosted, ephemeral, linux, "${{ matrix.arch == 'arm64' && 'arm64' || 'x64' }}"] | |
strategy: | |
fail-fast: false | |
matrix: | |
profile: | |
- ${{ inputs.profile }} | |
os: | |
- ubuntu22.04 | |
- ubuntu20.04 | |
- ubuntu18.04 | |
- debian12 | |
- debian11 | |
- debian10 | |
- el9 | |
- el8 | |
- el7 | |
- amzn2 | |
- amzn2023 | |
arch: | |
- amd64 | |
- arm64 | |
with_elixir: | |
- 'no' | |
otp: | |
- ${{ inputs.otp_vsn }} | |
builder: | |
- ${{ inputs.builder_vsn }} | |
elixir: | |
- ${{ inputs.elixir_vsn }} | |
include: | |
- profile: ${{ inputs.profile }} | |
os: ubuntu22.04 | |
arch: amd64 | |
with_elixir: 'yes' | |
otp: ${{ inputs.otp_vsn }} | |
builder: ${{ inputs.builder_vsn }} | |
elixir: ${{ inputs.elixir_vsn }} | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
ref: ${{ github.event.inputs.ref }} | |
fetch-depth: 0 | |
- name: build emqx packages | |
env: | |
PROFILE: ${{ matrix.profile }} | |
ARCH: ${{ matrix.arch }} | |
OS: ${{ matrix.os }} | |
IS_ELIXIR: ${{ matrix.with_elixir }} | |
BUILDER: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}" | |
BUILDER_SYSTEM: force_docker | |
run: | | |
./scripts/buildx.sh \ | |
--profile $PROFILE \ | |
--arch $ARCH \ | |
--builder $BUILDER \ | |
--elixir $IS_ELIXIR \ | |
--pkgtype pkg | |
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 | |
with: | |
name: ${{ matrix.profile }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.with_elixir == 'yes' && '-elixir' || '' }}-${{ matrix.builder }}-${{ matrix.otp }}-${{ matrix.elixir }} | |
path: _packages/${{ matrix.profile }}/ | |
retention-days: 7 | |
publish_artifacts: | |
runs-on: ubuntu-latest | |
needs: | |
- mac | |
- linux | |
if: inputs.publish | |
strategy: | |
fail-fast: false | |
matrix: | |
profile: | |
- ${{ inputs.profile }} | |
steps: | |
- uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 | |
with: | |
pattern: "${{ matrix.profile }}-*" | |
path: packages/${{ matrix.profile }} | |
merge-multiple: true | |
- name: install dos2unix | |
run: sudo apt-get update -y && sudo apt install -y dos2unix | |
- name: get packages | |
run: | | |
set -eu | |
cd packages/${{ matrix.profile }} | |
# fix the .sha256 file format | |
for var in $(ls | grep emqx | grep -v sha256); do | |
dos2unix $var.sha256 | |
echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1 | |
done | |
cd - | |
- uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: upload to aws s3 | |
env: | |
PROFILE: ${{ matrix.profile }} | |
REF_NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref_name }} | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
AWS_CLOUDFRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID }} | |
run: | | |
set -eu | |
if [ $PROFILE = 'emqx' ]; then | |
s3dir='emqx-ce' | |
elif [ $PROFILE = 'emqx-enterprise' ]; then | |
s3dir='emqx-ee' | |
else | |
echo "unknown profile $PROFILE" | |
exit 1 | |
fi | |
aws s3 cp --recursive packages/$PROFILE s3://$AWS_S3_BUCKET/$s3dir/$REF_NAME | |
aws cloudfront create-invalidation --distribution-id "$AWS_CLOUDFRONT_ID" --paths "/$s3dir/$REF_NAME/*" |