Release Binaries #4
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: Release Binaries | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag (e.g., v1.0.0)' | |
| required: true | |
| default: 'v1.0.0' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-dotnet: | |
| name: Build .NET Executables | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| runtime: linux-x64 | |
| artifact: linux | |
| ext: '' | |
| - os: windows-latest | |
| runtime: win-x64 | |
| artifact: windows | |
| ext: '.exe' | |
| - os: macos-latest | |
| runtime: osx-x64 | |
| artifact: macos | |
| ext: '' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Publish AdGuard.ConsoleUI | |
| shell: bash | |
| run: | | |
| dotnet publish src/adguard-api-dotnet/src/AdGuard.ConsoleUI/AdGuard.ConsoleUI.csproj \ | |
| --configuration Release \ | |
| --runtime ${{ matrix.runtime }} \ | |
| --self-contained true \ | |
| -p:PublishSingleFile=true \ | |
| -p:IncludeNativeLibrariesForSelfExtract=true \ | |
| --output ./artifacts/adguard-console-ui | |
| - name: Publish RulesCompiler.Console | |
| shell: bash | |
| run: | | |
| dotnet publish src/rules-compiler-dotnet/src/RulesCompiler.Console/RulesCompiler.Console.csproj \ | |
| --configuration Release \ | |
| --runtime ${{ matrix.runtime }} \ | |
| --self-contained true \ | |
| -p:PublishSingleFile=true \ | |
| -p:IncludeNativeLibrariesForSelfExtract=true \ | |
| --output ./artifacts/rules-compiler-dotnet | |
| - name: Package binaries (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| Compress-Archive -Path ./artifacts/adguard-console-ui/* -DestinationPath AdGuard.ConsoleUI-${{ matrix.artifact }}.zip | |
| Compress-Archive -Path ./artifacts/rules-compiler-dotnet/* -DestinationPath RulesCompiler.Console-${{ matrix.artifact }}.zip | |
| - name: Package binaries (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| cd ./artifacts/adguard-console-ui && tar -czf ../../AdGuard.ConsoleUI-${{ matrix.artifact }}.tar.gz * && cd ../.. | |
| cd ./artifacts/rules-compiler-dotnet && tar -czf ../../RulesCompiler.Console-${{ matrix.artifact }}.tar.gz * && cd ../.. | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dotnet-${{ matrix.artifact }} | |
| path: | | |
| *.zip | |
| *.tar.gz | |
| if-no-files-found: error | |
| build-rust: | |
| name: Build Rust Executable | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact: linux | |
| ext: '' | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact: windows | |
| ext: '.exe' | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact: macos | |
| ext: '' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: ${{ matrix.target }} | |
| - name: Build Rust compiler | |
| shell: bash | |
| working-directory: ./src/rules-compiler-rust | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package binary (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| Compress-Archive -Path ./src/rules-compiler-rust/target/${{ matrix.target }}/release/rules-compiler${{ matrix.ext }} -DestinationPath rules-compiler-rust-${{ matrix.artifact }}.zip | |
| - name: Package binary (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| tar -czf rules-compiler-rust-${{ matrix.artifact }}.tar.gz -C ./src/rules-compiler-rust/target/${{ matrix.target }}/release rules-compiler${{ matrix.ext }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rust-${{ matrix.artifact }} | |
| path: | | |
| *.zip | |
| *.tar.gz | |
| if-no-files-found: error | |
| create-release: | |
| name: Create Release | |
| needs: [build-dotnet, build-rust] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Validate and set release version | |
| id: version | |
| shell: bash | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| # Semver 2.0.0 compliant version pattern | |
| SEMVER_PATTERN='^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$' | |
| if ! echo "$VERSION" | grep -qE "$SEMVER_PATTERN"; then | |
| echo "Error: Version must follow format 'vX.Y.Z' or 'vX.Y.Z-suffix'" | |
| echo "Examples: v1.0.0, v1.0.0-beta, v1.0.0-rc1, v1.0.0-alpha.1" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # Check if tag exists remotely | |
| if git ls-remote --tags origin | grep -q "refs/tags/$VERSION$"; then | |
| echo "Tag $VERSION already exists remotely" | |
| else | |
| echo "Creating tag $VERSION" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$VERSION" -m "Release $VERSION" | |
| git push origin "$VERSION" | |
| echo "Tag $VERSION created and pushed successfully" | |
| fi | |
| else | |
| echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./release-artifacts | |
| - name: Prepare release assets | |
| shell: bash | |
| run: | | |
| mkdir -p ./release-assets | |
| find ./release-artifacts -type f \( -name '*.zip' -o -name '*.tar.gz' \) -exec cp {} ./release-assets/ \; | |
| echo "Release assets:" | |
| ls -lh ./release-assets | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.version }} | |
| files: ./release-assets/* | |
| body: | | |
| ## Release ${{ steps.version.outputs.version }} | |
| This release includes pre-built binaries for: | |
| - **AdGuard.ConsoleUI** - Console UI for AdGuard DNS API (Windows, Linux, macOS) | |
| - **RulesCompiler.Console** - .NET rules compiler (Windows, Linux, macOS) | |
| - **rules-compiler** (Rust) - Rust rules compiler (Windows, Linux, macOS) | |
| ### Installation | |
| #### AdGuard Console UI | |
| Download and extract: | |
| - Windows: `AdGuard.ConsoleUI-windows.zip` | |
| - Linux: `AdGuard.ConsoleUI-linux.tar.gz` | |
| - macOS: `AdGuard.ConsoleUI-macos.tar.gz` | |
| #### Rules Compiler (.NET) | |
| Download and extract: | |
| - Windows: `RulesCompiler.Console-windows.zip` | |
| - Linux: `RulesCompiler.Console-linux.tar.gz` | |
| - macOS: `RulesCompiler.Console-macos.tar.gz` | |
| #### Rules Compiler (Rust) | |
| Download and extract: | |
| - Windows: `rules-compiler-rust-windows.zip` | |
| - Linux: `rules-compiler-rust-linux.tar.gz` | |
| - macOS: `rules-compiler-rust-macos.tar.gz` | |
| ### Usage | |
| After extraction, run the executables: | |
| - Windows: `.\AdGuard.ConsoleUI.exe`, `.\RulesCompiler.Console.exe`, or `.\rules-compiler.exe` | |
| - Linux/macOS: `./AdGuard.ConsoleUI`, `./RulesCompiler.Console`, or `./rules-compiler` | |
| For detailed documentation, see the [README](https://github.com/jaypatrick/ad-blocking/blob/main/README.md). | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |