Build and Publish SimpleX Docker Image #4
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 and Publish SimpleX Docker Image | |
on: | |
workflow_dispatch: | |
inputs: | |
simplex_version: | |
description: 'SimpleX Server version to build (e.g. v6.0.4 or v6.1.0-beta.1). Use "latest" to build the most recent version' | |
required: true | |
default: 'latest' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
env: | |
REPO_URL: https://github.com/simplex-chat/simplex-chat.git | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Fetch latest tags from SimpleX repository | |
run: | | |
git clone --depth=1 --tags $REPO_URL | |
cd simplex-chat | |
# Find the latest tag, filtering out any non-version tags like 'v*' | |
LATEST_TAG=$(git tag -l --sort=-v:refname 'v*' | head -n 1) | |
echo "Latest tag found: $LATEST_TAG" | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | |
- name: Determine version to build | |
run: | | |
if [ "${{ github.event.inputs.simplex_version }}" == "latest" ]; then | |
echo "Using latest tag: $LATEST_TAG" | |
echo "SIMPLEX_VERSION=$LATEST_TAG" >> $GITHUB_ENV | |
else | |
echo "Using specified version: ${{ github.event.inputs.simplex_version }}" | |
echo "SIMPLEX_VERSION=${{ github.event.inputs.simplex_version }}" >> $GITHUB_ENV | |
fi | |
- name: Build and push Docker image for x86 and arm | |
run: | | |
echo "Building SimpleX version: $SIMPLEX_VERSION" | |
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
docker buildx build \ | |
--platform linux/amd64,linux/arm64 \ | |
--file .github/Dockerfile.simplex \ | |
--tag ghcr.io/${REPO_NAME}:$SIMPLEX_VERSION \ | |
--build-arg SIMPLEX_VERSION=$SIMPLEX_VERSION \ | |
--push \ | |
. | |
- name: Image build complete | |
run: echo "Docker image has been built and published." |