update readme #5
This file contains hidden or 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
| name: Build Rust Binaries | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build for ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| artifact_name: externkit | |
| asset_name: externkit-linux-x86_64 | |
| - os: windows-latest | |
| artifact_name: externkit.exe | |
| asset_name: externkit-windows-x86_64.exe | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install Python development headers (Ubuntu) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y python3-dev | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Build binary | |
| run: cargo build --release --bin externkit | |
| - name: Strip binary (Linux and macOS) | |
| if: matrix.os != 'windows-latest' | |
| run: strip target/release/${{ matrix.artifact_name }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: target/release/${{ matrix.artifact_name }} | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Display structure of downloaded files | |
| run: ls -R artifacts | |
| - name: Create compressed archives | |
| run: | | |
| cd artifacts | |
| for dir in */; do | |
| cd "$dir" | |
| if [[ "$dir" == *"windows"* ]]; then | |
| zip "../${dir%/}.zip" * | |
| else | |
| tar -czf "../${dir%/}.tar.gz" * | |
| fi | |
| cd .. | |
| done | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| artifacts/*.zip | |
| artifacts/*.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |