Build latest docker image #11
Workflow file for this run
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: Build latest docker image | |
on: | |
workflow_dispatch: | |
jobs: | |
prebuild: | |
runs-on: ubuntu-latest | |
outputs: | |
NEED_BUILD_DOCKER: ${{ steps.check.outputs.NEED_BUILD_DOCKER }} | |
TAG: ${{ steps.check.outputs.TAG }} | |
VERSION: ${{ steps.check.outputs.VERSION }} | |
steps: | |
- name: check tag version | |
id: check | |
run: | | |
REF=${{ github.ref }} | |
if [[ "$REF" =~ refs/tags/v[0-9]+.[0-9]+.[0-9]+.* ]]; then | |
NEED_BUILD_DOCKER=true | |
TAG=${REF:10} | |
VERSION=${REF:11} | |
else | |
echo "Expected refs of the form 'refs/tags/v<major-version>.<minor-version>.<patch-version>' but got '$REF'" | |
NEED_BUILD_DOCKER=false | |
fi | |
echo "NEED_BUILD_DOCKER=$NEED_BUILD_DOCKER, TAG=$TAG, VERSION=$VERSION" | |
echo "NEED_BUILD_DOCKER=$NEED_BUILD_DOCKER" >> "$GITHUB_OUTPUT" | |
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | |
build-and-push-docker: | |
runs-on: ubuntu-latest | |
needs: prebuild | |
if: needs.prebuild.outputs.NEED_BUILD_DOCKER | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn clean package -DskipTests | |
- name: Post build package | |
run: | | |
rm -rf output | |
mkdir output | |
cp build/build-bifromq-starters/target/bifromq-* output | |
cp Dockerfile output | |
- name: Upload build package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: prerelease-${{ needs.prebuild.outputs.VERSION }} | |
path: output | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: bifromq/bifromq | |
tags: | | |
type=raw,value=latest | |
- uses: docker/login-action@v3 | |
with: | |
username: ${{secrets.DOCKER_USERNAME}} | |
password: ${{secrets.DOCKER_PASSWORD}} | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v5 | |
with: | |
context: output | |
push: true | |
# Path to the Dockerfile | |
file: Dockerfile | |
# List of target platforms for build | |
platforms: linux/amd64,linux/arm64 | |
# List of tags s | |
tags: ${{ steps.meta.outputs.tags }} |