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

Commit 48ec148

Browse files
authored
Merge pull request #116 from typescript-tools/beta
feat: add support for M1 macOS
2 parents ad21fb2 + 5f36b83 commit 48ec148

File tree

13 files changed

+1637
-255
lines changed

13 files changed

+1637
-255
lines changed

.cargo/config

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
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+
14+
env:
15+
BINARY_NAME: monorepo
16+
CARGO_TERM_COLOR: always
17+
RUST_BACKTRACE: 1
18+
619
jobs:
7-
build:
20+
build-docker-image:
821
runs-on: ubuntu-latest
9-
env:
10-
BINARY_NAME: monorepo
11-
CARGO_TERM_COLOR: always
12-
RUST_BACKTRACE: 1
1322
steps:
1423
- name: Checkout
1524
uses: actions/checkout@v3
@@ -32,10 +41,58 @@ jobs:
3241
target/
3342
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3443

35-
- name: Run cargo check
44+
- name: Build docker image
45+
run: docker build -f Dockerfile .
46+
47+
# Room for improvement regarding caching/work-skipping. One example here
48+
# https://github.com/ClementTsang/bottom/blob/92ec3599363c710815c286e975bbb6cc748708dd/.github/workflows/ci.yml#L195
49+
cargo-check:
50+
runs-on: ${{ matrix.triple.os }}
51+
strategy:
52+
matrix:
53+
triple:
54+
- {
55+
os: "ubuntu-latest",
56+
target: "x86_64-unknown-linux-musl",
57+
cross: false,
58+
}
59+
- {
60+
os: "ubuntu-latest",
61+
target: "i686-unknown-linux-musl",
62+
cross: true,
63+
}
64+
- {
65+
os: "macOS-latest",
66+
target: "x86_64-apple-darwin",
67+
cross: false,
68+
}
69+
# aarch64
70+
- {
71+
os: "ubuntu-latest",
72+
target: "aarch64-unknown-linux-musl",
73+
cross: true,
74+
}
75+
# macOS ARM
76+
- {
77+
os: "macOS-latest",
78+
target: "aarch64-apple-darwin",
79+
cross: true,
80+
}
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@v3
84+
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
3694
uses: actions-rs/cargo@v1
3795
with:
3896
command: check
39-
40-
- name: Build docker image
41-
run: docker build -f Dockerfile .
97+
args: --all-targets --verbose --target=${{ matrix.triple.target }}
98+
use-cross: ${{ matrix.triple.cross }}

.github/workflows/release.yml

Lines changed: 133 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,66 @@ 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: Create checksum
144+
run: shasum --algorithm 256 typescript-tools-${{ matrix.triple.target }}.tar.gz > typescript-tools-${{ matrix.triple.target }}-SHASUMS256.txt
145+
working-directory: ./dist
146+
147+
- name: Upload release artifacts
148+
uses: actions/upload-artifact@v3
149+
with:
150+
name: ${{ matrix.triple.target }}
151+
path: |
152+
dist/typescript-tools-${{ matrix.triple.target }}.tar.gz
153+
dist/typescript-tools-${{ matrix.triple.target }}-SHASUMS256.txt
154+
if-no-files-found: error
155+
retention-days: 1
156+
157+
### Perform the semantic-release
158+
release:
159+
runs-on: ubuntu-latest
160+
needs:
161+
- build-release
162+
163+
steps:
164+
- name: Login to DockerHub
165+
uses: docker/login-action@v1
166+
with:
167+
username: ${{ secrets.DOCKER_USERNAME }}
168+
password: ${{ secrets.DOCKER_TOKEN }}
169+
170+
- name: Checkout
171+
uses: actions/checkout@v3
172+
173+
- name: Download release artifacts
174+
uses: actions/download-artifact@v3
175+
with:
176+
path: dist
177+
178+
- name: Display downloaded release artifacts
179+
run: ls -R
180+
working-directory: dist
181+
182+
- name: Combine checksums
183+
run: cat **/typescript-tools-*-SHASUMS256.txt | tee SHASUMS256.txt
184+
working-directory: dist
185+
105186
- name: Invoke semantic-release
106187
env:
107188
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.releaserc.json

Lines changed: 19 additions & 9 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,28 @@
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/x86_64-unknown-linux-musl/typescript-tools-x86_64-unknown-linux-musl.tar.gz",
40+
"label": "x86_64-unknown-linux-musl"
41+
},
42+
{
43+
"path": "dist/i686-unknown-linux-musl/typescript-tools-i686-unknown-linux-musl.tar.gz",
44+
"label": "i686-unknown-linux-musl"
4745
},
4846
{
49-
"path": "dist/typescript-tools-x86_64-apple-darwin.tar.gz",
47+
"path": "dist/x86_64-apple-darwin/typescript-tools-x86_64-apple-darwin.tar.gz",
5048
"label": "x86_64-apple-darwin"
49+
},
50+
{
51+
"path": "dist/aarch64-unknown-linux-musl/typescript-tools-aarch64-unknown-linux-musl.tar.gz",
52+
"label": "aarch64-unknown-linux-musl"
53+
},
54+
{
55+
"path": "dist/aarch64-apple-darwin/typescript-tools-aarch64-apple-darwin.tar.gz",
56+
"label": "aarch64-apple-darwin"
57+
},
58+
{
59+
"path": "dist/SHASUMS256.txt",
60+
"label": "SHASUMS256.txt"
5161
}
5262
]
5363
}

.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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ workflow.
3333

3434
## Supported Systems
3535

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

38-
- [x] GNU/Linux
39-
- [x] Mac OS
40-
- [ ] 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
4143

4244
The following package managers are supported
4345

4446
- [x] npm
4547
- [ ] yarn
48+
- [ ] pnpm

bin/monorepo

100755100644
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#!/bin/sh
2-
3-
cat <<EOF
4-
This is not the "monorepo" binary, which is usually downloaded via the npm "postinstall"
5-
hook. Was the "npm install" run with the "--ignore-scripts" flag?
6-
7-
Please try reinstalling "@typescript-tools/rust-implementation" or opening a ticket with
8-
details about your use case.
9-
EOF
1+
# This is a dummy binary that is the subject of the `npm install` workflow --
2+
# it gets linked into node_modules/.bin and marked as executable before the
3+
# npm postInstall hook executes

0 commit comments

Comments
 (0)