Prepare for release v2.1.3 (#78) #23
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 docker image | |
on: | |
push: | |
tags: | |
- v[0-9].[0-9].[0-9]** | |
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 }} | |
MARK_LATEST: ${{ steps.check.outputs.MARK_LATEST }} | |
steps: | |
- name: check tag version | |
id: check | |
run: | | |
REF=${{ github.ref }} | |
if [[ "${{github.event.created}}" == "false" ]]; then | |
NEED_BUILD_DOCKER=false | |
else | |
if [[ "$REF" =~ refs/tags/v[0-9]+.[0-9]+.[0-9]+ ]]; then | |
NEED_BUILD_DOCKER=true | |
MARK_LATEST=false | |
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 | |
fi | |
echo "MARK_LATEST=$MARK_LATEST, NEED_BUILD_DOCKER=$NEED_BUILD_DOCKER, TAG=$TAG, VERSION=$VERSION" | |
echo "NEED_BUILD_DOCKER=$NEED_BUILD_DOCKER" >> "$GITHUB_OUTPUT" | |
echo "TAG=$TAG" >> "$GITHUB_OUTPUT" | |
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | |
echo "MARK_LATEST=$MARK_LATEST" >> "$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@v3 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
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@v3 | |
with: | |
name: prerelease-${{ needs.prebuild.outputs.VERSION }} | |
path: output | |
- uses: docker/setup-qemu-action@v2 | |
- uses: docker/[email protected] | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: bifromq/bifromq | |
tags: | | |
type=raw,value=${{ needs.prebuild.outputs.VERSION }} | |
type=raw,value=latest,enable=${{ needs.prebuild.outputs.MARK_LATEST }} | |
- uses: docker/[email protected] | |
with: | |
username: ${{secrets.DOCKER_USERNAME}} | |
password: ${{secrets.DOCKER_PASSWORD}} | |
- name: Build and push Docker images | |
uses: docker/[email protected] | |
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 }} |