initial #18
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 | |
| on: | |
| push: | |
| branches: ["**"] | |
| tags: ["v*"] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| LIBTCD_URL: https://flaterco.com/files/xtide/libtcd-2.2.7-r3.tar.xz | |
| HARMONICS_URL: https://flaterco.com/files/xtide/harmonics-dwf-20251228-free.tar.xz | |
| XTIDE_WIN64_ZIP_URL: https://flaterco.com/files/xtide/xtide-2.15-win64.zip | |
| jobs: | |
| linux-amd64: | |
| name: linux (amd64) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Compute artifact tag | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| echo "ARTIFACT_TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV" | |
| else | |
| echo "ARTIFACT_TAG=sha-${GITHUB_SHA::7}" >> "$GITHUB_ENV" | |
| fi | |
| - name: Install deps | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| cmake ninja-build pkg-config g++ \ | |
| curl tar xz-utils make | |
| - name: Build + install libtcd (prefix) | |
| run: | | |
| set -euo pipefail | |
| rm -rf _deps && mkdir -p _deps | |
| cd _deps | |
| curl -L --retry 3 --retry-delay 2 -o libtcd.tar.xz "${LIBTCD_URL}" | |
| tar -xf libtcd.tar.xz | |
| LIBTCD_DIR="$(find . -maxdepth 1 -type d -name 'libtcd-*' | head -n1)" | |
| PREFIX="$PWD/libtcd-prefix" | |
| cd "$LIBTCD_DIR" | |
| ./configure --prefix="$PREFIX" | |
| make -j | |
| make install | |
| echo "TCD_PREFIX=$PREFIX" >> "$GITHUB_ENV" | |
| - name: Configure (release) | |
| run: | | |
| cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_PREFIX_PATH="${{ env.TCD_PREFIX }}" | |
| - name: Build | |
| run: | | |
| cmake --build build -j | |
| - name: Download harmonics (.tcd) for smoke test | |
| run: | | |
| set -euo pipefail | |
| rm -rf _deps/harmonics | |
| mkdir -p _deps/harmonics | |
| cd _deps/harmonics | |
| curl -L --retry 3 --retry-delay 2 -o harmonics.tar.xz "${HARMONICS_URL}" | |
| tar -xf harmonics.tar.xz | |
| TCD_FILE="$(find . -type f -name '*.tcd' | head -n1)" | |
| if [ -z "${TCD_FILE}" ]; then | |
| echo "ERROR: No .tcd found after extracting harmonics archive" | |
| find . -maxdepth 3 -type f | head -n 50 || true | |
| exit 1 | |
| fi | |
| echo "HARM_TCD=$PWD/${TCD_FILE#./}" >> "$GITHUB_ENV" | |
| echo "Using HARM_TCD=$PWD/${TCD_FILE#./}" | |
| - name: Smoke test (Linux, real data + log output) | |
| run: | | |
| set -euo pipefail | |
| echo "=== xtide-nearest --help ===" | |
| ./build/xtide-nearest --help | head -n 60 || true | |
| LAT="40.7050" | |
| LON="-74.0120" | |
| echo "" | |
| echo "=== Nearest TIDE station (lat=${LAT}, lon=${LON}) ===" | |
| ./build/xtide-nearest --lat "${LAT}" --lon "${LON}" --tcd "${{ env.HARM_TCD }}" \ | |
| nearest --no-current --top 1 | |
| echo "" | |
| echo "=== Nearest CURRENT station (lat=${LAT}, lon=${LON}) ===" | |
| ./build/xtide-nearest --lat "${LAT}" --lon "${LON}" --tcd "${{ env.HARM_TCD }}" \ | |
| nearest --no-tide --top 1 | |
| - name: Package | |
| run: | | |
| set -euo pipefail | |
| rm -rf dist | |
| mkdir -p dist | |
| cp -f build/xtide-nearest dist/ | |
| [ -f README.md ] && cp -f README.md dist/ || true | |
| [ -f LICENSE ] && cp -f LICENSE dist/ || true | |
| tar -czf xtide-nearest-${{ env.ARTIFACT_TAG }}-linux-amd64.tar.gz -C dist . | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-amd64 | |
| path: xtide-nearest-${{ env.ARTIFACT_TAG }}-linux-amd64.tar.gz | |
| linux-arm64: | |
| name: linux (arm64) | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Compute artifact tag | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| echo "ARTIFACT_TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV" | |
| else | |
| echo "ARTIFACT_TAG=sha-${GITHUB_SHA::7}" >> "$GITHUB_ENV" | |
| fi | |
| - name: Install deps | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| cmake ninja-build pkg-config g++ \ | |
| curl tar xz-utils make | |
| - name: Build + install libtcd (prefix) | |
| run: | | |
| set -euo pipefail | |
| rm -rf _deps && mkdir -p _deps | |
| cd _deps | |
| curl -L --retry 3 --retry-delay 2 -o libtcd.tar.xz "${LIBTCD_URL}" | |
| tar -xf libtcd.tar.xz | |
| LIBTCD_DIR="$(find . -maxdepth 1 -type d -name 'libtcd-*' | head -n1)" | |
| PREFIX="$PWD/libtcd-prefix" | |
| cd "$LIBTCD_DIR" | |
| ./configure --prefix="$PREFIX" | |
| make -j | |
| make install | |
| echo "TCD_PREFIX=$PREFIX" >> "$GITHUB_ENV" | |
| - name: Configure (release) | |
| run: | | |
| cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_PREFIX_PATH="${{ env.TCD_PREFIX }}" | |
| - name: Build | |
| run: | | |
| cmake --build build -j | |
| - name: Download harmonics (.tcd) for smoke test | |
| run: | | |
| set -euo pipefail | |
| rm -rf _deps/harmonics | |
| mkdir -p _deps/harmonics | |
| cd _deps/harmonics | |
| curl -L --retry 3 --retry-delay 2 -o harmonics.tar.xz "${HARMONICS_URL}" | |
| tar -xf harmonics.tar.xz | |
| TCD_FILE="$(find . -type f -name '*.tcd' | head -n1)" | |
| if [ -z "${TCD_FILE}" ]; then | |
| echo "ERROR: No .tcd found after extracting harmonics archive" | |
| find . -maxdepth 3 -type f | head -n 50 || true | |
| exit 1 | |
| fi | |
| echo "HARM_TCD=$PWD/${TCD_FILE#./}" >> "$GITHUB_ENV" | |
| echo "Using HARM_TCD=$PWD/${TCD_FILE#./}" | |
| - name: Smoke test (Linux arm64, real data + log output) | |
| run: | | |
| set -euo pipefail | |
| LAT="40.7050" | |
| LON="-74.0120" | |
| echo "=== Nearest TIDE station (lat=${LAT}, lon=${LON}) ===" | |
| ./build/xtide-nearest --lat "${LAT}" --lon "${LON}" --tcd "${{ env.HARM_TCD }}" \ | |
| nearest --no-current --top 1 | |
| echo "" | |
| echo "=== Nearest CURRENT station (lat=${LAT}, lon=${LON}) ===" | |
| ./build/xtide-nearest --lat "${LAT}" --lon "${LON}" --tcd "${{ env.HARM_TCD }}" \ | |
| nearest --no-tide --top 1 | |
| - name: Package | |
| run: | | |
| set -euo pipefail | |
| rm -rf dist | |
| mkdir -p dist | |
| cp -f build/xtide-nearest dist/ | |
| [ -f README.md ] && cp -f README.md dist/ || true | |
| [ -f LICENSE ] && cp -f LICENSE dist/ || true | |
| tar -czf xtide-nearest-${{ env.ARTIFACT_TAG }}-linux-arm64.tar.gz -C dist . | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-arm64 | |
| path: xtide-nearest-${{ env.ARTIFACT_TAG }}-linux-arm64.tar.gz | |
| windows-x64: | |
| name: windows (x64) | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up MSYS2 (MINGW64) | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| update: true | |
| install: >- | |
| mingw-w64-x86_64-gcc | |
| mingw-w64-x86_64-cmake | |
| mingw-w64-x86_64-ninja | |
| mingw-w64-x86_64-pkgconf | |
| make | |
| curl | |
| tar | |
| unzip | |
| xz | |
| - name: Compute artifact tag | |
| shell: msys2 {0} | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| echo "ARTIFACT_TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV" | |
| else | |
| echo "ARTIFACT_TAG=sha-${GITHUB_SHA::7}" >> "$GITHUB_ENV" | |
| fi | |
| - name: Build + install libtcd (prefix) | |
| shell: msys2 {0} | |
| run: | | |
| set -euo pipefail | |
| rm -rf _deps && mkdir -p _deps | |
| cd _deps | |
| curl -L --retry 3 --retry-delay 2 -o libtcd.tar.xz "${LIBTCD_URL}" | |
| tar -xf libtcd.tar.xz | |
| LIBTCD_DIR="$(find . -maxdepth 1 -type d -name 'libtcd-*' | head -n1)" | |
| PREFIX="$PWD/libtcd-prefix" | |
| cd "$LIBTCD_DIR" | |
| ./configure --prefix="$PREFIX" | |
| make -j | |
| make install | |
| echo "TCD_PREFIX=$PREFIX" >> "$GITHUB_ENV" | |
| - name: Configure (release) | |
| shell: msys2 {0} | |
| run: | | |
| set -euo pipefail | |
| cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_PREFIX_PATH="${{ env.TCD_PREFIX }}" | |
| - name: Build | |
| shell: msys2 {0} | |
| run: | | |
| cmake --build build -j | |
| - name: Download harmonics (.tcd) for smoke test | |
| shell: msys2 {0} | |
| run: | | |
| set -euo pipefail | |
| rm -rf _deps/harmonics | |
| mkdir -p _deps/harmonics | |
| cd _deps/harmonics | |
| curl -L --retry 3 --retry-delay 2 -o harmonics.tar.xz "${HARMONICS_URL}" | |
| # Archive has symlinks; MSYS2 tar may complain. We only need *.tcd. | |
| tar -xf harmonics.tar.xz || true | |
| TCD_FILE="$(find . -type f -name '*.tcd' | head -n1)" | |
| if [ -z "${TCD_FILE}" ]; then | |
| echo "ERROR: No .tcd found after extracting harmonics archive" | |
| find . -maxdepth 4 -type f | head -n 200 || true | |
| exit 1 | |
| fi | |
| echo "HARM_TCD=$PWD/${TCD_FILE#./}" >> "$GITHUB_ENV" | |
| echo "Using HARM_TCD=$PWD/${TCD_FILE#./}" | |
| - name: Download XTide Windows bundle (for tide.exe) | |
| shell: msys2 {0} | |
| run: | | |
| set -euo pipefail | |
| rm -rf _deps/xtide-win | |
| mkdir -p _deps/xtide-win | |
| curl -L --retry 3 --retry-delay 2 -o _deps/xtide-win.zip "${XTIDE_WIN64_ZIP_URL}" | |
| unzip -q _deps/xtide-win.zip -d _deps/xtide-win | |
| # POSIX path (good for copying within MSYS) | |
| TIDE_EXE="$(find _deps/xtide-win -iname 'tide.exe' | head -n1)" | |
| if [ ! -f "$TIDE_EXE" ]; then | |
| echo "ERROR: tide.exe not found inside XTide bundle" | |
| find _deps/xtide-win -maxdepth 4 -type f | head -n 100 || true | |
| exit 1 | |
| fi | |
| # Native Windows path (required for cmd.exe / system() launching) | |
| TIDE_EXE_WIN="$(cygpath -w "$TIDE_EXE")" | |
| printf 'TIDE_EXE=%s\n' "$TIDE_EXE" >> "$GITHUB_ENV" | |
| printf 'TIDE_EXE_WIN=%s\n' "$TIDE_EXE_WIN" >> "$GITHUB_ENV" | |
| echo "Using TIDE_EXE=$TIDE_EXE" | |
| echo "Using TIDE_EXE_WIN=$TIDE_EXE_WIN" | |
| - name: Smoke test (Windows, real data + log output + predictions) | |
| shell: msys2 {0} | |
| run: | | |
| set -euo pipefail | |
| LAT="40.7050" | |
| LON="-74.0120" | |
| echo "=== Nearest TIDE station (lat=${LAT}, lon=${LON}) ===" | |
| ./build/xtide-nearest.exe --lat "${LAT}" --lon "${LON}" --tcd "${{ env.HARM_TCD }}" \ | |
| nearest --no-current --top 1 | |
| echo "" | |
| echo "=== Nearest CURRENT station (lat=${LAT}, lon=${LON}) ===" | |
| ./build/xtide-nearest.exe --lat "${LAT}" --lon "${LON}" --tcd "${{ env.HARM_TCD }}" \ | |
| nearest --no-tide --top 1 | |
| # Now test predictions by invoking tide.exe directly (avoid cmd/system() quoting issues inside xtide-nearest). | |
| echo "" | |
| echo "=== tide.exe version ===" | |
| "${{ env.TIDE_EXE }}" --version || true | |
| # Ensure tide.exe can find the harmonics database. | |
| export HFILE_PATH="$(dirname "${{ env.HARM_TCD }}")" | |
| echo "HFILE_PATH=$HFILE_PATH" | |
| # Use a known current station name (matches your earlier log) | |
| STATION='Dimond Reef (depth 11 ft), Upper Bay, New York Harbor, New York Current' | |
| echo "" | |
| echo "=== Predict CURRENT via tide.exe (CSV, head) ===" | |
| "${{ env.TIDE_EXE }}" -l "$STATION" \ | |
| -b "2026-01-22 00:00" \ | |
| -e "2026-01-22 06:00" \ | |
| -m r -f c -s "00:30" -z n -em pSsMm \ | |
| > out.csv | |
| echo "--- out.csv (head) ---" | |
| sed -n '1,12p' out.csv | |
| # Hard assertion: CSV should have at least a header + a few rows. | |
| test "$(wc -l < out.csv)" -ge 5 | |
| - name: Package zip (includes tide.exe) | |
| shell: msys2 {0} | |
| run: | | |
| set -euo pipefail | |
| rm -rf dist xtide-nearest-${{ env.ARTIFACT_TAG }}-windows-x64.zip | |
| mkdir -p dist | |
| cp -f build/xtide-nearest.exe dist/ | |
| cp -f "${{ env.TIDE_EXE }}" dist/tide.exe | |
| [ -f README.md ] && cp -f README.md dist/ || true | |
| [ -f LICENSE ] && cp -f LICENSE dist/ || true | |
| ( cd dist && cmake -E tar cfv ../xtide-nearest-${{ env.ARTIFACT_TAG }}-windows-x64.zip --format=zip . ) | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-x64 | |
| path: xtide-nearest-${{ env.ARTIFACT_TAG }}-windows-x64.zip | |
| publish: | |
| name: publish to GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: [linux-amd64, linux-arm64, windows-x64] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: release-assets | |
| - name: Publish | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| release-assets/linux-amd64/*.tar.gz | |
| release-assets/linux-arm64/*.tar.gz | |
| release-assets/windows-x64/*.zip |