93 lines
3.6 KiB
YAML
93 lines
3.6 KiB
YAML
name: Upload release assets
|
|
on:
|
|
release:
|
|
types:
|
|
- published
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
type: string
|
|
required: true
|
|
publish_release_artefacts:
|
|
type: boolean
|
|
required: true
|
|
default: false
|
|
|
|
jobs:
|
|
upload:
|
|
runs-on: ubuntu-20.04
|
|
strategy:
|
|
fail-fast: false
|
|
steps:
|
|
- uses: aws-actions/configure-aws-credentials@v1-node16
|
|
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 }}
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ github.event.inputs.tag }}
|
|
- name: Detect profile
|
|
id: profile
|
|
run: |
|
|
if git describe --tags --match '[v|e]*' --exact; then
|
|
REF=$(git describe --tags --match '[v|e]*' --exact)
|
|
else
|
|
echo "Only release tags matching '[v|e]*' are supported"
|
|
exit 1
|
|
fi
|
|
case "$REF" in
|
|
v*)
|
|
echo "profile=emqx" >> $GITHUB_OUTPUT
|
|
echo "version=$(./pkg-vsn.sh emqx)" >> $GITHUB_OUTPUT
|
|
echo "s3dir=emqx-ce" >> $GITHUB_OUTPUT
|
|
;;
|
|
e*)
|
|
echo "profile=emqx-enterprise" >> $GITHUB_OUTPUT
|
|
echo "version=$(./pkg-vsn.sh emqx-enterprise)" >> $GITHUB_OUTPUT
|
|
echo "s3dir=emqx-ee" >> $GITHUB_OUTPUT
|
|
;;
|
|
esac
|
|
- name: Get packages
|
|
run: |
|
|
BUCKET=${{ secrets.AWS_S3_BUCKET }}
|
|
OUTPUT_DIR=${{ steps.profile.outputs.s3dir }}
|
|
aws s3 cp --recursive s3://$BUCKET/$OUTPUT_DIR/${{ github.ref_name }} packages
|
|
cd packages
|
|
DEFAULT_BEAM_PLATFORM='otp24.3.4.2-1'
|
|
# all packages including full-name and default-name are uploaded to s3
|
|
# but we only upload default-name packages (and elixir) as github artifacts
|
|
# so we rename (overwrite) non-default packages before uploading
|
|
while read -r fname; do
|
|
default_fname=$(echo "$fname" | sed "s/-${DEFAULT_BEAM_PLATFORM}//g")
|
|
echo "$fname -> $default_fname"
|
|
mv -f "$fname" "$default_fname"
|
|
done < <(find . -maxdepth 1 -type f | grep -E "emqx(-enterprise)?-5\.[0-9]+\.[0-9]+.*-${DEFAULT_BEAM_PLATFORM}" | grep -v elixir)
|
|
- uses: alexellis/upload-assets@0.4.0
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
with:
|
|
asset_paths: '["packages/*"]'
|
|
- name: update to emqx.io
|
|
if: github.event_name == 'release' || inputs.publish_release_artefacts
|
|
run: |
|
|
set -e -x -u
|
|
curl -w %{http_code} \
|
|
--insecure \
|
|
-H "Content-Type: application/json" \
|
|
-H "token: ${{ secrets.EMQX_IO_TOKEN }}" \
|
|
-X POST \
|
|
-d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ github.ref_name }}\" }" \
|
|
${{ secrets.EMQX_IO_RELEASE_API }}
|
|
- name: update homebrew packages
|
|
if: steps.profile.outputs.profile == 'emqx' && (github.event_name == 'release' || inputs.publish_release_artefacts)
|
|
run: |
|
|
if [ -z $(echo $version | grep -oE "(alpha|beta|rc)\.[0-9]") ]; then
|
|
curl --silent --show-error \
|
|
-H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
-X POST \
|
|
-d "{\"ref\":\"v1.0.4\",\"inputs\":{\"version\": \"${{ github.ref_name }}\"}}" \
|
|
"https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_homebrew.yaml/dispatches"
|
|
fi
|