Skip to content
This repository was archived by the owner on Sep 17, 2023. It is now read-only.

Commit 6cbdfb9

Browse files
committed
feat: add support for M1 macOS
This commit - compiles build artifacts with musl instead of glibc for greater compatibility - adds support for the following target triples - i686-unknown-linux-musl - aarch64-unknown-linux-musl - aarch64-apple-darwin
1 parent 7a635c1 commit 6cbdfb9

File tree

11 files changed

+1575
-277
lines changed

11 files changed

+1575
-277
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
---
2+
23
name: CI
34

45
on: [ pull_request ]
56

7+
# This pipeline validates proposed changes.
8+
#
9+
# CI pipeline based on:
10+
# - https://github.com/heim-rs/heim/blob/master/.github/workflows/ci.yml
11+
# - https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml
12+
# - https://github.com/ClementTsang/bottom/blob/master/.github/workflows/ci.yml
13+
614
env:
715
BINARY_NAME: monorepo
816
CARGO_TERM_COLOR: always
@@ -36,88 +44,55 @@ jobs:
3644
- name: Build docker image
3745
run: docker build -f Dockerfile .
3846

47+
# Room for improvement regarding caching/work-skipping. One example here
48+
# https://github.com/ClementTsang/bottom/blob/92ec3599363c710815c286e975bbb6cc748708dd/.github/workflows/ci.yml#L195
3949
cargo-check:
4050
runs-on: ${{ matrix.triple.os }}
4151
strategy:
4252
matrix:
4353
triple:
44-
- {
45-
os: "ubuntu-latest",
46-
target: "x86_64-unknown-linux-gnu",
47-
cross: false,
48-
rust: stable,
49-
}
50-
- {
51-
os: "ubuntu-latest",
52-
target: "i686-unknown-linux-gnu",
53-
cross: true,
54-
rust: stable,
55-
}
5654
- {
5755
os: "ubuntu-latest",
5856
target: "x86_64-unknown-linux-musl",
5957
cross: false,
60-
rust: stable,
6158
}
6259
- {
6360
os: "ubuntu-latest",
6461
target: "i686-unknown-linux-musl",
6562
cross: true,
66-
rust: stable,
67-
}
68-
- {
69-
os: "windows-2019",
70-
target: "x86_64-pc-windows-msvc",
71-
cross: false,
72-
rust: stable,
73-
}
74-
- {
75-
os: "windows-2019",
76-
target: "i686-pc-windows-msvc",
77-
cross: false,
78-
rust: stable,
79-
}
80-
- {
81-
os: "windows-2019",
82-
target: "x86_64-pc-windows-gnu",
83-
cross: false,
84-
rust: stable,
8563
}
8664
- {
8765
os: "macOS-latest",
8866
target: "x86_64-apple-darwin",
8967
cross: false,
90-
rust: stable,
9168
}
9269
# aarch64
9370
- {
9471
os: "ubuntu-latest",
95-
target: "aarch64-unknown-linux-gnu",
72+
target: "aarch64-unknown-linux-musl",
9673
cross: true,
97-
rust: stable,
9874
}
9975
# macOS ARM
10076
- {
10177
os: "macOS-latest",
10278
target: "aarch64-apple-darwin",
10379
cross: true,
104-
rust: stable,
10580
}
10681
steps:
107-
- name: Checkout
108-
uses: actions/checkout@v3
82+
- name: Checkout
83+
uses: actions/checkout@v3
10984

110-
- name: Install toolchain
111-
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
112-
uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746
113-
with:
114-
profile: minimal
115-
toolchain: ${{ matrix.triple.rust }}
116-
override: true
117-
target: ${{ matrix.triple.target }}
118-
- name: Cargo check
119-
uses: actions-rs/cargo@v1
120-
with:
121-
command: check
122-
args: --all-targets --verbose --target=${{ matrix.triple.target }}
123-
use-cross: ${{ matrix.triple.cross }}
85+
- name: Install toolchain
86+
uses: actions-rs/toolchain@v1
87+
with:
88+
profile: minimal
89+
toolchain: stable
90+
override: true
91+
target: ${{ matrix.triple.target }}
92+
93+
- name: Cargo check
94+
uses: actions-rs/cargo@v1
95+
with:
96+
command: check
97+
args: --all-targets --verbose --target=${{ matrix.triple.target }}
98+
use-cross: ${{ matrix.triple.cross }}

.github/workflows/release.yml

Lines changed: 119 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
23
name: Release
34

