2019-11-21 11:18:54 +01:00
|
|
|
---
|
|
|
|
on:
|
2022-06-09 11:50:20 +02:00
|
|
|
schedule:
|
2022-11-08 21:16:47 +01:00
|
|
|
- cron: '0 4 * * *' # Every day at 4:00am
|
2019-11-21 11:18:54 +01:00
|
|
|
push:
|
2022-12-01 12:48:01 +01:00
|
|
|
# Will run for every tag pushed except `latest`
|
|
|
|
# When the `latest` git tag is created with this [CI](../latest-git-tag.yml)
|
|
|
|
# we don't need to create a Docker `latest` image again.
|
|
|
|
# The `latest` Docker image push is already done in this CI when releasing a stable version of Meilisearch.
|
|
|
|
tags-ignore:
|
|
|
|
- latest
|
2019-11-21 11:18:54 +01:00
|
|
|
|
2022-06-09 11:50:20 +02:00
|
|
|
name: Publish tagged images to Docker Hub
|
2019-11-21 11:18:54 +01:00
|
|
|
|
|
|
|
jobs:
|
2022-06-08 17:17:20 +02:00
|
|
|
docker:
|
2021-12-21 18:32:29 +01:00
|
|
|
runs-on: docker
|
2019-11-21 11:18:54 +01:00
|
|
|
steps:
|
2022-09-02 16:45:32 +02:00
|
|
|
- uses: actions/checkout@v3
|
2022-06-16 19:27:27 +02:00
|
|
|
|
|
|
|
# Check if the tag has the v<nmumber>.<number>.<number> format. If yes, it means we are publishing an official release.
|
|
|
|
# In this situation, we need to set `output.stable` to create/update the following tags (additionally to the `vX.Y.Z` Docker tag):
|
|
|
|
# - a `vX.Y` (without patch version) Docker tag
|
|
|
|
# - a `latest` Docker tag
|
|
|
|
- name: Check tag format
|
|
|
|
if: github.event_name != 'schedule'
|
|
|
|
id: check-tag-format
|
|
|
|
run: |
|
|
|
|
escaped_tag=$(printf "%q" ${{ github.ref_name }})
|
|
|
|
|
|
|
|
if [[ $escaped_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
2022-11-10 10:40:16 +01:00
|
|
|
echo "stable=true" >> $GITHUB_OUTPUT
|
2022-06-16 19:27:27 +02:00
|
|
|
else
|
2022-11-10 10:40:21 +01:00
|
|
|
echo "stable=false" >> $GITHUB_OUTPUT
|
2022-06-16 19:27:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check only the validity of the tag for official releases (not for pre-releases or other tags)
|
|
|
|
- name: Check release validity
|
2022-06-23 19:14:39 +02:00
|
|
|
if: github.event_name != 'schedule' && steps.check-tag-format.outputs.stable == 'true'
|
|
|
|
run: bash .github/scripts/check-release.sh
|
2022-06-16 19:27:27 +02:00
|
|
|
|
2022-12-06 21:44:31 +01:00
|
|
|
- name: Set build-args for Docker buildx
|
|
|
|
id: build-metadata
|
|
|
|
run: |
|
|
|
|
# Extract commit date
|
|
|
|
commit_date=$(git show -s --format=%cd --date=iso-strict ${{ github.sha }})
|
|
|
|
|
|
|
|
echo "date=$commit_date" >> $GITHUB_OUTPUT
|
|
|
|
|
2021-11-11 15:57:06 +01:00
|
|
|
- name: Set up QEMU
|
2022-06-28 22:21:38 +02:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2021-11-11 15:57:06 +01:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2022-06-28 22:21:43 +02:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2021-11-11 15:57:06 +01:00
|
|
|
|
2022-06-16 19:27:27 +02:00
|
|
|
- name: Login to Docker Hub
|
2022-06-09 11:50:20 +02:00
|
|
|
if: github.event_name != 'schedule'
|
2022-07-01 19:06:38 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-11-11 19:42:30 +01:00
|
|
|
with:
|
2022-06-20 14:39:50 +02:00
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2021-11-11 19:42:30 +01:00
|
|
|
|
2021-11-11 15:57:06 +01:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
2022-06-28 22:21:32 +02:00
|
|
|
uses: docker/metadata-action@v4
|
2021-11-11 15:57:06 +01:00
|
|
|
with:
|
2021-11-11 19:42:30 +01:00
|
|
|
images: getmeili/meilisearch
|
2022-09-20 16:39:35 +02:00
|
|
|
# The latest and `vX.Y` tags are only pushed for the official Meilisearch releases
|
2022-06-08 17:17:20 +02:00
|
|
|
# See https://github.com/docker/metadata-action#latest-tag
|
2021-11-11 15:57:06 +01:00
|
|
|
flavor: latest=false
|
2022-06-08 17:17:20 +02:00
|
|
|
tags: |
|
|
|
|
type=ref,event=tag
|
2022-06-23 19:14:39 +02:00
|
|
|
type=semver,pattern=v{{major}}.{{minor}},enable=${{ steps.check-tag-format.outputs.stable == 'true' }}
|
|
|
|
type=raw,value=latest,enable=${{ steps.check-tag-format.outputs.stable == 'true' }}
|
2021-11-11 15:57:06 +01:00
|
|
|
|
|
|
|
- name: Build and push
|
2022-07-01 19:06:44 +02:00
|
|
|
uses: docker/build-push-action@v3
|
2019-11-21 11:18:54 +01:00
|
|
|
with:
|
2022-06-09 11:50:20 +02:00
|
|
|
# We do not push tags for the cron jobs, this is only for test purposes
|
|
|
|
push: ${{ github.event_name != 'schedule' }}
|
2021-11-11 16:28:30 +01:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2021-11-11 15:57:06 +01:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
2022-12-06 21:44:31 +01:00
|
|
|
build-args: |
|
|
|
|
COMMIT_SHA=${{ github.sha }}
|
|
|
|
COMMIT_DATE=${{ steps.build-metadata.outputs.date }}
|
2022-09-21 11:03:01 +02:00
|
|
|
|
|
|
|
# /!\ Don't touch this without checking with Cloud team
|
|
|
|
- name: Send CI information to Cloud team
|
|
|
|
if: github.event_name != 'schedule'
|
|
|
|
uses: peter-evans/repository-dispatch@v2
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.MEILI_BOT_GH_PAT }}
|
|
|
|
repository: meilisearch/meilisearch-cloud
|
|
|
|
event-type: cloud-docker-build
|
2022-10-12 09:36:01 +02:00
|
|
|
client-payload: '{ "meilisearch_version": "${{ github.ref_name }}", "stable": "${{ steps.check-tag-format.outputs.stable }}" }'
|