|
| 1 | +GitHub Actions (CI/CD) |
| 2 | +====================== |
| 3 | + |
| 4 | +Obfuscate in your CI pipeline without touching your source or your ``.csproj``. You build your project |
| 5 | +as usual, then point the action at the compiled assembly and it comes back obfuscated. Nothing about |
| 6 | +obfuscation lives in your repo, no package reference, no MSBuild properties, no config files unless you |
| 7 | +actually want them. |
| 8 | + |
| 9 | +This is the opposite trade-off from :doc:`msbuild-integration`. The MSBuild package obfuscates *inside* |
| 10 | +your build and travels with the project; the action obfuscates *outside* it, in the pipeline only. Pick |
| 11 | +whichever fits, if you'd rather keep your project clean and only protect what ships from CI, this is it. |
| 12 | + |
| 13 | +Under the hood the action just installs ``BitMono.GlobalTool`` from nuget.org and runs it, so you can do |
| 14 | +the exact same thing by hand (see `Without the action`_ below). The action is only there to save you the |
| 15 | +boilerplate. |
| 16 | + |
| 17 | +Requirements |
| 18 | +------------ |
| 19 | + |
| 20 | +The .NET SDK has to be on the runner. If you built your project in the same job you already have it, |
| 21 | +otherwise add ``actions/setup-dotnet`` before the BitMono step. BitMono's tool runs on .NET 6–9; on a |
| 22 | +.NET 10-only runner it still works, the action rolls forward automatically. |
| 23 | + |
| 24 | +Quick start |
| 25 | +----------- |
| 26 | + |
| 27 | +.. code-block:: yaml |
| 28 | +
|
| 29 | + jobs: |
| 30 | + build: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v7 |
| 34 | + - uses: actions/setup-dotnet@v5 |
| 35 | + with: |
| 36 | + dotnet-version: 9.x |
| 37 | + - run: dotnet build -c Release |
| 38 | +
|
| 39 | + - uses: sunnamed434/BitMono@0.43.0 # pin the latest release tag |
| 40 | + with: |
| 41 | + file: bin/Release/net9.0/MyApp.dll |
| 42 | + preset: Maximum |
| 43 | +
|
| 44 | +That's it. The obfuscated assembly lands in ``bin/Release/net9.0/output/MyApp.dll`` (or set ``output:`` |
| 45 | +to put it elsewhere). Upload it with ``actions/upload-artifact``, ship it, whatever you need. |
| 46 | + |
| 47 | +Inputs |
| 48 | +------ |
| 49 | + |
| 50 | +Every input maps one-to-one to a CLI option, so anything ``BitMono.CLI`` can do you can do here. Only |
| 51 | +``file`` is required. |
| 52 | + |
| 53 | +.. list-table:: |
| 54 | + :header-rows: 1 |
| 55 | + :widths: 25 75 |
| 56 | + |
| 57 | + * - Input |
| 58 | + - Description |
| 59 | + * - ``file`` |
| 60 | + - **Required.** Path to the compiled assembly to obfuscate, e.g. ``bin/Release/net9.0/MyApp.dll``. |
| 61 | + * - ``output`` |
| 62 | + - Output directory. Default: an ``output`` folder next to ``file``. |
| 63 | + * - ``output-name`` |
| 64 | + - Output file name. Default: keeps the original name. |
| 65 | + * - ``libraries`` |
| 66 | + - Space-separated dependency directories, e.g. ``bin/Release/net9.0``. |
| 67 | + * - ``protections`` |
| 68 | + - Space-separated protections, e.g. ``FullRenamer StringsEncryption``. Overrides preset/JSON. |
| 69 | + * - ``preset`` |
| 70 | + - Protection preset: ``Minimal``, ``Balanced`` or ``Maximum``. |
| 71 | + * - ``obfuscation-file`` / ``protections-file`` / ``criticals-file`` / ``logging-file`` |
| 72 | + - Paths to the JSON config files (same formats as the CLI). Used only when you pass them. |
| 73 | + * - ``no-watermark`` |
| 74 | + - Set to ``true`` to disable the BitMono watermark. |
| 75 | + * - ``no-logo`` |
| 76 | + - Set to ``true`` to suppress the BitMono ASCII banner on startup (``--nologo``). |
| 77 | + * - ``strong-name-key`` |
| 78 | + - Path to a ``.snk`` to re-sign the obfuscated assembly. See :doc:`assembly-signing`. |
| 79 | + * - ``extra-args`` |
| 80 | + - Anything else passed straight to the CLI verbatim, for options not listed above. |
| 81 | + * - ``version`` |
| 82 | + - ``BitMono.GlobalTool`` version to install. Default: latest. See `Versioning`_. |
| 83 | + |
| 84 | +Prefer config files? It works the same as everywhere else, commit your ``protections.json`` / |
| 85 | +``criticals.json`` / ``obfuscation.json`` and point the matching inputs at them. See :doc:`how-to-use` |
| 86 | +for the schemas. |
| 87 | + |
| 88 | +Versioning |
| 89 | +---------- |
| 90 | + |
| 91 | +The action lives in the BitMono repo, so it doesn't have a version of its own, you reference it by a |
| 92 | +BitMono release tag. ``sunnamed434/BitMono@0.43.0`` reads the action from the repo at tag ``0.43.0``. |
| 93 | +Every release you'd normally cut is automatically a usable action version, nothing extra to publish. |
| 94 | + |
| 95 | +There are two things you can pin, and they're independent: |
| 96 | + |
| 97 | +- the **tag** after ``@`` decides which version of the action wrapper you run. |
| 98 | +- the **``version``** input decides which version of the obfuscator (the nuget tool) it installs. |
| 99 | + Defaults to latest. |
| 100 | + |
| 101 | +For a build that produces the same bytes months from now, pin both to the same number: |
| 102 | + |
| 103 | +.. code-block:: yaml |
| 104 | +
|
| 105 | + - uses: sunnamed434/BitMono@0.43.0 |
| 106 | + with: |
| 107 | + file: bin/Release/net9.0/MyApp.dll |
| 108 | + version: 0.43.0 |
| 109 | +
|
| 110 | +Use the newest tag from the `releases page <https://github.com/sunnamed434/BitMono/releases>`_. |
| 111 | + |
| 112 | +Without the action |
| 113 | +------------------ |
| 114 | + |
| 115 | +You don't actually need the action, it's a thin wrapper over the global tool. If you'd rather not pull a |
| 116 | +third-party action into your workflow, two ``run`` steps do the same job: |
| 117 | + |
| 118 | +.. code-block:: yaml |
| 119 | +
|
| 120 | + - run: dotnet tool install --global BitMono.GlobalTool |
| 121 | + - run: bitmono.console -f bin/Release/net9.0/MyApp.dll --preset Maximum |
| 122 | +
|
| 123 | +The action just saves you the install dance, the PATH handling and the argument mapping. |
| 124 | + |
| 125 | +Troubleshooting |
| 126 | +--------------- |
| 127 | + |
| 128 | +The CLI exits non-zero when obfuscation fails, so a broken run fails the job, no silent pass. Read the |
| 129 | +log under the ``BitMono obfuscation`` group in the step output, it has the full command and the |
| 130 | +obfuscator's messages. See :doc:`troubleshooting`. |
0 commit comments