45
on:
@@ -18,70 +19,90 @@ on:
1819
# - npm publish
1920
# - create GitHub release
2021

22+
env:
23+
BINARY_NAME: monorepo
24+
CARGO_TERM_COLOR: always
25+
RUST_BACKTRACE: 1
26+
2127
jobs:
22-
release:
28+
29+
semantic-version:
2330
runs-on: ubuntu-latest
24-
env:
25-
BINARY_NAME: monorepo
26-
CARGO_TERM_COLOR: always
27-
RUST_BACKTRACE: 1
28-
steps:
29-
- name: Login to DockerHub
30-
uses: docker/login-action@v1
31-
with:
32-
username: ${{ secrets.DOCKER_USERNAME }}
33-
password: ${{ secrets.DOCKER_TOKEN }}
31+
outputs:
32+
next-version: ${{ steps.calculate.outputs.next-version }}
3433

34+
steps:
3535
- name: Checkout
3636
uses: actions/checkout@v3
37-
38-
- name: Install macOS cross-compilation dependencies
39-
run: |
40-
sudo apt update
41-
sudo apt install --yes \
42-
g++ \
43-
gcc \
44-
libgmp-dev \
45-
libmpc-dev \
46-
libmpfr-dev \
47-
libssl-dev \
48-
libxml2-dev \
49-
zlib1g-dev
50-
51-
- name: Cache osxcross
52-
uses: actions/cache@v3
53-
id: cache-osxcross
5437
with:
55-
path: |
56-
~/osxcross
57-
key: ${{ runner.os }}-osxcross-${{ hashFiles('$GITHUB_WORKSPACE/ci/resource-macos-sdk') }}
38+
# Fetch all history and tags for calculating next semantic version
39+
fetch-depth: 0
5840

