Skip to content

Commit

Permalink
Finally add macOS builds
Browse files Browse the repository at this point in the history
  • Loading branch information
vedantmgoyal9 committed Oct 20, 2024
1 parent a09bcfb commit 45f4146
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 28 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,16 @@ jobs:
lfs: true
persist-credentials: false

- name: Setup Rust and Zig
run: |
rustup target add aarch64-pc-windows-msvc
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
choco install zig
iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content
cargo binstall cargo-zigbuild -y
- name: Build rust-msi
run: |
rustup target add aarch64-pc-windows-msvc
cargo build --release --target x86_64-pc-windows-msvc
cargo build --release --target aarch64-pc-windows-msvc
cargo zigbuild --release --target x86_64-unknown-linux-gnu
cargo zigbuild --release --target aarch64-unknown-linux-gnu
docker run --rm -v ${pwd}:/io -w /io messense/cargo-zigbuild sh -c "
cargo zigbuild --release --target x86_64-unknown-linux-gnu
cargo zigbuild --release --target aarch64-unknown-linux-gnu
cargo zigbuild --release --target aarch64-apple-darwin
"
working-directory: src/WingetCreateCore/Common/Msi/rust-msi

- run: dotnet publish ./WingetCreateCLI.csproj -c Release -r win-x64 --output ./output/win-x64
Expand All @@ -57,12 +52,16 @@ jobs:
- run: dotnet publish ./WingetCreateCLI.csproj -c Release -r linux-arm64 --output ./output/linux-arm64
working-directory: src/WingetCreateCLI

- run: dotnet publish ./WingetCreateCLI.csproj -c Release -r osx-arm64 --output ./output/osx-arm64
working-directory: src/WingetCreateCLI

