Publish Dev Docker Image #14
This file contains hidden or 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: Publish Dev Docker Image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| publish: | |
| description: 'Publish the image to Docker Hub' | |
| required: true | |
| default: true | |
| type: boolean | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - '.devcontainer/Dockerfile' | |
| - '.github/workflows/publish_dev_docker.yaml' | |
| env: | |
| IMAGE_NAME: fzyzcjy/flutter_rust_bridge_dev | |
| jobs: | |
| publish: | |
| name: Build, Test and Publish Dev Image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| if: github.event_name == 'push' || inputs.publish | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: docker.io | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Compute tags from Dockerfile | |
| id: metadata | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| flutter_version="$(awk -F= '/^ARG FLUTTER_VERSION=/{print $2; exit}' .devcontainer/Dockerfile)" | |
| rust_version="$(awk -F= '/^ARG RUST_VERSION=/{print $2; exit}' .devcontainer/Dockerfile)" | |
| rust_nightly_version="$(awk -F= '/^ARG RUST_NIGHTLY_VERSION=/{print $2; exit}' .devcontainer/Dockerfile)" | |
| short_sha="${GITHUB_SHA::7}" | |
| version_tag="flutter-${flutter_version}-rust-${rust_version}-nightly-${rust_nightly_version}" | |
| sha_tag="sha-${short_sha}" | |
| local_tag_amd64="frb-dev-image-smoke:${short_sha}-amd64" | |
| local_tag_arm64="frb-dev-image-smoke:${short_sha}-arm64" | |
| { | |
| echo "flutter_version=${flutter_version}" | |
| echo "rust_version=${rust_version}" | |
| echo "rust_nightly_version=${rust_nightly_version}" | |
| echo "version_tag=${version_tag}" | |
| echo "sha_tag=${sha_tag}" | |
| echo "local_tag_amd64=${local_tag_amd64}" | |
| echo "local_tag_arm64=${local_tag_arm64}" | |
| echo "tags<<EOF" | |
| echo "${IMAGE_NAME}:latest" | |
| echo "${IMAGE_NAME}:${version_tag}" | |
| echo "${IMAGE_NAME}:${sha_tag}" | |
| echo "EOF" | |
| } >> "${GITHUB_OUTPUT}" | |
| - name: Build local amd64 image for smoke test | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: .devcontainer | |
| file: .devcontainer/Dockerfile | |
| platforms: linux/amd64 | |
| load: true | |
| push: false | |
| tags: ${{ steps.metadata.outputs.local_tag_amd64 }} | |
| - name: Smoke test local amd64 image | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| docker run --rm --platform linux/amd64 "${{ steps.metadata.outputs.local_tag_amd64 }}" bash -lc ' | |
| set -euo pipefail | |
| flutter --version | |
| dart --version | |
| cargo --version | |
| rustup show | |
| rustup target list --toolchain nightly-${{ steps.metadata.outputs.rust_nightly_version }} --installed | |
| wasm-pack --version | |
| "${CHROME_BIN}" --version | |
| rustup target list --toolchain nightly-${{ steps.metadata.outputs.rust_nightly_version }} --installed | grep wasm32-unknown-unknown | |
| rustup show | grep "nightly-${{ steps.metadata.outputs.rust_nightly_version }}" | |
| ' | |
| - name: Build local arm64 image for smoke test | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: .devcontainer | |
| file: .devcontainer/Dockerfile | |
| platforms: linux/arm64 | |
| load: true | |
| push: false | |
| tags: ${{ steps.metadata.outputs.local_tag_arm64 }} | |
| - name: Smoke test local arm64 image | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| docker run --rm --platform linux/arm64 "${{ steps.metadata.outputs.local_tag_arm64 }}" bash -lc ' | |
| set -euo pipefail | |
| flutter --version | |
| dart --version | |
| cargo --version | |
| rustup show | |
| rustup target list --toolchain nightly-${{ steps.metadata.outputs.rust_nightly_version }} --installed | |
| wasm-pack --version | |
| "${CHROME_BIN}" --version | |
| rustup target list --toolchain nightly-${{ steps.metadata.outputs.rust_nightly_version }} --installed | grep wasm32-unknown-unknown | |
| rustup show | grep "nightly-${{ steps.metadata.outputs.rust_nightly_version }}" | |
| ' | |
| - name: Push image to Docker Hub | |
| if: github.event_name == 'push' || inputs.publish | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: .devcontainer | |
| file: .devcontainer/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.metadata.outputs.tags }} | |
| - name: Publish workflow summary | |
| shell: bash | |
| run: | | |
| { | |
| if [[ "${{ github.event_name }}" == "push" || "${{ inputs.publish }}" == "true" ]]; then | |
| echo "## Dev Docker Image Published" | |
| else | |
| echo "## Dev Docker Image Verified" | |
| fi | |
| echo | |
| echo "- Repository: \`${IMAGE_NAME}\`" | |
| echo "- Published: \`${{ github.event_name == 'push' || inputs.publish }}\`" | |
| echo "- Flutter: \`${{ steps.metadata.outputs.flutter_version }}\`" | |
| echo "- Rust: \`${{ steps.metadata.outputs.rust_version }}\`" | |
| echo "- Rust nightly: \`${{ steps.metadata.outputs.rust_nightly_version }}\`" | |
| echo "- Platforms: \`linux/amd64\`, \`linux/arm64\`" | |
| echo "- Tags:" | |
| echo " - \`latest\`" | |
| echo " - \`${{ steps.metadata.outputs.version_tag }}\`" | |
| echo " - \`${{ steps.metadata.outputs.sha_tag }}\`" | |
| } >> "${GITHUB_STEP_SUMMARY}" |