59-
- name: Install osxcross
60-
if: steps.cache-osxcross.outputs.cache-hit != 'true'
61-
run: |
62-
sdk=$(cat $GITHUB_WORKSPACE/ci/resource-macos-sdk)
63-
git clone https://github.com/tpoechtrager/osxcross ~/osxcross
64-
pushd ~/osxcross
65-
curl -O $sdk
66-
mv $(basename $sdk) tarballs/
67-
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
68-
popd
69-
70-
- name: Add macOS cross-compilation binaries to path
71-
run: echo "$HOME/osxcross/target/bin" >> $GITHUB_PATH
72-
73-
- name: Install GNU/Linux toolchain
74-
uses: actions-rs/toolchain@v1
41+
- name: Configure Node.js
42+
uses: actions/setup-node@v2
7543
with:
76-
profile: minimal
77-
toolchain: stable
78-
target: x86_64-unknown-linux-gnu
44+
node-version: lts/*
45+
cache: npm
46+
47+
- name: Install npm dependencies
48+
run: npm ci --ignore-scripts
49+
50+
- name: Calculate next semantic-release version
51+
id: calculate
52+
run: echo "::set-output name=next-version::$(npx standard-version --dry-run | grep "tagging release" | awk '{ print $NF }')"
53+
54+
# Room for improvement regarding caching/work-skipping. One example here
55+
# https://github.com/ClementTsang/bottom/blob/92ec3599363c710815c286e975bbb6cc748708dd/.github/workflows/ci.yml#L195
56+
57+
### Compile release artifacts
58+
build-release:
59+
runs-on: ${{ matrix.triple.os }}
60+
container: ${{ matrix.triple.container }}
61+
needs:
62+
- semantic-version
63+
64+
strategy:
65+
matrix:
66+
triple:
67+
- {
68+
os: "ubuntu-latest",
69+
target: "x86_64-unknown-linux-musl",
70+
cross: false,
71+
}
72+
- {
73+
os: "ubuntu-latest",
74+
target: "i686-unknown-linux-musl",
75+
cross: true,
76+
}
77+
- {
78+
os: "macOS-latest",
79+
target: "x86_64-apple-darwin",
80+
cross: false,
81+
}
82+
# aarch64
83+
- {
84+
os: "ubuntu-latest",
85+
target: "aarch64-unknown-linux-musl",
86+
cross: true,
87+
}
88+
# macOS ARM
89+
- {
90+
os: "macOS-latest",
91+
target: "aarch64-apple-darwin",
92+
cross: true,
93+
}
94+
95+
steps:
96+
- name: Checkout
97+
uses: actions/checkout@v3
7998

80-
- name: Install macOS toolchain
99+
- name: Install toolchain
81100
uses: actions-rs/toolchain@v1
82101
with:
102+
profile: minimal
83103
toolchain: stable
84-
target: x86_64-apple-darwin
104+
override: true
105+
target: ${{ matrix.triple.target }}
85106

86107
- name: Cache cargo
87108
uses: actions/cache@v3
@@ -102,6 +123,52 @@ jobs:
102123
command: install
103124
args: semantic-release-rust --version 1.0.0-alpha.8
104125

126+
- name: Prepare semantic-release for Rust
127+
run: semantic-release-rust prepare ${{ needs.semantic-version.outputs.next-version }}
128+
129+
- name: Cargo build
130+
uses: actions-rs/cargo@v1
131+
with:
132+
command: build
133+
args: --all-targets --verbose --target=${{ matrix.triple.target }} --release
134+
use-cross: ${{ matrix.triple.cross }}
135+
136+
- name: Create release archive
137+
run: |
138+
mkdir dist
139+
mkdir -p builds/typescript-tools-${{ matrix.triple.target }}
140+
cp target/${{ matrix.triple.target }}/release/monorepo builds/typescript-tools-${{ matrix.triple.target }}/
141+
tar -C builds -czvf dist/typescript-tools-${{ matrix.triple.target }}.tar.gz typescript-tools-${{ matrix.triple.target }}
142+
143+
- name: Upload release artifact
144+
uses: actions/upload-artifact@v3
145+
with:
146+
name: typescript-tools-${{ matrix.triple.target }}.tar.gz
147+
path: dist/typescript-tools-${{ matrix.triple.target }}.tar.gz
148+
if-no-files-found: error
149+
retention-days: 1
150+
151+
### Perform the semantic-release
152+
release:
153+
runs-on: ubuntu-latest
154+
needs:
155+
- build-release
156+
157+
steps:
158+
- name: Login to DockerHub
159+
uses: docker/login-action@v1
160+
with:
161+
username: ${{ secrets.DOCKER_USERNAME }}
162+
password: ${{ secrets.DOCKER_TOKEN }}
163+
164+
- name: Download release artifacts
165+
uses: actions/download-artifact@v3
166+
with:
167+
path: dist
168+
169+
- name: Checkout
170+
uses: actions/checkout@v3
171+
105172
- name: Invoke semantic-release
106173
env:
107174
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.releaserc.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515
}
1616
],
1717
"@semantic-release/release-notes-generator",
18-
[
19-
"@semantic-release/exec",
20-
{
21-
"prepareCmd": "./ci/prepare-cmd ${nextRelease.version}"
22-
}
23-
],
2418
[
2519
"@codedependant/semantic-release-docker",
2620
{
@@ -42,12 +36,24 @@
4236
{
4337
"assets": [
4438
{
45-
"path": "dist/typescript-tools-x86_64-unknown-linux-gnu.tar.gz",
46-
"label": "x86_64-unknown-linux-gnu"
39+
"path": "dist/typescript-tools-x86_64-unknown-linux-musl.tar.gz",
40+
"label": "x86_64-unknown-linux-musl"
41+
},
42+
{
43+
"path": "dist/typescript-tools-i686-unknown-linux-musl.tar.gz",
44+
"label": "i686-unknown-linux-musl"
4745
},
4846
{
4947
"path": "dist/typescript-tools-x86_64-apple-darwin.tar.gz",
5048
"label": "x86_64-apple-darwin"
49+
},
50+
{
51+
"path": "dist/typescript-tools-aarch64-unknown-linux-musl.tar.gz",
52+
"label": "aarch64-unknown-linux-musl"
53+
},
54+
{
55+
"path": "dist/typescript-tools-aarch64-apple-darwin.tar.gz",
56+
"label": "aarch64-apple-darwin"
5157
}
5258
]
5359
}

.versionrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"packageFiles": [],
3+
"bumpFiles": [],
4+
"tagPrefix": ""
5+
}

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ workflow.
3333

3434
## Supported Systems
3535

36-
The following operating systems/architectures are supported
36+
The following target triples are supported:
3737

38-
- [x] GNU/Linux
39-
- [x] x86_64
40-
- [x] Mac OS
41-
- [x] x86_64
42-
- [ ] aarch64
43-
- [ ] Windows
38+
- x86_64-unknown-linux-musl
39+
- i686-unknown-linux-musl
40+
- x86_64-apple-darwin
41+
- aarch64-unknown-linux-musl
42+
- aarch64-apple-darwin
4443

4544
The following package managers are supported
4645

4746
- [x] npm
4847
- [ ] yarn
48+
- [ ] pnpm

0 commit comments

Comments
 (0)