Skip to content

macOS

macOS #359

# This is ci/actions-templates/macos-builds-template.yaml
# Do not edit this file in .github/workflows
name: macOS
on:
pull_request:
branches:
- "*"
push:
branches:
- master
- stable
schedule:
- cron: "30 0 * * 1" # Every Monday at half past midnight UTC
jobs:
build:
name: Build
runs-on: macos-latest
strategy:
matrix:
target:
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
with:
# v2 defaults to a shallow checkout, but we need at least to the previous tag
fetch-depth: 0
- name: Acquire tags for the repo
run: |
git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/*
- name: Display the current git status
run: |
git status
git describe --tags
- name: Prep cargo dirs
run: |
mkdir -p ~/.cargo/{registry,git}
- name: Set environment variables appropriately for the build
run: |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV
echo "SKIP_TESTS=" >> $GITHUB_ENV
echo "LZMA_API_STATIC=1" >> $GITHUB_ENV
- name: Cache cargo registry and git trees
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Get rustc commit hash
id: cargo-target-cache
run: |
echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')"
shell: bash
- name: Cache cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}-3
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}-3
- name: Install Rustup
run: |
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=none --profile=minimal -y
- name: Ensure Stable is up to date
run: |
if rustc +stable -vV >/dev/null 2>/dev/null; then
rustup toolchain uninstall stable
fi
rustup toolchain install --profile=minimal stable
- name: aarch64-specific items
run: |
# Use nightly for now
rustup toolchain install --profile=minimal nightly
rustup default nightly
# Can't run tests: cross-compiling
echo "SKIP_TESTS=yes" >> $GITHUB_ENV
if: matrix.target == 'aarch64-apple-darwin'
- name: Ensure we have our goal target installed
run: |
rustup target install "$TARGET"
- name: Run a full build and test
run: bash ci/run.bash
- name: Dump dynamic link targets
if: false
run: |
otool -L target/${TARGET}/release/rustup-init
if otool -L target/${TARGET}/release/rustup-init | grep -q -F /usr/local/; then
echo >&2 "Unfortunately there are /usr/local things in the link. Fail."
exit 1
fi
- name: Upload the built artifact
if: false
uses: actions/upload-artifact@v3
with:
name: rustup-init-${{ matrix.target }}
path: |
target/${{ matrix.target }}/release/rustup-init
retention-days: 7
- name: Acquire the AWS tooling
run: |
pip3 install awscli
if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable'
- name: Prepare the dist
run: |
bash ci/prepare-deploy.bash
if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable'
- name: Deploy build to dev-static dist tree for release team
run: |
aws s3 cp --recursive deploy/ s3://dev-static-rust-lang-org/rustup/
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-1
if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable'
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache