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

fix macOS build for x64 and arm64 #356

Merged
merged 21 commits into from
Jun 17, 2024
Merged
36 changes: 28 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ jobs:
with:
paths_ignore: '["docs/**", "*.md"]'

build-linux:
build-linux-x64:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')

name: Linux x86_64
runs-on: ubuntu-latest

steps:
Expand All @@ -32,25 +33,30 @@ jobs:

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

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

- name: Build
run: RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-unknown-linux-gnu --all --release && ls target && mv target/x86_64-unknown-linux-gnu/release/squawk target/release/squawk-linux-x86_64
run: cargo build --target x86_64-unknown-linux-gnu --release && mv target/x86_64-unknown-linux-gnu/release/squawk target/release/squawk-linux-x64

- name: Artifact
uses: actions/upload-artifact@v3
with:
name: release
path: target/release/squawk-linux-x86_64
path: target/release/squawk-linux-x64

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

Expand All @@ -61,6 +67,16 @@ jobs:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')

strategy:
fail-fast: false
matrix:
include:
- arch: x64
target: x86_64-apple-darwin
- arch: arm64
target: aarch64-apple-darwin

name: macOS ${{ matrix.arch }}
runs-on: macos-latest

steps:
Expand All @@ -69,31 +85,35 @@ jobs:

- name: Install Toolchain
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
with:
target: ${{ matrix.target }}
profile: minimal
override: true

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

- name: Build for mac
run: cargo build --all --release && mv target/release/squawk target/release/squawk-darwin-x86_64
run: cargo build --release --target=${{ matrix.target }} && mv target/${{ matrix.target }}/release/squawk target/release/squawk-darwin-${{ matrix.arch }}

- name: Artifact
uses: actions/upload-artifact@v3
with:
name: release
path: target/release/squawk-darwin-x86_64
path: target/release/squawk-darwin-${{ matrix.arch }}

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

publish-npm:
if: startsWith(github.ref, 'refs/tags/')
needs: [build-linux, build-mac]
needs: [build-linux-x64, build-mac]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## v1.1.1 - 2024-06-16

### Fixed

- fix build for macos arm64 (#356)

## v1.1.0 - 2024-06-13

### Changed
Expand Down
28 changes: 18 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "squawk"
version = "1.1.0"
version = "1.1.1"
authors = ["Steve Dignam <steve@dignam.xyz>"]
edition = "2018"
license = "GPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
squawk = final.rustPlatform.buildRustPackage {
pname = "squawk";
version = "1.1.0";
version = "1.1.1";

cargoLock = {
lockFile = ./Cargo.lock;
Expand Down
18 changes: 8 additions & 10 deletions js/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,17 @@ 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(["darmin-x64", "darwin-arm64", "linux-x64"])

/**
* @param {string} platform
* @param {string} arch
*/
function getDownloadUrl(platform) {
const releasesUrl = `${RELEASES_BASE_URL}/v${pkgInfo.version}/squawk`
switch (platform) {
case "darwin":
return `${releasesUrl}-darwin-x86_64`
case "linux":
return `${releasesUrl}-linux-x86_64`
default:
return null
function getDownloadUrl(platform, arch) {
if (!SUPPORTED_PLATFORMS.has(`${platform}-${arch}`)) {
return null
}
return `${RELEASES_BASE_URL}/v${pkgInfo.version}/squawk-${platform}-${arch}`
}

function getNpmCache() {
Expand Down Expand Up @@ -107,7 +105,7 @@ function getDecompressor(response) {
function downloadBinary() {
const arch = os.arch()
const platform = os.platform()
const downloadUrl = getDownloadUrl(platform)
const downloadUrl = getDownloadUrl(platform, arch)
if (!downloadUrl) {
return Promise.reject(new Error(`unsupported target ${platform}-${arch}`))
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "squawk-cli",
"version": "1.1.0",
"version": "1.1.1",
"description": "linter for PostgreSQL, focused on migrations",
"repository": "git@github.com:sbdchd/squawk.git",
"author": "Steve Dignam <steve@dignam.xyz>",
Expand Down
2 changes: 1 addition & 1 deletion parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["postgres", "sql", "parser"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libpg_query-sys = "0.3.1"
libpg_query-sys = { git = "https://github.com/chdsbd/libpg_query-sys.git", rev = "f4584dcbcb8c1f3bee550477257e84a846fdd92d" }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_repr = "0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Ok(
}),
]),
"version": Number(
150001,
160001,
),
}),
)
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
targets = ["x86_64-unknown-linux-gnu"]
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "aarch64-apple-darwin"]
channel = "1.67.0"
Loading