Skip to content

Commit 926786f

Browse files
committed
Initial commit
0 parents  commit 926786f

21 files changed

Lines changed: 7227 additions & 0 deletions

.github/workflows/pull-request.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Pull request checks
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
fmt-clippy-test:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Rust
15+
uses: dtolnay/rust-toolchain@stable
16+
17+
- name: Cache cargo
18+
uses: actions/cache@v4
19+
with:
20+
path: |
21+
~/.cargo/registry
22+
~/.cargo/git
23+
target
24+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
25+
26+
- name: Install deps
27+
run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
28+
29+
- name: Check formatting
30+
run: cargo fmt -- --check
31+
32+
- name: Clippy (deny warnings)
33+
run: cargo clippy --all-targets --all-features -- -D warnings
34+
35+
- name: Run tests
36+
run: cargo test --release

.github/workflows/release.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Release cross-compile
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-upload:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
packages: write
13+
strategy:
14+
matrix:
15+
target:
16+
- x86_64-unknown-linux-musl
17+
- i686-unknown-linux-musl
18+
- aarch64-unknown-linux-musl
19+
- armv7-unknown-linux-musleabihf
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Rust toolchain
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Install target and build deps
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y \
32+
musl-tools \
33+
gcc-aarch64-linux-gnu \
34+
gcc-arm-linux-gnueabihf \
35+
gcc-i686-linux-gnu
36+
37+
rustup target add ${{ matrix.target }}
38+
39+
mkdir -p ~/.cargo
40+
41+
case "${{ matrix.target }}" in
42+
i686-unknown-linux-musl)
43+
echo '[target.i686-unknown-linux-musl]' >> ~/.cargo/config.toml
44+
echo 'linker = "i686-linux-gnu-gcc"' >> ~/.cargo/config.toml
45+
;;
46+
aarch64-unknown-linux-musl)
47+
echo '[target.aarch64-unknown-linux-musl]' >> ~/.cargo/config.toml
48+
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
49+
;;
50+
armv7-unknown-linux-musleabihf)
51+
echo '[target.armv7-unknown-linux-musleabihf]' >> ~/.cargo/config.toml
52+
echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config.toml
53+
;;
54+
esac
55+
56+
- name: Cache cargo registry and build
57+
uses: actions/cache@v4
58+
with:
59+
path: |
60+
~/.cargo/registry
61+
~/.cargo/git
62+
target
63+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.target }}
64+
65+
- name: Build (release)
66+
env:
67+
RUSTFLAGS: "-C target-feature=+crt-static -C link-arg=-s"
68+
run: |
69+
cargo build --release --target ${{ matrix.target }}
70+
71+
- name: Prepare artifact name
72+
id: artifact
73+
run: |
74+
BIN_NAME=envex
75+
VERSION=${{ github.ref_name }}
76+
TARGET=${{ matrix.target }}
77+
RELEASE_NAME="${BIN_NAME}-${VERSION}-${TARGET}"
78+
OUT="target/${TARGET}/release/${BIN_NAME}"
79+
if [ -f "${OUT}" ]; then
80+
mkdir -p "${RELEASE_NAME}"
81+
cp "${OUT}" "${RELEASE_NAME}/"
82+
cp README.md LICENSE "${RELEASE_NAME}/"
83+
cp -r man completions "${RELEASE_NAME}/"
84+
tar czf "${RELEASE_NAME}.tar.gz" "${RELEASE_NAME}"
85+
echo "found=true" >> $GITHUB_OUTPUT
86+
echo "path=${RELEASE_NAME}.tar.gz" >> $GITHUB_OUTPUT
87+
else
88+
echo "found=false" >> $GITHUB_OUTPUT
89+
fi
90+
91+
- name: Upload release asset
92+
if: steps.artifact.outputs.found == 'true'
93+
uses: softprops/action-gh-release@v1
94+
with:
95+
files: ${{ steps.artifact.outputs.path }}
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: ["main", "master"]
6+
7+
jobs:
8+
fmt-clippy-test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Rust
16+
uses: dtolnay/rust-toolchain@stable
17+
18+
- name: Cache cargo
19+
uses: actions/cache@v4
20+
with:
21+
path: |
22+
~/.cargo/registry
23+
~/.cargo/git
24+
target
25+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
26+
27+
- name: Install deps
28+
run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
29+
30+
- name: Check formatting
31+
run: cargo fmt -- --check
32+
33+
- name: Clippy (deny warnings)
34+
run: cargo clippy --all-targets --all-features -- -D warnings
35+
36+
- name: Run tests
37+
run: cargo test --release

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target
2+
/man
3+
/completions

.gitleaks.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Gitleaks configuration
2+
# https://github.com/gitleaks/gitleaks
3+
#
4+
# The files below contain intentionally fake secrets used for testing
5+
# a secret detection tool. All values are synthetic and not valid.
6+
7+
[allowlist]
8+
paths = [
9+
'''tests/demo\.sh''',
10+
'''tests/integration_tests\.rs''',
11+
'''src/detect\.rs''',
12+
]

0 commit comments

Comments
 (0)