Skip to content

Commit

Permalink
feat: add aarch64-apple-darwin build (#77)
Browse files Browse the repository at this point in the history
Co-authored-by: Utkarsh Gupta <[email protected]>
  • Loading branch information
dsherret and utkarshgupta137 authored Feb 17, 2024
1 parent 3176e7f commit de9b828
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
35 changes: 23 additions & 12 deletions .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
import * as yaml from "https://deno.land/[email protected]/encoding/yaml.ts";
import $ from "https://deno.land/x/[email protected]/mod.ts";

enum OperatingSystem {
Mac = "macOS-latest",
enum Runner {
MacLatest = "macOS-latest",
Mac14 = "macos-14",
Windows = "windows-latest",
// uses an older version of ubuntu because of issue dprint/#483
Linux = "ubuntu-20.04",
}

interface ProfileData {
os: OperatingSystem;
runner: Runner;
target: string;
runTests?: boolean;
cross?: boolean;
}

const profileDataItems: ProfileData[] = [{
os: OperatingSystem.Mac,
runner: Runner.MacLatest,
target: "x86_64-apple-darwin",
runTests: true,
}, {
os: OperatingSystem.Windows,
runner: Runner.Mac14,
target: "aarch64-apple-darwin",
runTests: true,
}, {
runner: Runner.Windows,
target: "x86_64-pc-windows-msvc",
runTests: true,
}, {
os: OperatingSystem.Linux,
runner: Runner.Linux,
target: "x86_64-unknown-linux-gnu",
runTests: true,
}, {
os: OperatingSystem.Linux,
runner: Runner.Linux,
target: "aarch64-unknown-linux-gnu",
runTests: false,
cross: true,
Expand Down Expand Up @@ -60,7 +65,7 @@ const ci = {
strategy: {
matrix: {
config: profiles.map((profile) => ({
os: profile.os,
os: profile.runner,
run_tests: (profile.runTests ?? false).toString(),
cross: (profile.cross ?? false).toString(),
target: profile.target,
Expand Down Expand Up @@ -90,6 +95,11 @@ const ci = {
"save-if": "${{ github.ref == 'refs/heads/main' }}",
},
},
{
name: "Setup Rust (aarch64-apple-darwin)",
if: `matrix.config.target == 'aarch64-apple-darwin'`,
run: "rustup target add aarch64-apple-darwin",
},
{ uses: "denoland/setup-deno@v1" },
{
uses: "actions/setup-node@v3",
Expand Down Expand Up @@ -151,20 +161,21 @@ const ci = {
// zip files
...profiles.map((profile) => {
function getRunSteps() {
switch (profile.os) {
case OperatingSystem.Mac:
switch (profile.runner) {
case Runner.MacLatest:
case Runner.Mac14:
return [
`cd target/${profile.target}/release`,
`zip -r ${profile.zipFileName} dprint-plugin-prettier`,
`echo \"::set-output name=ZIP_CHECKSUM::$(shasum -a 256 ${profile.zipFileName} | awk '{print $1}')\"`,
];
case OperatingSystem.Linux:
case Runner.Linux:
return [
`cd target/${profile.target}/release`,
`zip -r ${profile.zipFileName} dprint-plugin-prettier`,
`echo \"::set-output name=ZIP_CHECKSUM::$(shasum -a 256 ${profile.zipFileName} | awk '{print $1}')\"`,
];
case OperatingSystem.Windows:
case Runner.Windows:
return [
`Compress-Archive -CompressionLevel Optimal -Force -Path target/${profile.target}/release/dprint-plugin-prettier.exe -DestinationPath target/${profile.target}/release/${profile.zipFileName}`,
`echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 target/${profile.target}/release/${profile.zipFileName} | awk '{print $1}')"`,
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
run_tests: "true"
cross: "false"
target: x86_64-apple-darwin
- os: macos-14
run_tests: "true"
cross: "false"
target: aarch64-apple-darwin
- os: windows-latest
run_tests: "true"
cross: "false"
Expand All @@ -38,6 +42,7 @@ jobs:
target: aarch64-unknown-linux-gnu
outputs:
ZIP_CHECKSUM_X86_64_APPLE_DARWIN: "${{steps.pre_release_x86_64_apple_darwin.outputs.ZIP_CHECKSUM}}"
ZIP_CHECKSUM_AARCH64_APPLE_DARWIN: "${{steps.pre_release_aarch64_apple_darwin.outputs.ZIP_CHECKSUM}}"
ZIP_CHECKSUM_X86_64_PC_WINDOWS_MSVC: "${{steps.pre_release_x86_64_pc_windows_msvc.outputs.ZIP_CHECKSUM}}"
ZIP_CHECKSUM_X86_64_UNKNOWN_LINUX_GNU: "${{steps.pre_release_x86_64_unknown_linux_gnu.outputs.ZIP_CHECKSUM}}"
ZIP_CHECKSUM_AARCH64_UNKNOWN_LINUX_GNU: "${{steps.pre_release_aarch64_unknown_linux_gnu.outputs.ZIP_CHECKSUM}}"
Expand All @@ -52,6 +57,9 @@ jobs:
with:
prefix-key: "v3-${{matrix.config.target}}"
save-if: "${{ github.ref == 'refs/heads/main' }}"
- name: Setup Rust (aarch64-apple-darwin)
if: matrix.config.target == 'aarch64-apple-darwin'
run: rustup target add aarch64-apple-darwin
- uses: denoland/setup-deno@v1
- uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -91,6 +99,13 @@ jobs:
cd target/x86_64-apple-darwin/release
zip -r dprint-plugin-prettier-x86_64-apple-darwin.zip dprint-plugin-prettier
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-prettier-x86_64-apple-darwin.zip | awk '{print $1}')"
- name: Pre-release (aarch64-apple-darwin)
id: pre_release_aarch64_apple_darwin
if: "matrix.config.target == 'aarch64-apple-darwin' && startsWith(github.ref, 'refs/tags/')"
run: |-
cd target/aarch64-apple-darwin/release
zip -r dprint-plugin-prettier-aarch64-apple-darwin.zip dprint-plugin-prettier
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-prettier-aarch64-apple-darwin.zip | awk '{print $1}')"
- name: Pre-release (x86_64-pc-windows-msvc)
id: pre_release_x86_64_pc_windows_msvc
if: "matrix.config.target == 'x86_64-pc-windows-msvc' && startsWith(github.ref, 'refs/tags/')"
Expand All @@ -117,6 +132,12 @@ jobs:
with:
name: x86_64-apple-darwin-artifacts
path: target/x86_64-apple-darwin/release/dprint-plugin-prettier-x86_64-apple-darwin.zip
- name: Upload artifacts (aarch64-apple-darwin)
if: "matrix.config.target == 'aarch64-apple-darwin' && startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v2
with:
name: aarch64-apple-darwin-artifacts
path: target/aarch64-apple-darwin/release/dprint-plugin-prettier-aarch64-apple-darwin.zip
- name: Upload artifacts (x86_64-pc-windows-msvc)
if: "matrix.config.target == 'x86_64-pc-windows-msvc' && startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -149,12 +170,14 @@ jobs:
- name: Move downloaded artifacts to root directory
run: |-
mv x86_64-apple-darwin-artifacts/dprint-plugin-prettier-x86_64-apple-darwin.zip .
mv aarch64-apple-darwin-artifacts/dprint-plugin-prettier-aarch64-apple-darwin.zip .
mv x86_64-pc-windows-msvc-artifacts/dprint-plugin-prettier-x86_64-pc-windows-msvc.zip .
mv x86_64-unknown-linux-gnu-artifacts/dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip .
mv aarch64-unknown-linux-gnu-artifacts/dprint-plugin-prettier-aarch64-unknown-linux-gnu.zip .
- name: Output checksums
run: |-
echo "dprint-plugin-prettier-x86_64-apple-darwin.zip: ${{needs.build.outputs.ZIP_CHECKSUM_X86_64_APPLE_DARWIN}}"
echo "dprint-plugin-prettier-aarch64-apple-darwin.zip: ${{needs.build.outputs.ZIP_CHECKSUM_AARCH64_APPLE_DARWIN}}"
echo "dprint-plugin-prettier-x86_64-pc-windows-msvc.zip: ${{needs.build.outputs.ZIP_CHECKSUM_X86_64_PC_WINDOWS_MSVC}}"
echo "dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip: ${{needs.build.outputs.ZIP_CHECKSUM_X86_64_UNKNOWN_LINUX_GNU}}"
echo "dprint-plugin-prettier-aarch64-unknown-linux-gnu.zip: ${{needs.build.outputs.ZIP_CHECKSUM_AARCH64_UNKNOWN_LINUX_GNU}}"
Expand All @@ -173,6 +196,7 @@ jobs:
with:
files: |-
dprint-plugin-prettier-x86_64-apple-darwin.zip
dprint-plugin-prettier-aarch64-apple-darwin.zip
dprint-plugin-prettier-x86_64-pc-windows-msvc.zip
dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip
dprint-plugin-prettier-aarch64-unknown-linux-gnu.zip
Expand Down
1 change: 1 addition & 0 deletions scripts/create_plugin_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ await processPlugin.createDprintOrgProcessPlugin({
version: new CargoToml(cargoFilePath).version(),
platforms: [
"darwin-x86_64",
"darwin-aarch64",
"linux-x86_64",
"linux-aarch64",
"windows-x86_64",
Expand Down

0 comments on commit de9b828

Please sign in to comment.