Skip to content

Commit

Permalink
improve deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Heliozoa committed Jun 7, 2021
1 parent e013de6 commit 98de421
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 45 deletions.
104 changes: 61 additions & 43 deletions .github/workflows/upload-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,6 @@ env:
TAG: ${{ github.event.release.tag_name }} # had some issue using this directly on windows

jobs:
linux:
runs-on: ubuntu-18.04
strategy:
matrix:
target: [i686-unknown-linux-gnu, x86_64-unknown-linux-gnu]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y gcc-multilib # required to build for 32-bit arch
- name: Build
run: |
rustup target add ${{ matrix.target }}
cargo build -p tmc-langs-cli --release --verbose --target ${{ matrix.target }}
npm --prefix ./bindings/tmc-langs-node install
npm --prefix ./bindings/tmc-langs-node run build -- --release --verbose --target ${{ matrix.target }}
- name: Deploy
run: |
gsutil cp target/${{ matrix.target }}/release/tmc-langs-cli gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-${{ matrix.target }}-$TAG
gsutil cp bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-${{ matrix.target }}-$TAG.node
windows:
runs-on: windows-latest
strategy:
Expand All @@ -57,7 +28,7 @@ jobs:
rustup target add ${{ matrix.target }}
$env:RUSTFLAGS="-C target-feature=+crt-static"
cargo build -p tmc-langs-cli --release --verbose --target ${{ matrix.target }}
cd ./bindings/tmc-langs-node && npm install && npm run build -- --release --verbose --target ${{ matrix.target }}
cd ./bindings/tmc-langs-node && npm install && npm run build -- --release --target ${{ matrix.target }}
- name: Deploy
run: |
$env:python_version=$(python -c 'import sys; print(\".\".join(map(str, sys.version_info[:3])))')
Expand All @@ -80,19 +51,16 @@ jobs:
run: |
cargo build -p tmc-langs-cli --release --verbose
npm --prefix ./bindings/tmc-langs-node install
npm run --prefix ./bindings/tmc-langs-node build -- --release --verbose
npm run --prefix ./bindings/tmc-langs-node build -- --release
- name: Sign
run: codesign --force -s - target/release/tmc-langs-cli
- name: Deploy
run: |
gsutil cp target/release/tmc-langs-cli gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-x86_64-apple-darwin-$TAG
gsutil cp bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-x86_64-apple-darwin-$TAG.node
arm:
ubuntu:
runs-on: ubuntu-18.04
strategy:
matrix:
target: [aarch64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
Expand All @@ -102,14 +70,64 @@ jobs:
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Cargo build
- name: Install dependencies
run: |
rustup target add ${{ matrix.target }}
cargo install cross
cross build -p tmc-langs-cli --release --verbose --target ${{ matrix.target }}
sudo apt update
sudo apt install -y gcc-multilib # required to build for 32-bit arch
sudo apt install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf # linkers for ARM targets
- name: x86_64-unknown-linux-gnu
env:
TARGET: x86_64-unknown-linux-gnu
run: |
# build and deploy CLI
rustup target add $TARGET
cargo build -p tmc-langs-cli --release --verbose --target $TARGET
gsutil cp target/$TARGET/release/tmc-langs-cli gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-$TARGET-$TAG
# build and deploy Node module
npm --prefix ./bindings/tmc-langs-node install
npm --prefix ./bindings/tmc-langs-node run cross -- --release --verbose --target ${{ matrix.target }}
- name: Deploy
npm --prefix ./bindings/tmc-langs-node run build -- --release --target $TARGET
gsutil cp bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-$TARGET-$TAG.node
- name: i686-unknown-linux-gnu
env:
TARGET: i686-unknown-linux-gnu
run: |
gsutil cp target/${{ matrix.target }}/release/tmc-langs-cli gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-${{ matrix.target }}-$TAG
gsutil cp bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-${{ matrix.target }}-$TAG.node
# build and deploy CLI
rustup target add $TARGET
cargo build -p tmc-langs-cli --release --verbose --target $TARGET
gsutil cp target/$TARGET/release/tmc-langs-cli gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-$TARGET-$TAG
# build and deploy Node module
npm --prefix ./bindings/tmc-langs-node install
npm --prefix ./bindings/tmc-langs-node run build -- --release --target $TARGET
gsutil cp bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-$TARGET-$TAG.node
- name: aarch64-unknown-linux-gnu
env:
TARGET: aarch64-unknown-linux-gnu
run: |
# build and deploy CLI
rustup target add $TARGET
cargo build -p tmc-langs-cli --release --verbose --target $TARGET
gsutil cp target/$TARGET/release/tmc-langs-cli gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-$TARGET-$TAG
# build and deploy Node module
npm --prefix ./bindings/tmc-langs-node install
npm --prefix ./bindings/tmc-langs-node run build -- --release --target $TARGET
gsutil cp bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-$TARGET-$TAG.node
- name: armv7-unknown-linux-gnueabihf
env:
TARGET: armv7-unknown-linux-gnueabihf
run: |
# build and deploy CLI
rustup target add $TARGET
cargo build -p tmc-langs-cli --release --verbose --target $TARGET
gsutil cp target/$TARGET/release/tmc-langs-cli gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-$TARGET-$TAG
# build and deploy Node module
npm --prefix ./bindings/tmc-langs-node install
npm --prefix ./bindings/tmc-langs-node run build -- --release --target $TARGET
gsutil cp bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-$TARGET-$TAG.node
3 changes: 1 addition & 2 deletions bindings/tmc-langs-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"types": "index.d.ts",
"scripts": {
"build": "cargo-cp-artifact -nc ts/functions.node -- cargo build --message-format=json-render-diagnostics",
"cross": "cargo-cp-artifact -nc ts/functions.node -- cross build --message-format=json-render-diagnostics",
"test": "cargo test && npm run jest",
"jest": "npm install && npm run build && jest"
},
Expand Down Expand Up @@ -45,4 +44,4 @@
"d.ts"
]
}
}
}

0 comments on commit 98de421

Please sign in to comment.