- name: Rename binaries according to os and arch
run: |
@('win-x64', 'win-arm64', 'linux-x64', 'linux-arm64') | % {
@('win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-arm64') | % {
$wc = get-item -Path .\$_\WingetCreateCLI$(if($_.StartsWith("win")){".exe"})
move-item $wc.fullname ./wingetcreate-$_$(if($_.StartsWith("win")){".exe"})
}
move-item ./wingetcreate-osx-arm64 ./wingetcreate-macos-arm64
working-directory: src/WingetCreateCLI/output

- name: Delete old release 🗑️
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ You can install the prerequisites in one of two ways:
- MSVC - VS2022 C++ ARM64/ARM64EC build tools (Latest) (Individual component)
- Windows 11 SDK (10.0.26100.0) (Individual component)
- Microsoft Visual Studio Installer Projects 2022 (Extension)
- Docker Desktop (only if you want to build for Linux/macOS on Windows)

### Building

Expand Down
28 changes: 16 additions & 12 deletions pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,16 @@ extends:
nugetConfigPath: "NuGet.config"
projects: $(workingDirectory)/**/*.csproj

- displayName: "Setup Rust, Zig"
pwsh: |
rustup target add aarch64-pc-windows-msvc
rustup target add x86_64-unknown-linux-gnu
rustup target add aaarch64-unknown-linux-gnu
choco install zig
iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content
cargo binstall cargo-zigbuild -y
- displayName: Build rust-msi
pwsh: |
rustup target add aarch64-pc-windows-msvc
cargo build --release --target x86_64-pc-windows-msvc
cargo build --release --target aarch64-pc-windows-msvc
cargo zigbuild --release --target x86_64-unknown-linux-gnu
cargo zigbuild --release --target aarch64-unknown-linux-gnu
docker run --rm -v ${pwd}:/io -w /io messense/cargo-zigbuild sh -c "
cargo zigbuild --release --target x86_64-unknown-linux-gnu
cargo zigbuild --release --target aarch64-unknown-linux-gnu
cargo zigbuild --release --target aarch64-apple-darwin
"
workingDirectory: $(workingDirectory)/WingetCreateCore/Common/Msi/rust-msi

- task: MSBuild@1
Expand Down Expand Up @@ -180,17 +175,26 @@ extends:
arguments: "-c Release -r linux-arm64 --output ./output/linux-arm64"
workingDirectory: "$(workingDirectory)/WingetCreateCLI"

- task: DotNetCoreCLI@2
displayName: "Publish (osx-arm64)"
inputs:
command: "publish"
projects: "WingetCreateCLI.csproj"
arguments: "-c Release -r osx-arm64 --output ./output/osx-arm64"
workingDirectory: "$(workingDirectory)/WingetCreateCLI"

- task: 1ES.PublishPipelineArtifact@1
inputs:
targetPath: $(wingetCreatePackageDir)
artifactName: wingetcreate_msixbundle
displayName: Publish WingetCreate msix bundle

- pwsh: |
@('win-x64', 'win-arm64', 'linux-x64', 'linux-arm64') | ForEach-Object {
@('win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-arm64') | ForEach-Object {
$wc = get-item ./$_/WingetCreateCLI$(if($_.StartsWith("win")){".exe"})
move-item $wc.fullname $(portableExecutablesDir)\wingetcreate-$_$(if($_.StartsWith("win")){".exe"})
}
move-item $(portableExecutablesDir)\wingetcreate-osx-arm64 $(portableExecutablesDir)\wingetcreate-macos-arm64
workingDirectory: $(workingDirectory)/WingetCreateCLI/output
- task: 1ES.PublishPipelineArtifact@1
Expand Down
12 changes: 8 additions & 4 deletions src/WingetCreateCore/WingetCreateCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@
<Exec Command="cargo build --release --target aarch64-pc-windows-msvc --manifest-path $(ProjectDir)Common\Msi\rust-msi\Cargo.toml" />
</Target>
<Target Name="CargoBuild_linux_x86_64" Condition="'$(IsLinux)'=='true' And '$(IsX64)'=='true'" BeforeTargets="PreBuild;PreBuildEvent">
<Message Importance="high" Text="Running: cargo zigbuild --release --target x86_64-unknown-linux-gnu --manifest-path $(ProjectDir)Common\Msi\rust-msi\Cargo.toml" />
<Exec Command="cargo zigbuild --release --target x86_64-unknown-linux-gnu --manifest-path $(ProjectDir)Common\Msi\rust-msi\Cargo.toml" />
<Message Importance="high" Text="Running: docker run --rm -it -v $(ProjectDir)Common\Msi\rust-msi:/io -w /io messense/cargo-zigbuild cargo zigbuild -r --target x86_64-unknown-linux-gnu" />
<Exec Command="docker run --rm -it -v $(ProjectDir)Common\Msi\rust-msi:/io -w /io messense/cargo-zigbuild cargo zigbuild -r --target x86_64-unknown-linux-gnu" />
</Target>
<Target Name="CargoBuild_linux_arm64" Condition="'$(IsLinux)'=='true' And '$(IsArm64)'=='true'" BeforeTargets="PreBuild;PreBuildEvent">
<Message Importance="high" Text="Running: cargo zigbuild --release --target aarch64-unknown-linux-gnu --manifest-path $(ProjectDir)Common\Msi\rust-msi\Cargo.toml" />
<Exec Command="cargo zigbuild --release --target aarch64-unknown-linux-gnu --manifest-path $(ProjectDir)Common\Msi\rust-msi\Cargo.toml" />
<Message Importance="high" Text="Running: docker run --rm -it -v $(ProjectDir)Common\Msi\rust-msi:/io -w /io messense/cargo-zigbuild cargo zigbuild -r --target aarch64-unknown-linux-gnu" />
<Exec Command="docker run --rm -it -v $(ProjectDir)Common\Msi\rust-msi:/io -w /io messense/cargo-zigbuild cargo zigbuild -r --target aarch64-unknown-linux-gnu" />
</Target>
<Target Name="CargoBuild_osx_arm64" Condition="'$(IsOSX)'=='true' And '$(IsArm64)'=='true'" BeforeTargets="PreBuild;PreBuildEvent">
<Message Importance="high" Text="Running: docker run --rm -it -v $(ProjectDir)Common\Msi\rust-msi:/io -w /io messense/cargo-zigbuild cargo zigbuild -r --target aarch64-apple-darwin" />
<Exec Command="docker run --rm -it -v $(ProjectDir)Common\Msi\rust-msi:/io -w /io messense/cargo-zigbuild cargo zigbuild -r --target aarch64-apple-darwin" />
</Target>

<ItemGroup>
Expand Down

0 comments on commit 45f4146

Please sign in to comment.