-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Tlntin/master
speed up github action compile
- Loading branch information
Showing
2 changed files
with
150 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,14 @@ jobs: | |
- os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-musl | ||
use-cross: false | ||
|
||
- os: ubuntu-20.04 | ||
target: aarch64-unknown-linux-gnu | ||
use-cross: true | ||
|
||
- os: ubuntu-20.04 | ||
target: aarch64-unknown-linux-musl | ||
use-cross: true | ||
|
||
- os: macos-latest | ||
target: x86_64-apple-darwin | ||
|
@@ -27,6 +35,10 @@ jobs: | |
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
use-cross: false | ||
|
||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
use-cross: false | ||
|
||
steps: | ||
- name: Checkout repository | ||
|
@@ -45,6 +57,17 @@ jobs: | |
profile: minimal | ||
override: true | ||
target: ${{ matrix.target }} | ||
|
||
- name: rust cache restore | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
|
||
- name: Build | ||
|
@@ -53,96 +76,23 @@ jobs: | |
use-cross: ${{ matrix.use-cross }} | ||
command: build | ||
args: --target ${{ matrix.target }} --release --locked | ||
|
||
- name: Strip binary | ||
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-latest' | ||
run: strip target/${{ matrix.target }}/release/et | ||
|
||
- name: Upload binaries to release | ||
uses: svenstaro/upload-release-action@v1-release | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: target/${{ matrix.target }}/release/et | ||
asset_name: et-${{ steps.version.outputs.VERSION }}-${{ matrix.target }} | ||
tag: ${{ github.ref }} | ||
|
||
x86_64-pc-windows-msvc: | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: false | ||
target: x86_64-pc-windows-msvc | ||
|
||
- name: Build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: ${{ matrix.use-cross }} | ||
command: build | ||
args: --release --locked | ||
|
||
- name: Upload binaries to release | ||
uses: svenstaro/upload-release-action@v1-release | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: target/release/et.exe | ||
asset_name: et-x86_64-pc-windows-msvc.exe | ||
tag: ${{ github.ref }} | ||
|
||
|
||
|
||
aarch64-unknown-linux-gnu-: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set the version | ||
id: version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
target: aarch64-unknown-linux-gnu | ||
|
||
- uses: uraimo/[email protected] | ||
name: build native modules using another arch | ||
with: | ||
arch: aarch64 | ||
distro: ubuntu20.04 | ||
githubToken: ${{ github.token }} | ||
dockerRunArgs: | | ||
--volume "${PWD}:/build" | ||
--volume "/home/runner:/home/runner" | ||
install: | | ||
apt-get update && apt-get install -y gnupg2 && apt-get install curl gcc g++ make -y | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
source "$HOME/.cargo/env" | ||
run: | | ||
uname -a | ||
chmod -R 777 /build | ||
source "$HOME/.cargo/env" | ||
cargo build --release --locked | ||
- name: Upload binaries to release | ||
uses: svenstaro/upload-release-action@v1-release | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: target/release/et | ||
asset_name: et-${{ steps.version.outputs.VERSION }}-aarch64-unknown-linux-gnu | ||
tag: ${{ github.ref }} | ||
|
||
- name: Upload files (only for Mac/Linux) | ||
if: matrix.target != 'x86_64-pc-windows-msvc' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
UPLOADTOOL_ISPRERELEASE: true | ||
run: | | ||
curl -L https://github.com/probonopd/uploadtool/raw/master/upload.sh --output upload.sh | ||
mv target/${{ matrix.target }}/release/et et-${{ steps.version.outputs.VERSION }}-${{ matrix.target }} | ||
bash upload.sh et-${{ steps.version.outputs.VERSION }}-${{ matrix.target }} | ||
- name: Upload files (only for Windows) | ||
if: matrix.target == 'x86_64-pc-windows-msvc' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
UPLOADTOOL_ISPRERELEASE: true | ||
run: | | ||
curl -L https://github.com/probonopd/uploadtool/raw/master/upload.sh --output upload.sh | ||
mv target/${{ matrix.target }}/release/et.exe et-${{ steps.version.outputs.VERSION }}-${{ matrix.target }}.exe | ||
bash upload.sh et-${{ steps.version.outputs.VERSION }}-${{ matrix.target }}.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: Test App With Cache | ||
|
||
on: | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
publish: | ||
name: ${{ matrix.target }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-gnu | ||
use-cross: false | ||
|
||
- os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-musl | ||
use-cross: false | ||
|
||
- os: ubuntu-20.04 | ||
target: aarch64-unknown-linux-gnu | ||
use-cross: true | ||
|
||
- os: ubuntu-20.04 | ||
target: aarch64-unknown-linux-musl | ||
use-cross: true | ||
|
||
- os: macos-latest | ||
target: x86_64-apple-darwin | ||
use-cross: false | ||
|
||
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
use-cross: false | ||
|
||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
use-cross: false | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set the version | ||
id: version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
target: ${{ matrix.target }} | ||
|
||
- name: rust cache restore | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
|
||
- name: Build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: ${{ matrix.use-cross }} | ||
command: build | ||
args: --target ${{ matrix.target }} --release --locked | ||
|
||
- name: Upload files (only for Mac/Linux) | ||
if: matrix.target != 'x86_64-pc-windows-msvc' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
UPLOADTOOL_ISPRERELEASE: true | ||
run: | | ||
curl -L https://github.com/probonopd/uploadtool/raw/master/upload.sh --output upload.sh | ||
mv target/${{ matrix.target }}/release/et et-${{ matrix.target }} | ||
bash upload.sh et-${{ matrix.target }} | ||
- name: Upload files (only for Windows) | ||
if: matrix.target == 'x86_64-pc-windows-msvc' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
UPLOADTOOL_ISPRERELEASE: true | ||
run: | | ||
curl -L https://github.com/probonopd/uploadtool/raw/master/upload.sh --output upload.sh | ||
mv target/${{ matrix.target }}/release/et.exe et-${{ matrix.target }}.exe | ||
bash upload.sh et-${{ matrix.target }}.exe | ||
|
||
- name: rust cache store | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} |