diff --git a/.github/workflows/meson-build.yml b/.github/workflows/meson-build.yml index 33a0b92..5bc1265 100644 --- a/.github/workflows/meson-build.yml +++ b/.github/workflows/meson-build.yml @@ -1,10 +1,12 @@ --- name: Meson Build System -# Basically, only rebuilds and tests the project when C++ is changed -# Commented out to facilitate testing +# Builds the plugin and relay on every branch push and pull request, and keeps +# both files as workflow artifacts. The path filters are commented out to +# facilitate testing. Tags are built by release.yml, which calls this workflow. on: push: + branches: ['**'] # paths: # - "**.cpp" # - "**.h" @@ -13,13 +15,15 @@ on: # - "**.cpp" # - "**.h" workflow_dispatch: + # Lets release.yml reuse this build instead of repeating its steps. + workflow_call: permissions: contents: read jobs: build-on-windows: - name: Build and Test on Windows with Meson + name: Build the plugin and relay on Windows runs-on: windows-latest steps: - uses: actions/checkout@v4 @@ -38,6 +42,24 @@ jobs: cd xplane_plugin/ meson setup build meson compile -C build + + - name: Build the relay + working-directory: relay + run: cargo build --release + + - name: Upload the plugin + uses: actions/upload-artifact@v4 + with: + name: plugin + path: xplane_plugin/build/PilotDataSync.xpl + if-no-files-found: error + + - name: Upload the relay + uses: actions/upload-artifact@v4 + with: + name: relay + path: relay/target/release/relay.exe + if-no-files-found: error # - name: Test the Meson Project # run: | # cd xplane_plugin/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1cf59a7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +--- +name: Release + +# A v* tag publishes a GitHub Release. A manual run is a dry run: it builds +# and uploads the files as workflow artifacts, and publishes nothing. +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + name: Build the plugin and relay + uses: ./.github/workflows/meson-build.yml + + publish: + name: Publish the GitHub Release + needs: build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download the plugin and relay + uses: actions/download-artifact@v4 + with: + path: release-files + merge-multiple: true + + - name: Create the release + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: >- + gh release create "$GITHUB_REF_NAME" --generate-notes + release-files/PilotDataSync.xpl release-files/relay.exe diff --git a/AGENTS.md b/AGENTS.md index fc7852f..087bf21 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,7 +20,7 @@ Run from the repo root, in order, per component: - Baton: `cd xplane_plugin/subprojects/baton && cargo test` - Inference: `cd inference && uv sync`, then `uv run python -m pilot_inference..`. `uv run pytest` runs the tests in `inference/tests/`; the event classification scripts are mostly untested. -CI is in `.github/workflows/` (`meson-build.yml`, `super-linter.yml`). Run `meson setup` with the cross-file for your OS if not on native Windows (see README). +CI is in `.github/workflows/` (`meson-build.yml`, `super-linter.yml`, `release.yml`: a `v*` tag publishes the plugin and `relay.exe` to a GitHub Release, a manual run is a dry run). Run `meson setup` with the cross-file for your OS if not on native Windows (see README). ## Gotchas diff --git a/README.md b/README.md index d38e681..bc893ad 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,19 @@ Then: Start the components in this order: iMotions (or the mock server) → relay → X-Plane. The relay is a TCP client, and any flight data that arrives before its TCP connection is up is discarded. +## Download the built files + +Lab PCs do not need to build anything. Download `PilotDataSync.xpl` and `relay.exe` from the repo's [GitHub Releases page](https://github.com/oss-slu/PilotDataSynchronization/releases). + +- `PilotDataSync.xpl` goes into X-Plane's `Resources/plugins/PilotDataSync/win_x64/` folder. See [1. X-Plane plugin](#1-x-plane-plugin). +- `relay.exe` can live anywhere. Run it by double-clicking it. It needs no VC++ redistributable. Double-clicking it opens a console window next to the relay window, where its diagnostic messages go (see [2. Relay](#2-relay)). + +> Not yet confirmed on a clean lab PC. The DLLs that `relay.exe` loads were checked, and none is part of the VC++ redistributable, but no one has run it on a PC without the redistributable installed. If you try it on one, please confirm it and delete this note. + +Build from source only when you want to change the code, or while no release has been published yet. A release is published by pushing a `v*` tag, such as `v0.1.0`. + +To try a branch on the lab PC before it merges, open its CI run under the repo's Actions tab. Every run keeps both files as workflow artifacts. + ## Prerequisites | Tool | Version | Needed for | Notes | diff --git a/relay/.cargo/config.toml b/relay/.cargo/config.toml new file mode 100644 index 0000000..c068bbd --- /dev/null +++ b/relay/.cargo/config.toml @@ -0,0 +1,3 @@ +# Link the C runtime statically so relay.exe runs on a PC without the VC++ redistributable. +[target.x86_64-pc-windows-msvc] +rustflags = ["-C", "target-feature=+crt-static"]