Skip to content
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
115 changes: 115 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

env:
CARGO_TERM_COLOR: always

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Check formatting
run: cargo fmt --all -- --check

- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings

test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4

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

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Run tests
run: cargo test --all-features --verbose

coverage:
name: Test Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Install tarpaulin
run: cargo install cargo-tarpaulin

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Run tests with coverage
run: cargo tarpaulin --out Xml --output-dir coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage/cobertura.xml
fail_ci_if_error: false

- name: Generate HTML coverage report
run: cargo tarpaulin --out Html --output-dir coverage

- name: Upload coverage HTML report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/tarpaulin-report.html
retention-days: 30

244 changes: 244 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
name: Release

on:
push:
tags:
- 'v*.*.*' # Official releases (e.g., v1.0.0)
- 'v*.*.*-alpha*' # Alpha releases (e.g., v1.0.0-alpha.1)

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: aarch64-pc-windows-msvc
os: windows-latest

steps:
- uses: actions/checkout@v4

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

- name: Install cross-compilation dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-musl" ]; then
sudo apt-get install -y musl-tools
fi
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu
fi

- name: Install cross-compilation dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
if [ "${{ matrix.target }}" = "x86_64-apple-darwin" ]; then
rustup target add x86_64-apple-darwin
fi
if [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then
rustup target add aarch64-apple-darwin
fi

- name: Install cross-compilation dependencies (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
if [ "${{ matrix.target }}" = "aarch64-pc-windows-msvc" ]; then
rustup target add aarch64-pc-windows-msvc
fi

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-

- name: Build release binary
run: |
cargo build --release --target ${{ matrix.target }}

- name: Determine binary name
id: binary_name
shell: bash
run: |
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
echo "name=connect-util.exe" >> $GITHUB_OUTPUT
else
echo "name=connect-util" >> $GITHUB_OUTPUT
fi

- name: Determine archive name
id: archive_name
shell: bash
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
TARGET=${{ matrix.target }}

if [[ "$TARGET" == *"windows"* ]]; then
ARCHIVE_NAME="connect-util-${TAG_NAME}-${TARGET}.zip"
echo "name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
echo "format=zip" >> $GITHUB_OUTPUT
else
ARCHIVE_NAME="connect-util-${TAG_NAME}-${TARGET}.tar.gz"
echo "name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
echo "format=tar.gz" >> $GITHUB_OUTPUT
fi

- name: Create archive (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../${{ steps.archive_name.outputs.name }} ${{ steps.binary_name.outputs.name }}
cd ../../../

- name: Create archive (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Push-Location "target/${{ matrix.target }}/release"
Compress-Archive -Path "${{ steps.binary_name.outputs.name }}" -DestinationPath "../../../${{ steps.archive_name.outputs.name }}" -Force
Pop-Location

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: ${{ steps.archive_name.outputs.name }}
retention-days: 90

release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Determine release type
id: release_type
shell: bash
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
if [[ "$TAG_NAME" == *"-alpha"* ]]; then
echo "type=alpha" >> $GITHUB_OUTPUT
echo "prerelease=true" >> $GITHUB_OUTPUT
else
echo "type=official" >> $GITHUB_OUTPUT
echo "prerelease=false" >> $GITHUB_OUTPUT
fi
echo "tag=${TAG_NAME}" >> $GITHUB_OUTPUT

- name: Extract version from tag
id: version
shell: bash
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
VERSION=${TAG_NAME#v}
echo "version=${VERSION}" >> $GITHUB_OUTPUT

- name: Generate release notes
id: release_notes
shell: bash
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
VERSION=${{ steps.version.outputs.version }}

if [[ "${{ steps.release_type.outputs.type }}" == "alpha" ]]; then
NOTES="## Alpha Release ${VERSION}

This is an alpha release. Use with caution.

### Installation

Download the appropriate binary for your platform:

- **Linux (x86_64)**: \`connect-util-${TAG_NAME}-x86_64-unknown-linux-gnu.tar.gz\`
- **Linux (ARM64)**: \`connect-util-${TAG_NAME}-aarch64-unknown-linux-gnu.tar.gz\`
- **macOS (Intel)**: \`connect-util-${TAG_NAME}-x86_64-apple-darwin.tar.gz\`
- **macOS (Apple Silicon)**: \`connect-util-${TAG_NAME}-aarch64-apple-darwin.tar.gz\`
- **Windows (x86_64)**: \`connect-util-${TAG_NAME}-x86_64-pc-windows-msvc.zip\`
- **Windows (ARM64)**: \`connect-util-${TAG_NAME}-aarch64-pc-windows-msvc.zip\`

### Checksums

SHA256 checksums are available for all binaries."
else
NOTES="## Release ${VERSION}

### Installation

Download the appropriate binary for your platform:

- **Linux (x86_64)**: \`connect-util-${TAG_NAME}-x86_64-unknown-linux-gnu.tar.gz\`
- **Linux (ARM64)**: \`connect-util-${TAG_NAME}-aarch64-unknown-linux-gnu.tar.gz\`
- **macOS (Intel)**: \`connect-util-${TAG_NAME}-x86_64-apple-darwin.tar.gz\`
- **macOS (Apple Silicon)**: \`connect-util-${TAG_NAME}-aarch64-apple-darwin.tar.gz\`
- **Windows (x86_64)**: \`connect-util-${TAG_NAME}-x86_64-pc-windows-msvc.zip\`
- **Windows (ARM64)**: \`connect-util-${TAG_NAME}-aarch64-pc-windows-msvc.zip\`

### Checksums

SHA256 checksums are available for all binaries."
fi

echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Generate checksums
shell: bash
run: |
cd artifacts
find . -type f \( -name "*.tar.gz" -o -name "*.zip" \) | while read file; do
sha256sum "$file" >> checksums.txt
done

- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_type.outputs.tag }}
name: Release ${{ steps.version.outputs.version }}
body: ${{ steps.release_notes.outputs.notes }}
prerelease: ${{ steps.release_type.outputs.prerelease }}
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip
artifacts/checksums.txt
draft: false
generate_release_notes: false

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# will have compiled files and executables
debug
target
release
coverage

# These are backup files generated by rustfmt
**/*.rs.bk
Expand All @@ -19,3 +21,9 @@ target
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

IMPLEMENTATION_SUMMARY.md
cobertura.xml
demo.tf
test.tf
.DS_Store
Loading