Skip to content

Commit

Permalink
feat: add aarch64_unknown-linux-gnu build (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Dec 30, 2023
1 parent 25ac7ff commit 944c7b0
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 181 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ProfileData {
os: OperatingSystem;
target: string;
runTests?: boolean;
cross?: boolean;
}

const profileDataItems: ProfileData[] = [{
Expand All @@ -26,6 +27,11 @@ const profileDataItems: ProfileData[] = [{
os: OperatingSystem.Linux,
target: "x86_64-unknown-linux-gnu",
runTests: true,
}, {
os: OperatingSystem.Linux,
target: "aarch64-unknown-linux-gnu",
runTests: false,
cross: true,
}];
const profiles = profileDataItems.map((profile) => {
return {
Expand Down Expand Up @@ -56,6 +62,7 @@ const ci = {
config: profiles.map((profile) => ({
os: profile.os,
run_tests: (profile.runTests ?? false).toString(),
cross: (profile.cross ?? false).toString(),
target: profile.target,
})),
},
Expand All @@ -79,7 +86,7 @@ const ci = {
name: "Cache cargo",
uses: "Swatinem/rust-cache@v2",
with: {
"prefix-key": "v3-rust",
"prefix-key": "v3-${{matrix.config.target}}",
"save-if": "${{ github.ref == 'refs/heads/main' }}",
},
},
Expand All @@ -94,16 +101,38 @@ const ci = {
name: "npm install",
run: "cd js/node && npm ci",
},
{
name: "Setup cross",
if: "matrix.config.cross == 'true'",
run: [
"deno task build",
"cargo install cross --git https://github.com/cross-rs/cross --rev 44011c8854cb2eaac83b173cc323220ccdff18ea",
].join("\n"),
},
{
name: "Build (Debug)",
if: "!startsWith(github.ref, 'refs/tags/')",
if: "matrix.config.cross != 'true' && !startsWith(github.ref, 'refs/tags/')",
run: "cargo build --locked --all-targets --target ${{matrix.config.target}}",
},
{
name: "Build release",
if: "startsWith(github.ref, 'refs/tags/')",
if: "matrix.config.cross != 'true' && startsWith(github.ref, 'refs/tags/')",
run: "cargo build --locked --all-targets --target ${{matrix.config.target}} --release",
},
{
name: "Build cross (Debug)",
if: "matrix.config.cross == 'true' && !startsWith(github.ref, 'refs/tags/')",
run: [
"cross build --locked --target ${{matrix.config.target}}",
].join("\n"),
},
{
name: "Build cross (Release)",
if: "matrix.config.cross == 'true' && startsWith(github.ref, 'refs/tags/')",
run: [
"cross build --locked --target ${{matrix.config.target}} --release",
].join("\n"),
},
{
name: "Lint",
if: "!startsWith(github.ref, 'refs/tags/') && matrix.config.target == 'x86_64-unknown-linux-gnu'",
Expand Down
41 changes: 38 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@ jobs:
config:
- os: macOS-latest
run_tests: "true"
cross: "false"
target: x86_64-apple-darwin
- os: windows-latest
run_tests: "true"
cross: "false"
target: x86_64-pc-windows-msvc
- os: ubuntu-20.04
run_tests: "true"
cross: "false"
target: x86_64-unknown-linux-gnu
- os: ubuntu-20.04
run_tests: "false"
cross: "true"
target: aarch64-unknown-linux-gnu
outputs:
ZIP_CHECKSUM_X86_64_APPLE_DARWIN: "${{steps.pre_release_x86_64_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}}"
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: full
Expand All @@ -42,20 +50,31 @@ jobs:
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
prefix-key: v3-rust
prefix-key: "v3-${{matrix.config.target}}"
save-if: "${{ github.ref == 'refs/heads/main' }}"
- uses: denoland/setup-deno@v1
- uses: actions/setup-node@v3
with:
node-version: 18
- name: npm install
run: cd js/node && npm ci
- name: Setup cross
if: matrix.config.cross == 'true'
run: |-
deno task build
cargo install cross --git https://github.com/cross-rs/cross --rev 44011c8854cb2eaac83b173cc323220ccdff18ea
- name: Build (Debug)
if: "!startsWith(github.ref, 'refs/tags/')"
if: "matrix.config.cross != 'true' && !startsWith(github.ref, 'refs/tags/')"
run: "cargo build --locked --all-targets --target ${{matrix.config.target}}"
- name: Build release
if: "startsWith(github.ref, 'refs/tags/')"
if: "matrix.config.cross != 'true' && startsWith(github.ref, 'refs/tags/')"
run: "cargo build --locked --all-targets --target ${{matrix.config.target}} --release"
- name: Build cross (Debug)
if: "matrix.config.cross == 'true' && !startsWith(github.ref, 'refs/tags/')"
run: "cross build --locked --target ${{matrix.config.target}}"
- name: Build cross (Release)
if: "matrix.config.cross == 'true' && startsWith(github.ref, 'refs/tags/')"
run: "cross build --locked --target ${{matrix.config.target}} --release"
- name: Lint
if: "!startsWith(github.ref, 'refs/tags/') && matrix.config.target == 'x86_64-unknown-linux-gnu'"
run: cargo clippy
Expand Down Expand Up @@ -85,6 +104,13 @@ jobs:
cd target/x86_64-unknown-linux-gnu/release
zip -r dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip dprint-plugin-prettier
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip | awk '{print $1}')"
- name: Pre-release (aarch64-unknown-linux-gnu)
id: pre_release_aarch64_unknown_linux_gnu
if: "matrix.config.target == 'aarch64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/')"
run: |-
cd target/aarch64-unknown-linux-gnu/release
zip -r dprint-plugin-prettier-aarch64-unknown-linux-gnu.zip dprint-plugin-prettier
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-prettier-aarch64-unknown-linux-gnu.zip | awk '{print $1}')"
- name: Upload artifacts (x86_64-apple-darwin)
if: "matrix.config.target == 'x86_64-apple-darwin' && startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v2
Expand All @@ -103,6 +129,12 @@ jobs:
with:
name: x86_64-unknown-linux-gnu-artifacts
path: target/x86_64-unknown-linux-gnu/release/dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip
- name: Upload artifacts (aarch64-unknown-linux-gnu)
if: "matrix.config.target == 'aarch64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v2
with:
name: aarch64-unknown-linux-gnu-artifacts
path: target/aarch64-unknown-linux-gnu/release/dprint-plugin-prettier-aarch64-unknown-linux-gnu.zip
draft_release:
name: draft_release
if: "startsWith(github.ref, 'refs/tags/')"
Expand All @@ -119,11 +151,13 @@ jobs:
mv x86_64-apple-darwin-artifacts/dprint-plugin-prettier-x86_64-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-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}}"
- name: Create plugin file
run: deno run -A scripts/create_plugin_file.ts
- name: Get tag version
Expand All @@ -141,6 +175,7 @@ jobs:
dprint-plugin-prettier-x86_64-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
plugin.json
body: |
## Install
Expand Down
Loading

0 comments on commit 944c7b0

Please sign in to comment.