Skip to content

Commit

Permalink
Try build macos arm
Browse files Browse the repository at this point in the history
  • Loading branch information
eikek committed Jul 3, 2024
1 parent aa9b4f0 commit d6ab9eb
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
branches:
- main

concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check:
name: check
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/publish-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: "Publish Test"
on:
pull_request:

concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
publish-mac:
runs-on: macos-latest

strategy:
fail-fast: true
matrix:
build:
- aarch64
- amd64
include:
- build: amd64
target: x86_64-apple-darwin
use-cross: true
features: ""
- build: aarch64
target: aarch64-apple-darwin
use-cross: false
features: ""
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
default: true

- name: Extract crate information
shell: bash
run: |
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)"
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
if [[ $PROJECT_VERSION == *-pre ]]; then
echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV
else
echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV
fi
- name: Add build env parameters
shell: bash
run: |
echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: build
args: ${{ matrix.features }} --release --target=${{ matrix.target }}

- name: Rename binary
run: |
mv target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }} target/release/${{ env.PROJECT_NAME }}_darwin-${{ matrix.build }}-${{ env.VERSION_SUFFIX }}
- name: Publish Release
id: publish
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: ${{ github.ref }} == "refs/heads/main"
files: |
target/release/${{ env.PROJECT_NAME }}_darwin-${{ matrix.build }}-${{ env.VERSION_SUFFIX }}
- name: Publish Pre-Release
id: publish-pre
if: ${{ github.ref }} == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: "ncipollo/release-action@v1"
with:
token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
allowUpdates: true
tag: "nightly"
commit: "main"
name: "renku-cli nightly"
replacesArtifacts: true
artifacts: target/release/${{ env.PROJECT_NAME }}_darwin-${{ matrix.build }}-${{ env.VERSION_SUFFIX }}
56 changes: 41 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
- 'v*'
branches:
- main

concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -143,9 +148,24 @@ jobs:
replacesArtifacts: true
artifacts: ${{ steps.strip.outputs.BIN_PATH }}

build-win:
runs-on: windows-latest
build-mac:
runs-on: macos-latest

strategy:
fail-fast: true
matrix:
build:
- aarch64
- amd64
include:
- build: amd64
target: x86_64-apple-darwin
use-cross: false
features: ""
- build: aarch64
target: aarch64-apple-darwin
use-cross: true
features: ""
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
Expand All @@ -156,6 +176,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: {{ matrix.target }}
override: true
default: true

Expand All @@ -171,15 +192,22 @@ jobs:
echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV
fi
- name: Add build env parameters
shell: bash
run: |
echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.features }} --release

- name: Rename binary
- name: Rename and strip binary
run: |
mv target/release/${{ env.PROJECT_NAME }}.exe target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe
strip target/release/${{ env.PROJECT_NAME }}
mv target/release/${{ env.PROJECT_NAME }} target/release/${{ env.PROJECT_NAME }}_darwin-${{ env.VERSION_SUFFIX }}
- name: Publish Release
id: publish
Expand All @@ -188,8 +216,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: ${{ github.ref }} == "refs/heads/main"
files: |
target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe
target/release/${{ env.PROJECT_NAME }}_darwin-${{ env.VERSION_SUFFIX }}
- name: Publish Pre-Release
id: publish-pre
Expand All @@ -205,10 +234,10 @@ jobs:
commit: "main"
name: "renku-cli nightly"
replacesArtifacts: true
artifacts: target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe
artifacts: target/release/${{ env.PROJECT_NAME }}_darwin-${{ env.VERSION_SUFFIX }}

build-mac:
runs-on: macos-latest
build-win:
runs-on: windows-latest

steps:
- name: Checkout
Expand All @@ -220,7 +249,6 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-apple-darwin
override: true
default: true

Expand All @@ -242,10 +270,9 @@ jobs:
command: build
args: ${{ matrix.features }} --release

- name: Rename and strip binary
- name: Rename binary
run: |
strip target/release/${{ env.PROJECT_NAME }}
mv target/release/${{ env.PROJECT_NAME }} target/release/${{ env.PROJECT_NAME }}_darwin-${{ env.VERSION_SUFFIX }}
mv target/release/${{ env.PROJECT_NAME }}.exe target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe
- name: Publish Release
id: publish
Expand All @@ -254,9 +281,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: ${{ github.ref }} == "refs/heads/main"
files: |
target/release/${{ env.PROJECT_NAME }}_darwin-${{ env.VERSION_SUFFIX }}
target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe
- name: Publish Pre-Release
id: publish-pre
Expand All @@ -272,4 +298,4 @@ jobs:
commit: "main"
name: "renku-cli nightly"
replacesArtifacts: true
artifacts: target/release/${{ env.PROJECT_NAME }}_darwin-${{ env.VERSION_SUFFIX }}
artifacts: target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe

0 comments on commit d6ab9eb

Please sign in to comment.