Skip to content

Commit

Permalink
Merge pull request #16 from titanom/ci/clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
nyarthan authored Sep 18, 2023
2 parents c619352 + 1287d47 commit db43271
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 100 deletions.
100 changes: 0 additions & 100 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,103 +39,3 @@ jobs:
with:
command: clippy
args: -- -D warnings

build-linux:
name: Build for x86_64-unknown-linux-musl
needs: check
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: mozilla-actions/[email protected]
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: x86_64-unknown-linux-musl

- run: sudo apt-get update && sudo apt install musl-tools

- name: Build for x86_64-unknown-linux-musl
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target x86_64-unknown-linux-musl

- name: Store build artifact
uses: actions/upload-artifact@v3
with:
name: x86_64-unknown-linux-musl
path: ./target/x86_64-unknown-linux-musl/release/bwenv

build-apple-silicon:
name: Build aarch64-apple-darwin
needs: check
if: github.ref == 'refs/heads/master'
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: mozilla-actions/[email protected]
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: aarch64-apple-darwin

- name: Build for aarch64-apple-darwin
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target aarch64-apple-darwin

- name: Store build artifact
uses: actions/upload-artifact@v3
with:
name: aarch64-apple-darwin
path: ./target/aarch64-apple-darwin/release/bwenv

release:
name: Release
needs:
- build-linux
- build-apple-silicon
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Download build artifacts for x86_64-unknown-linux-musl
uses: actions/download-artifact@v3
with:
name: x86_64-unknown-linux-musl
path: ./x86_64-unknown-linux-musl

- name: Download build artifacts for aarch64-apple-darwin
uses: actions/download-artifact@v3
with:
name: aarch64-apple-darwin
path: ./aarch64-apple-darwin

- name: Create archive for x86_64-unknown-linux-musl
run: zip -r -j bwenv-x86_64-unknown-linux-musl.zip x86_64-unknown-linux-musl/bwenv

- name: Create archive for aarch64-apple-darwin
run: zip -r -j bwenv-aarch64-apple-darwin.zip aarch64-apple-darwin/bwenv

- name: Read version from Cargo.toml
id: get_version
run: echo "version=$(awk -F' = ' '/^version/ {gsub(/"/, "", $2); print $2}' Cargo.toml)" >> $GITHUB_OUTPUT

- name: ls
run: ls -la

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
./bwenv-x86_64-unknown-linux-musl.zip
./bwenv-aarch64-apple-darwin.zip
tag_name: "v${{ steps.get_version.outputs.version }}"
name: "Release v${{ steps.get_version.outputs.version }}"
153 changes: 153 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
on:
workflow_dispatch:

name: CI

env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

jobs:
check:
name: Check, Format, Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: mozilla-actions/[email protected]
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Check
uses: actions-rs/cargo@v1
with:
command: check

- name: Format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Lint
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

build:
name: Build on ${{ matrix.os }} for ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
arch: [x86_64, aarch64]
lib: [gnu, musl]
exclude:
- os: macos-latest
lib: musl
- os: ubuntu-latest
arch: aarch64

steps:
- uses: actions/checkout@v3
- uses: mozilla-actions/[email protected]

- name: Compute Linux Target
id: linux-target
if: startsWith(matrix.os, 'ubuntu')
run: echo "target=${{ matrix.arch }}-unknown-linux-${{ matrix.lib }}" >> $GITHUB_OUTPUT

- name: Compute Apple Target
id: apple-target
if: startsWith(matrix.os, 'macos')
run: echo "target=${{ matrix.arch }}-apple-darwin" >> $GITHUB_OUTPUT

- name: Print Target
id: target
run: echo "target=${{ steps.linux-target.outputs.target || steps.apple-target.outputs.target }}" >> $GITHUB_OUTPUT

- name: Print Actual Target
run: echo "${{ steps.target.outputs.target }}"

- name: Install Rust Toolchain
run: rustup target add ${{ steps.target.outputs.target }}

- name: Install musl Compiler
if: startsWith(matrix.lib, 'musl')
run: sudo apt-get update && sudo apt install musl-tools

- name: Build Target ${{ steps.target.outputs.target }}
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ steps.target.outputs.target }}

- name: Upload Build Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.target.outputs.target }}
path: ./target/${{ steps.target.outputs.target }}/release/bwenv


release:
name: Release
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Download build artifacts for x86_64-unknown-linux-gnu
uses: actions/download-artifact@v3
with:
name: x86_64-unknown-linux-musl
path: ./x86_64-unknown-linux-musl

- name: Download build artifacts for x86_64-unknown-linux-musl
uses: actions/download-artifact@v3
with:
name: x86_64-unknown-linux-musl
path: ./x86_64-unknown-linux-musl

- name: Download build artifacts for aarch64-apple-darwin
uses: actions/download-artifact@v3
with:
name: aarch64-apple-darwin
path: ./aarch64-apple-darwin

- name: Download build artifacts for x86_64-apple-darwin
uses: actions/download-artifact@v3
with:
name: x86_64-apple-darwin
path: ./x86_64-apple-darwin

- name: Create archive for x86_64-unknown-linux-grnu
run: zip -r -j bwenv-x86_64-unknown-linux-gnu.zip x86_64-unknown-linux-gnu/bwenv

- name: Create archive for x86_64-unknown-linux-musl
run: zip -r -j bwenv-x86_64-unknown-linux-musl.zip x86_64-unknown-linux-musl/bwenv

- name: Create archive for aarch64-apple-darwin
run: zip -r -j bwenv-aarch64-apple-darwin.zip aarch64-apple-darwin/bwenv

- name: Create archive for x86_64-apple-darwin
run: zip -r -j bwenv-x86_64-apple-darwin.zip x86_64-apple-darwin/bwenv

- name: Read version from Cargo.toml
id: get_version
run: echo "version=$(awk -F' = ' '/^version/ {gsub(/"/, "", $2); print $2}' Cargo.toml)" >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
./bwenv-x86_64-unknown-linux-gnu.zip
./bwenv-x86_64-unknown-linux-musl.zip
./bwenv-aarch64-apple-darwin.zip
./bwenv-x86_64-apple-darwin.zip
tag_name: "v${{ steps.get_version.outputs.version }}"
name: "Release v${{ steps.get_version.outputs.version }}"
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ tokio = { version = "1.32.0", features = ["full"] }
toml = "0.7.6"
uuid = "1.4.1"
openssl = { version = "0.10", features = ["vendored"] }

[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-gnu-gcc"
rustflags = ["-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc"]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
rustflags = ["-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc"]

0 comments on commit db43271

Please sign in to comment.