Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added windows support (#368) #369

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,45 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# windows isn't supported by libpg_query
# https://github.com/lfittl/libpg_query/issues/44
build-windows:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
name: Windows

runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Toolchain
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
with:
toolchain: stable
target: x86_64-pc-windows-msvc
profile: minimal
override: true

- name: Cache
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # pin@v2

- name: Build
run: cargo build --target x86_64-pc-windows-msvc --release && mv target/x86_64-pc-windows-msvc/release/squawk.exe target/release/squawk-windows-x64.exe

- name: Artifact
uses: actions/upload-artifact@v3
with:
name: release
path: target/release/squawk-windows-x64.exe

- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
target/release/squawk-windows-x64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-mac:
needs: pre_job
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- added support windows builds (#368)

## v1.1.2 - 2024-06-26

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Also it seemed like a nice project to spend more time with Rust.

Note: due to `squawk`'s dependency on
[`libpg_query`](https://github.com/lfittl/libpg_query/issues/44), `squawk`
only supports Linux and macOS
supports Linux, macOS and Windows

```shell
npm install -g squawk-cli
Expand Down
13 changes: 11 additions & 2 deletions js/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ const { binaryPath } = require("./helpers")
// e.g.: https://github.com/sbdchd/squawk/releases/download/v0.1.3/squawk-darwin-x86_64
const RELEASES_BASE_URL = "https://github.com/sbdchd/squawk/releases/download"

const SUPPORTED_PLATFORMS = new Set(["darwin-x64", "darwin-arm64", "linux-x64"])
const SUPPORTED_PLATFORMS = new Set([
"darwin-x64",
"darwin-arm64",
"linux-x64",
"win32-x64",
])
const BINARY_NAME_OVERRIDE = new Map([["win32-x64", "squawk-windows-x64.exe"]])

/**
* @param {string} platform
Expand All @@ -56,7 +62,10 @@ function getDownloadUrl(platform, arch) {
if (!SUPPORTED_PLATFORMS.has(`${platform}-${arch}`)) {
return null
}
return `${RELEASES_BASE_URL}/v${pkgInfo.version}/squawk-${platform}-${arch}`
const name =
BINARY_NAME_OVERRIDE.get(`${platform}-${arch}`) ||
`squawk-${platform}-${arch}`
return `${RELEASES_BASE_URL}/v${pkgInfo.version}/${name}`
}

function getNpmCache() {
Expand Down
Loading