Skip to content

Commit

Permalink
fix: macOS darwin build (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsojramos authored May 11, 2023
2 parents f7b64db + 53cdf65 commit ecf8a6f
Show file tree
Hide file tree
Showing 5 changed files with 428 additions and 320 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "weekly"

- package-ecosystem: "cargo"
directory: "/"
schedule:
# Check for updates managed by Composer once a week
interval: "weekly"
161 changes: 6 additions & 155 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,164 +11,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Repository Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
profile: minimal
override: true
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache
uses: Swatinem/rust-cache@v1

- name: Build Binary
run: cargo build
uses: Swatinem/rust-cache@v2

- name: Run Unit Tests
run: cargo test

publish-linux:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: build

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true

- name: Build amd64
uses: actions-rs/cargo@v1
with:
command: build
args: --all --release

- name: Prepare amd64 binary
run: |
mv target/release/discrakt target/release/discrakt_amd64
chmod +x target/release/discrakt_amd64
- name: Build arm64
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --all --release --target=aarch64-unknown-linux-musl

- name: Prepare arm64 Binary
run: |
mv target/aarch64-unknown-linux-musl/release/discrakt target/release/discrakt_arm64
chmod +x target/release/discrakt_arm64
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
target/release/discrakt_arm64
target/release/discrakt_amd64
credentials.ini
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-win:
runs-on: windows-latest
if: startsWith(github.ref, 'refs/tags/')
needs: build

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true

- name: Build win64
uses: actions-rs/cargo@v1
with:
command: build
args: --all --release

- name: Prepare win64 Binary
run: mv target/release/discrakt.exe target/release/discrakt_win64.exe

- name: Create silent win64 executable
run: sed -i '1i\#\!\[windows_subsystem\ \=\ \"windows\"\]' src/main.rs

- name: Build silent win64 executable
uses: actions-rs/cargo@v1
with:
command: build
args: --all --release

- name: Prepare silent win64 Binary
run: mv target/release/discrakt.exe target/release/discrakt_win64_silent.exe

- name: Release silent executable
uses: softprops/action-gh-release@v1
with:
files: |
target/release/discrakt_win64_silent.exe
target/release/discrakt_win64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-mac:
runs-on: macos-latest
if: startsWith(github.ref, 'refs/tags/')
needs: build

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-apple-darwin
default: true
override: true

- name: Build darwin
uses: actions-rs/cargo@v1
with:
command: build
args: --all --release

- name: Prepare darwin binary
run: |
mv target/release/discrakt target/release/discrakt_darwin
chmod +x target/release/discrakt_darwin
- name: Build darwin arm64
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --all --release --target=aarch64-apple-darwin

- name: Prepare darwin arm64 binary
run: |
mv target/aarch64-apple-darwin/release/discrakt target/release/discrakt_darwin_arm64
chmod +x target/release/discrakt_darwin_arm64
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
target/release/discrakt_darwin_arm64
target/release/discrakt_darwin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
cargo check
cargo test
25 changes: 7 additions & 18 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@ jobs:

steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install stable toolchain
id: toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
profile: minimal
override: true
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache
uses: Swatinem/rust-cache@v1
uses: Swatinem/rust-cache@v2

- name: Run clippy
uses: actions-rs/clippy-check@v1
Expand All @@ -35,15 +29,10 @@ jobs:

steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
profile: minimal
override: true
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Run cargo fmt
run: cargo fmt --all -- --check
106 changes: 106 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Release

on:
release:
types: [created]

jobs:
publish-linux:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Build amd64
run: cargo build --release

- name: Prepare amd64 binary
run: |
mv target/release/discrakt target/release/discrakt_amd64
chmod +x target/release/discrakt_amd64
- name: Build arm64
run: cargo build --release --target=aarch64-unknown-linux-musl

- name: Prepare arm64 Binary
run: |
mv target/aarch64-unknown-linux-musl/release/discrakt target/release/discrakt_arm64
chmod +x target/release/discrakt_arm64
- name: Upload binaries
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} target/release/discrakt_arm64
gh release upload ${{ github.ref_name }} target/release/discrakt_amd64
publish-win:
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Build win64
run: cargo build --release

- name: Prepare win64 Binary
run: mv target/release/discrakt.exe target/release/discrakt_win64.exe

- name: Create silent win64 executable
run: sed -i '1i\#\!\[windows_subsystem\ \=\ \"windows\"\]' src/main.rs

- name: Build silent win64 executable
run: cargo build --release

- name: Prepare silent win64 Binary
run: mv target/release/discrakt.exe target/release/discrakt_win64_silent.exe

- name: Upload binaries
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} target/release/discrakt_win64_silent.exe
gh release upload ${{ github.ref_name }} target/release/discrakt_win64.exe
publish-mac:
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: "aarch64-apple-darwin, x86_64-apple-darwin"

- name: Build darwin
run: cargo build --release --target=x86_64-apple-darwin

- name: Prepare darwin binary
run: |
mv target/x86_64-apple-darwin/release/discrakt target/release/discrakt_darwin
chmod +x target/release/discrakt_darwin
- name: Build darwin arm64
run: cargo build --release --target=aarch64-apple-darwin

- name: Prepare darwin arm64 binary
run: |
mv target/aarch64-apple-darwin/release/discrakt target/release/discrakt_darwin_arm64
chmod +x target/release/discrakt_darwin_arm64
- name: Upload binaries
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} target/release/discrakt_darwin_arm64
gh release upload ${{ github.ref_name }} target/release/discrakt_darwin
Loading

0 comments on commit ecf8a6f

Please sign in to comment.