diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..cfe119f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: Build + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + release: + types: [created] + +jobs: + build: + name: Build on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + permissions: + contents: read + strategy: + matrix: + include: + - os: ubuntu-latest + artifact_name: macf-linux-x86_64 + binary_name: macf + - os: macos-13 + artifact_name: macf-macos-x86_64 + binary_name: macf + - os: macos-latest + artifact_name: macf-macos-arm64 + binary_name: macf + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build + run: gcc -o macf main.c + + - name: Test executable + run: | + ./macf 00:11:22:33:44:55 cisco + ./macf 00:11:22:33:44:55 dash + ./macf 00:11:22:33:44:55 colon + ./macf 00:11:22:33:44:55 raw + + - name: Create artifact directory + run: | + mkdir -p artifact + cp macf artifact/${{ matrix.binary_name }} + cp macf.1 artifact/ + cp README.md artifact/ + cp LICENSE artifact/ + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact_name }} + path: artifact/ + retention-days: 90 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..40079e2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + build-and-release: + name: Build and Release on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + permissions: + contents: write + strategy: + matrix: + include: + - os: ubuntu-latest + artifact_name: macf-linux-x86_64 + archive_name: macf-linux-x86_64.tar.gz + - os: macos-13 + artifact_name: macf-macos-x86_64 + archive_name: macf-macos-x86_64.tar.gz + - os: macos-latest + artifact_name: macf-macos-arm64 + archive_name: macf-macos-arm64.tar.gz + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build + run: gcc -o macf main.c + + - name: Test executable + run: | + ./macf 00:11:22:33:44:55 cisco + ./macf 00:11:22:33:44:55 dash + + - name: Create release package + run: | + mkdir -p release/${{ matrix.artifact_name }} + cp macf release/${{ matrix.artifact_name }}/ + cp macf.1 release/${{ matrix.artifact_name }}/ + cp README.md release/${{ matrix.artifact_name }}/ + cp LICENSE release/${{ matrix.artifact_name }}/ + cd release + tar -czf ${{ matrix.archive_name }} ${{ matrix.artifact_name }} + + - name: Upload Release Asset + uses: softprops/action-gh-release@v1 + with: + files: release/${{ matrix.archive_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..945bfb0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Build artifacts +macf + +# Editor files +*.swp +*.swo +*~ +.vscode/ +.idea/ + +# OS files +.DS_Store +Thumbs.db diff --git a/README.md b/README.md index 4da76d5..38d54ca 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,50 @@ # macf - MAC Address Formatter -`macf` is a command-line utility for converting MAC addresses into different formats. It can process a single MAC address or multiple MAC addresses from a file. +![Build](https://github.com/hexabyte8/macf/workflows/Build/badge.svg) + +`macf` is a command-line utility for converting MAC addresses into different formats. It can process a single MAC address or multiple MAC addresses from a file. + +## Download + +Pre-built binaries are available for Linux and macOS: + +### From GitHub Actions +1. Go to the [Actions tab](https://github.com/hexabyte8/macf/actions) +2. Click on the latest successful "Build" workflow run +3. Download the artifact for your platform: + - `macf-linux-x86_64` for Linux (x86_64) + - `macf-macos-x86_64` for macOS (Intel x86_64) + - `macf-macos-arm64` for macOS (Apple Silicon ARM64) +4. Extract the archive and make the binary executable: `chmod +x macf` + +### From Releases +When a release is published, download pre-built binaries from the [Releases page](https://github.com/hexabyte8/macf/releases): +- `macf-linux-x86_64.tar.gz` for Linux (x86_64) +- `macf-macos-x86_64.tar.gz` for macOS (Intel x86_64) +- `macf-macos-arm64.tar.gz` for macOS (Apple Silicon ARM64) + +Extract and install: +```bash +tar -xzf macf-*.tar.gz +cd macf-* +chmod +x macf +sudo mv macf /usr/local/bin/ +sudo mv macf.1 /usr/local/share/man/man1/ +``` + +## Build from Source + +To compile from source, you need GCC: + +```bash +gcc -o macf main.c +``` + +Or use the provided installation script: + +```bash +./install.sh +``` ## Features