Skip to content

Commit

Permalink
refactor: Copy binary using sbt to main dir
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Jan 27, 2025
1 parent e0f15b9 commit ceaffc4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ jobs:
fail-fast: false
matrix:
deploy: [
{ os : macOS-13, name: scalafmt-x86_64-apple-darwin, path: "scalafmt-cli/native/target/scala-2.13/scalafmt-cli"},
{ os : macOS-14, name: scalafmt-aarch64-apple-darwin, path: "scalafmt-cli/native/target/scala-2.13/scalafmt-cli"},
{ os : ubuntu-latest, name: scalafmt-x86_64-pc-linux, path: "scalafmt-cli/native/target/scala-2.13/scalafmt-cli"},
{ os : ubuntu-24.04-arm, name: scalafmt-aarch64-pc-linux, path: "scalafmt-cli/native/target/scala-2.13/scalafmt-cli"},
{ os : windows-latest, name: scalafmt-x86_64-pc-win32, path: "scalafmt-cli/native/target/scala-2.13/scalafmt-cli.exe"}
{ os : macOS-13, name: scalafmt-x86_64-apple-darwin},
{ os : macOS-14, name: scalafmt-aarch64-apple-darwin},
{ os : ubuntu-latest, name: scalafmt-x86_64-pc-linux},
{ os : ubuntu-24.04-arm, name: scalafmt-aarch64-pc-linux},
{ os : windows-latest, name: scalafmt-x86_64-pc-win32}
]
runs-on: ${{ matrix.deploy.os }}
steps:
Expand All @@ -112,7 +112,7 @@ jobs:
- uses: actions/upload-artifact@master
with:
name: ${{ matrix.deploy.name }}
path: ${{ matrix.deploy.path }}
path: ${{ (startsWith(matrix.deploy.os, 'windows') && 'scalafmt.exe') || 'scalafmt' }}
- name: Upload release
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1.0.2
Expand Down
2 changes: 0 additions & 2 deletions bin/build-native-image.sh

This file was deleted.

15 changes: 14 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _root_.scala.util.Properties
import scala.scalanative.build._

import Dependencies._
Expand Down Expand Up @@ -40,7 +41,19 @@ inThisBuild {
name := "scalafmtRoot"
publish / skip := true

addCommandAlias("scala-native", "cliNative/compile;cliNative/nativeLink")
lazy val copyScalaNative = taskKey[Unit]("Copy Scala Native output to root")

copyScalaNative := {
val binaryVersion = (cli.native / scalaBinaryVersion).value
val suffix =
if (Properties.isWin) ".exe"
else ""
val nativeOutput = (cli.native / Compile / target).value / s"scala-$binaryVersion" / s"scalafmt-cli$suffix"
val output = baseDirectory.value / s"scalafmt$suffix"
IO.copyFile(nativeOutput, output)
}

addCommandAlias("scala-native", "cliNative/compile;cliNative/nativeLink;copyScalaNative")

commands ++= Seq(
Command.command("ci-test-jvm") { s =>
Expand Down
Binary file modified scalafmt
Binary file not shown.

0 comments on commit ceaffc4

Please sign in to comment.