-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d59fb9
commit c80930f
Showing
12 changed files
with
413 additions
and
199 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 |
---|---|---|
@@ -1,187 +1,77 @@ | ||
name: Build | ||
|
||
on: | ||
#pull_request: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
defaults: | ||
run: | ||
# necessary for windows | ||
shell: bash | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cargo cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
./target | ||
key: test-cargo-registry | ||
- name: List | ||
run: find ./ | ||
- name: Run tests | ||
run: cargo test --verbose | ||
|
||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# a list of all the targets | ||
target: | ||
- x86_64-unknown-linux-musl | ||
- x86_64-apple-darwin | ||
include: | ||
- TARGET: x86_64-unknown-linux-gnu # tested in a debian container on a mac | ||
OS: ubuntu-latest | ||
- TARGET: x86_64-unknown-linux-musl # test in an alpine container on a mac | ||
OS: ubuntu-latest | ||
- TARGET: aarch64-unknown-linux-gnu # tested on aws t4g.nano | ||
OS: ubuntu-latest | ||
- TARGET: aarch64-unknown-linux-musl # tested on aws t4g.nano in alpine container | ||
OS: ubuntu-latest | ||
- TARGET: armv7-unknown-linux-gnueabihf # raspberry pi 2-3-4, not tested | ||
OS: ubuntu-latest | ||
- TARGET: armv7-unknown-linux-musleabihf # raspberry pi 2-3-4, not tested | ||
OS: ubuntu-latest | ||
- TARGET: arm-unknown-linux-gnueabihf # raspberry pi 0-1, not tested | ||
OS: ubuntu-latest | ||
- TARGET: arm-unknown-linux-musleabihf # raspberry pi 0-1, not tested | ||
OS: ubuntu-latest | ||
- TARGET: x86_64-apple-darwin # tested on a mac, is not properly signed so there are security warnings | ||
OS: macos-latest | ||
- TARGET: x86_64-pc-windows-msvc # tested on a windows machine | ||
OS: windows-latest | ||
needs: test | ||
runs-on: ${{ matrix.OS }} | ||
env: | ||
NAME: cargo-appraiser | ||
TARGET: ${{ matrix.TARGET }} | ||
OS: ${{ matrix.OS }} | ||
- target: x86_64-unknown-linux-musl | ||
os: ubuntu-latest | ||
- target: x86_64-apple-darwin | ||
os: macos-latest | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cargo cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
./target | ||
key: build-cargo-registry-${{ matrix.OS }}-${{ matrix.TARGET }} | ||
- name: List | ||
run: find ./ | ||
- name: Install and configure dependencies | ||
- uses: actions/checkout@v4 | ||
- name: Build Linux | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
if [[ $OS == "ubuntu-latest" ]]; then | ||
sudo apt-get update | ||
if [[ "$TARGET" == *musl* ]]; then | ||
# Install musl-tools and other musl-specific dependencies | ||
sudo apt-get install -qq musl-tools musl-dev libssl-dev pkg-config | ||
else | ||
# Install GNU-specific dependencies | ||
sudo apt-get install -qq libssl-dev pkg-config | ||
fi | ||
elif [[ $OS == "macos-latest" ]]; then | ||
# Install OpenSSL@3 using Homebrew | ||
brew install openssl@3 | ||
# Set OpenSSL environment variables | ||
echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV | ||
echo "OPENSSL_INCLUDE_DIR=$(brew --prefix openssl@3)/include" >> $GITHUB_ENV | ||
echo "OPENSSL_LIB_DIR=$(brew --prefix openssl@3)/lib" >> $GITHUB_ENV | ||
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> $GITHUB_ENV | ||
echo "$(brew --prefix openssl@3)/bin" >> $GITHUB_PATH | ||
elif [[ $OS == "windows-latest" ]]; then | ||
# Install dependencies for Windows if needed (e.g., OpenSSL via Chocolatey) | ||
choco install openssl | ||
fi | ||
# Configure linker based on target | ||
if [[ "$TARGET" == *musl* ]]; then | ||
echo "[target.$TARGET]" >> ~/.cargo/config | ||
echo "linker = \"musl-gcc\"" >> ~/.cargo/config | ||
else | ||
# Use the default system linker or specify if cross-linking | ||
case "$TARGET" in | ||
x86_64-unknown-linux-gnu) | ||
echo "[target.x86_64-unknown-linux-gnu]" >> ~/.cargo/config | ||
echo "linker = \"gcc\"" >> ~/.cargo/config | ||
;; | ||
aarch64-unknown-linux-gnu) | ||
echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config | ||
echo "linker = \"aarch64-linux-gnu-gcc\"" >> ~/.cargo/config | ||
;; | ||
armv7-unknown-linux-gnueabihf) | ||
echo "[target.armv7-unknown-linux-gnueabihf]" >> ~/.cargo/config | ||
echo "linker = \"arm-linux-gnueabihf-gcc\"" >> ~/.cargo/config | ||
;; | ||
arm-unknown-linux-gnueabihf) | ||
echo "[target.arm-unknown-linux-gnueabihf]" >> ~/.cargo/config | ||
echo "linker = \"arm-linux-gnueabihf-gcc\"" >> ~/.cargo/config | ||
;; | ||
x86_64-pc-windows-msvc) | ||
# For Windows MSVC, ensure the Visual Studio environment is set up | ||
echo "[target.x86_64-pc-windows-msvc]" >> ~/.cargo/config | ||
echo "rustflags = [\"-C\", \"target-feature=+crt-static\"]" >> ~/.cargo/config | ||
;; | ||
x86_64-apple-darwin) | ||
# For macOS, set specific environment variables for OpenSSL | ||
echo "[target.x86_64-apple-darwin]" >> ~/.cargo/config | ||
echo "rustflags = [\"-L\", \"$OPENSSL_LIB_DIR\", \"-lssl\", \"-lcrypto\"]" >> ~/.cargo/config | ||
;; | ||
*) | ||
echo "Unknown target: $TARGET" | ||
exit 1 | ||
;; | ||
esac | ||
fi | ||
- name: Install rust target | ||
run: rustup target add $TARGET | ||
- name: Run build | ||
run: cargo build --release --verbose --target $TARGET | ||
- name: List target | ||
run: find ./target | ||
- name: Compress | ||
run: | | ||
mkdir -p ./artifacts | ||
# Determine the executable name based on the OS | ||
if [[ $OS == "windows-latest" ]]; then | ||
EXEC=$NAME.exe | ||
else | ||
EXEC=$NAME | ||
fi | ||
# Determine the tag name or commit SHA | ||
if [[ $GITHUB_REF_TYPE == "tag" ]]; then | ||
TAG=$GITHUB_REF_NAME | ||
else | ||
TAG=$GITHUB_SHA | ||
fi | ||
# Move and compress the executable | ||
mv ./target/$TARGET/release/$EXEC ./$EXEC | ||
tar -czf ./artifacts/$NAME-$TARGET-$TAG.tar.gz $EXEC | ||
- name: Archive artifact | ||
uses: actions/upload-artifact@v4 | ||
docker run --rm -t \ | ||
-v $HOME/.cargo/registry/:/root/.cargo/registry \ | ||
-v "$(pwd)":/volume \ | ||
clux/muslrust:stable \ | ||
cargo build --release --bin kopium --target ${{ matrix.target }} | ||
- name: Prepare macOS | ||
if: matrix.os == 'macos-latest' | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
target: ${{ matrix.target }} | ||
override: true | ||
- name: Build macOS | ||
if: matrix.os == 'macos-latest' | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
toolchain: stable | ||
command: build | ||
args: --release --bin kopium --target ${{ matrix.target }} | ||
- name: Upload | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: result | ||
path: | | ||
./artifacts | ||
name: kopium-${{ matrix.os }}-amd64 | ||
path: target/${{ matrix.target }}/release/kopium | ||
if-no-files-found: error | ||
|
||
# deploys to github releases on tag | ||
deploy: | ||
if: startsWith(github.ref, 'refs/tags/') | ||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download artifacts | ||
- uses: actions/checkout@v4 | ||
- name: Download | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: result | ||
path: ./artifacts | ||
- name: List | ||
run: find ./artifacts | ||
- name: Layout | ||
run: | | ||
mv kopium-ubuntu-latest-amd64/kopium ./kopium-linux-amd64 | ||
mv kopium-macos-latest-amd64/kopium ./kopium-darwin-amd64 | ||
rm -rf kopium-ubuntu-latest-amd64 kopium-macos-latest-amd64 | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: ./artifacts/*.tar.gz | ||
generate_release_notes: true | ||
draft: true | ||
fail_on_unmatched_files: true | ||
files: | | ||
kopium-darwin-amd64 | ||
kopium-linux-amd64 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.