Skip to content

speed up github action compile #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 42 additions & 92 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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/run-on-arch-action@v2.3.0
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
108 changes: 108 additions & 0 deletions .github/workflows/test.yml
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') }}