# Cross-compiles reqlite for Windows (x86_64-pc-windows-gnu, MinGW-w64) on the # standard Ubuntu runner and uploads a portable zip with both binaries. name: windows on: push: branches: [main] tags: ["v*"] pull_request: workflow_dispatch: env: CARGO_TERM_COLOR: always TARGET: x86_64-pc-windows-gnu # Link the MinGW C runtime pieces statically so the .exe files need no DLLs. CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS: -C target-feature=+crt-static jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install MinGW-w64 and zip run: | sudo apt-get update sudo apt-get install -y --no-install-recommends gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 zip - name: Install Rust (version from rust-toolchain.toml) run: | if ! command -v rustup >/dev/null; then curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" export PATH="$HOME/.cargo/bin:$PATH" fi rustup show active-toolchain || rustup toolchain install rustup target add "$TARGET" - uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git target key: windows-gnu-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock') }} restore-keys: windows-gnu- - name: Build run: cargo build --release --locked --target "$TARGET" -p reqlite-app -p reqlite-cli - name: Package id: package run: | version=$(cargo pkgid -p reqlite-app | sed 's/.*[#@]//') name="reqlite-${version}-windows-x86_64" dir="target/dist/${name}" rm -rf "$dir" && mkdir -p "$dir" cp "target/$TARGET/release/reqlite-gui.exe" "target/$TARGET/release/reqlite.exe" README.md "$dir/" (cd target/dist && rm -f "${name}.zip" && zip -r9 "${name}.zip" "$name") echo "name=${name}" >> "$GITHUB_OUTPUT" echo "version=${version}" >> "$GITHUB_OUTPUT" - uses: actions/upload-artifact@v3 with: name: ${{ steps.package.outputs.name }} path: target/dist/${{ steps.package.outputs.name }}.zip - name: Check tag matches crate version if: startsWith(github.ref, 'refs/tags/v') run: | if [ "${GITHUB_REF_NAME}" != "v${{ steps.package.outputs.version }}" ]; then echo "Tag ${GITHUB_REF_NAME} does not match crate version v${{ steps.package.outputs.version }}" >&2 exit 1 fi - name: Publish release if: startsWith(github.ref, 'refs/tags/v') uses: https://gitea.com/actions/gitea-release-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} name: ${{ github.ref_name }} files: target/dist/${{ steps.package.outputs.name }}.zip sha256sum: true