Update to rust 1.70 (#8) #23
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
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: [main, staging, trying] | |
tags: | |
- "v*.*.*" | |
name: Build Cross Images | |
env: | |
CARGO_NET_RETRY: 3 | |
CARGO_HTTP_CHECK_REVOKE: false | |
CROSS_REPO_REF: b7f7ace6681511de8df3bfbfd05652e369588875 | |
RUST_VERSION: 1.67.0 | |
ANDROID_NDK: r13b | |
ANDROID_SDK: 21 | |
ANDROID_VERSION: 5.0.0_r1 | |
# Default from upstream | |
# ANDROID_NDK: r25b | |
# ANDROID_SDK: 28 | |
# ANDROID_VERSION: 9.0.0_r1 | |
jobs: | |
generate-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.generate-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/checkout@v4 | |
with: | |
repository: cross-rs/cross | |
ref: ${{ env.CROSS_REPO_REF }} | |
path: cross | |
- uses: ./.github/actions/setup-rust | |
- name: Generate matrix | |
id: generate-matrix | |
run: cargo xtask ci-job target-matrix --weekly | |
working-directory: cross | |
env: | |
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
COMMIT_AUTHOR: ${{ github.event.head_commit.author.username }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TARGETS: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android | |
build: | |
name: target (${{ matrix.pretty }},${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
needs: [generate-matrix] | |
if: needs.generate-matrix.outputs.matrix != '{}' && needs.generate-matrix.outputs.matrix != '[]' && needs.generate-matrix.outputs.matrix != '' | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
outputs: | |
has-image: ${{ steps.prepare-meta.outputs.has-image }} | |
images: ${{ steps.build-docker-image.outputs.images && fromJSON(steps.build-docker-image.outputs.images) }} | |
coverage-artifact: ${{ steps.cov.outputs.artifact-name }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/checkout@v4 | |
with: | |
repository: cross-rs/cross | |
ref: ${{ env.CROSS_REPO_REF }} | |
path: cross | |
- name: git patch (cross) | |
run: git apply ../patches/cross.patch | |
working-directory: ./cross | |
- name: Configure Android/NDK/SDK | |
working-directory: ./cross | |
run: | | |
grep 'ARG ANDROID_' ./docker/Dockerfile.* | |
grep 'libunwind.a' ./docker/android-system.sh || true | |
- uses: ./.github/actions/setup-rust | |
- name: Set up Docker Buildx | |
if: runner.os == 'Linux' | |
uses: docker/setup-buildx-action@v3 | |
- name: Build xtask | |
run: cargo build -p xtask | |
working-directory: cross | |
- name: Prepare Meta | |
id: prepare-meta | |
timeout-minutes: 60 | |
run: cargo xtask ci-job prepare-meta "${TARGET}${SUB:+.$SUB}" | |
working-directory: cross | |
env: | |
TARGET: ${{ matrix.target }} | |
SUB: ${{ matrix.sub }} | |
shell: bash | |
- name: Docker Meta | |
if: steps.prepare-meta.outputs.has-image | |
id: docker-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
name=ghcr.io/${{ github.repository_owner }}/cross/${{ matrix.target }}:main:main | |
labels: | | |
${{ fromJSON(steps.prepare-meta.outputs.labels) }} | |
- name: Build Docker image | |
id: build-docker-image | |
if: steps.prepare-meta.outputs.has-image | |
timeout-minutes: 120 | |
run: > | |
cargo xtask build-docker-image -v "${TARGET}${SUB:+.$SUB}" | |
--tag "${DOCKER_METADATA_OUTPUT_VERSION}" | |
--build-arg "ANDROID_NDK=${{ env.ANDROID_NDK }}" | |
--build-arg "ANDROID_SDK=${{ env.ANDROID_SDK }}" | |
--build-arg "ANDROID_VERSION=${{ env.ANDROID_VERSION }}" | |
working-directory: cross | |
env: | |
TARGET: ${{ matrix.target }} | |
SUB: ${{ matrix.sub }} | |
LABELS: ${{ steps.docker-meta.outputs.labels }} | |
LATEST: ${{ needs.check.outputs.is-latest || 'false' }} | |
shell: bash | |
- name: Set Docker image for test | |
if: steps.prepare-meta.outputs.has-image | |
run: | | |
TARGET_VAR="cross_target_${TARGET//-/_}_image" | |
echo "${TARGET_VAR^^}=${IMAGE}" | tee -a "${GITHUB_ENV}" | |
working-directory: cross | |
env: | |
TARGET: ${{ matrix.target }} | |
IMAGE: ${{ steps.build-docker-image.outputs.image }} | |
shell: bash | |
- name: Test Image | |
continue-on-error: true | |
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'default' | |
run: ./ci/test.sh | |
working-directory: cross | |
env: | |
TARGET: ${{ matrix.target }} | |
CPP: ${{ matrix.cpp }} | |
DYLIB: ${{ matrix.dylib }} | |
STD: ${{ matrix.std }} | |
BUILD_STD: ${{ matrix.build-std }} | |
RUN: ${{ matrix.run }} | |
RUNNERS: ${{ matrix.runners }} | |
shell: bash | |
- name: Test Zig Image | |
continue-on-error: true | |
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'zig' | |
run: ./ci/test-zig-image.sh | |
working-directory: cross | |
shell: bash | |
- name: Test Cross Image | |
continue-on-error: true | |
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'cross' | |
run: ./ci/test-cross-image.sh | |
working-directory: cross | |
env: | |
TARGET: 'aarch64-unknown-linux-gnu' | |
IMAGE: 'ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main' | |
shell: bash | |
- name: Login to GitHub Container Registry | |
if: github.event_name == 'push' && steps.prepare-meta.outputs.has-image | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push image to GitHub Container Registry | |
if: > | |
steps.prepare-meta.outputs.has-image && ( | |
github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || | |
startsWith(github.ref, 'refs/tags/v') | |
) | |
run: > | |
cargo xtask build-docker-image -v --repository ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/cross --push "${TARGET}${SUB:+.$SUB}" | |
--tag "${DOCKER_METADATA_OUTPUT_VERSION}" | |
--build-arg "ANDROID_NDK=${{ env.ANDROID_NDK }}" | |
--build-arg "ANDROID_SDK=${{ env.ANDROID_SDK }}" | |
--build-arg "ANDROID_VERSION=${{ env.ANDROID_VERSION }}" | |
working-directory: cross | |
env: | |
TARGET: ${{ matrix.target }} | |
SUB: ${{ matrix.sub }} | |
LABELS: ${{ steps.docker-meta.outputs.labels }} | |
LATEST: ${{ needs.check.outputs.is-latest || 'false' }} | |
shell: bash |