-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bleep can now build and publish Bleep! 🎆
- drops sbt build - new publishing scheme for compiled binaries - publish bleep-cli to maven so coursier can provide a slow version for non-common platforms - propagate cwd to scripts
- Loading branch information
1 parent
9e900b4
commit 920e36f
Showing
13 changed files
with
197 additions
and
291 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
#!/bin/bash | ||
mkdir -p work/release | ||
chmod 755 artifacts/linux-binary/bleep-linux | ||
chmod 755 artifacts/macos-binary/bleep-macos | ||
|
||
mv artifacts/linux-binary/bleep-linux "work/release/bleep-$VERSION-x86-64-pc-linux" | ||
mv artifacts/macos-binary/bleep-macos "work/release/bleep-$VERSION-x86-64-apple-darwin" | ||
mv artifacts/windows-binary/bleep-windows.exe artifacts/windows-binary/bleep.exe | ||
set -e | ||
|
||
mkdir -p work/release | ||
|
||
gzip "work/release/bleep-$VERSION-x86-64-pc-linux" | ||
gzip "work/release/bleep-$VERSION-x86-64-apple-darwin" | ||
CWD=$(pwd -P) | ||
(cd artifacts/windows-binary && zip -r "$CWD/work/release/bleep-$VERSION-x86-64-pc-win32.zip" *.exe) | ||
|
||
chmod +x artifacts/bleep-x86_64-pc-linux/bleep | ||
(cd artifacts/bleep-x86_64-pc-linux && tar cvfz "$CWD/work/release/bleep-x86_64-pc-linux.tar.gz" bleep) | ||
|
||
chmod +x artifacts/bleep-x86_64-apple-darwin/bleep | ||
(cd artifacts/bleep-x86_64-apple-darwin && tar cvfz "$CWD/work/release/bleep-x86_64-apple-darwin.tar.gz" bleep) | ||
|
||
(cd artifacts/bleep-x86_64-pc-win32 && zip -r "$CWD/work/release/bleep-x86_64-pc-win32.zip" bleep.exe) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,122 +15,98 @@ jobs: | |
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- uses: graalvm/setup-graalvm@v1 | ||
with: | ||
version: '22.1.0' | ||
java-version: '17' | ||
components: 'native-image' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: coursier/setup-action@v1 | ||
- uses: coursier/[email protected] | ||
with: | ||
apps: sbt | ||
extraFiles: bleep.yaml | ||
apps: scalafmt | ||
- uses: coursier/cache-action@v6 | ||
|
||
- name: Scalafmt Check | ||
if: ${{ matrix.os != 'windows-latest' }} | ||
shell: bash | ||
run: sbt --client scalafmtCheckAll | ||
- name: "Test" | ||
shell: bash | ||
run: sbt --client "test" | ||
- name: "Assembly" | ||
shell: bash | ||
run: sbt --client "bleep-cli/assembly" | ||
- name: Temporarily save package | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: java-binary | ||
path: | | ||
${{ github.workspace }}/bleep-cli/target/jvm-2.13/bleep-cli-assembly.jar | ||
retention-days: 1 | ||
- name: Cleanup before cache | ||
shell: bash | ||
run: scalafmt -c .scalafmt.conf --check | ||
|
||
- name: Install bleep stable | ||
run: cs install --channel channel bleep:0.0.1-M7 --verbose | ||
|
||
- name: Run tests | ||
run: | | ||
rm -rf "$HOME/.ivy2/local" || true | ||
find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true | ||
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true | ||
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true | ||
find $HOME/.sbt -name "*.lock" -delete || true | ||
bleep generate-resources | ||
bleep test | ||
build-native-image: | ||
name: Native image build on ${{ matrix.os }} | ||
needs: [ build ] | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 20 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
file_name: bleep-linux | ||
artifact_name: linux-binary | ||
file_name: bleep | ||
artifact_name: bleep-x86_64-pc-linux | ||
- os: macos-latest | ||
file_name: bleep-macos | ||
artifact_name: macos-binary | ||
file_name: bleep | ||
artifact_name: bleep-x86_64-apple-darwin | ||
- os: windows-latest | ||
file_name: bleep-windows | ||
artifact_name: windows-binary | ||
file_name: bleep.exe | ||
artifact_name: bleep-x86_64-pc-win32 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- name: Download application package | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: java-binary | ||
- uses: graalvm/setup-graalvm@v1 | ||
with: | ||
version: '22.1.0' | ||
java-version: '17' | ||
components: 'native-image' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: coursier/[email protected] | ||
- uses: coursier/cache-action@v6 | ||
with: | ||
extraFiles: bleep.yaml | ||
|
||
- name: Build native image on Linux | ||
run: mkdir dist && native-image --enable-url-protocols=https -jar bleep-*.jar dist/${{ matrix.file_name }} && chmod 755 dist/${{ matrix.file_name }} | ||
if: runner.os == 'Linux' | ||
- name: Install bleep stable | ||
run: cs install --channel channel bleep:0.0.1-M7 --verbose | ||
|
||
- name: Build native image on Mac OS X | ||
run: mkdir dist && native-image --enable-url-protocols=https -jar bleep-*.jar dist/${{ matrix.file_name }} && chmod 755 dist/${{ matrix.file_name }} | ||
if: runner.os == 'macOS' | ||
- name: Build native image (non-windows) | ||
run: | | ||
bleep generate-resources | ||
bleep native-image ${{ matrix.file_name }} | ||
if: runner.os != 'Windows' | ||
|
||
- name: Build native image on Windows | ||
run: >- | ||
mkdir dist && "C:\Program Files (x86)\Microsoft Visual | ||
Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && native-image --native-image-info --verbose --enable-url-protocols=https -jar bleep-*.jar dist/${{ matrix.file_name }} | ||
if: runner.os == 'Windows' | ||
- name: Test binary after build (non-windows) | ||
run: ./${{ matrix.file_name }} --ignore-version-in-build-file test --no-color jvm213 | ||
if: runner.os != 'Windows' | ||
|
||
- name: Test binary after build on Windows | ||
- name: generate resources (windows) | ||
# note: yaml multiline syntax doesn't seem to work (cmd only runs first command). | ||
# that's why this is split in generate resources and build native image below | ||
run: bleep generate-resources | ||
# shell is important here. default is powershell and things do not work there | ||
# see https://github.com/dirs-dev/directories-jvm/issues/49 | ||
shell: cmd | ||
run: | | ||
.\dist\${{ matrix.file_name }}.exe --ignore-version-in-build-file generate-resources | ||
.\dist\${{ matrix.file_name }}.exe --ignore-version-in-build-file compile --no-color jvm213 | ||
if: runner.os == 'Windows' | ||
|
||
- name: Test binary after build on Linux | ||
run: | | ||
chmod 755 dist/${{ matrix.file_name }} | ||
./dist/${{ matrix.file_name }} --ignore-version-in-build-file generate-resources | ||
./dist/${{ matrix.file_name }} --ignore-version-in-build-file compile --no-color jvm213 | ||
if: runner.os == 'Linux' | ||
- name: Build native image (windows) | ||
run: bleep native-image ${{ matrix.file_name }} | ||
shell: cmd | ||
if: runner.os == 'Windows' | ||
|
||
- name: Test binary after build on Macos | ||
run: | | ||
chmod 755 dist/${{ matrix.file_name }} | ||
./dist/${{ matrix.file_name }} --ignore-version-in-build-file generate-resources | ||
./dist/${{ matrix.file_name }} --ignore-version-in-build-file compile --no-color jvm213 | ||
if: runner.os == 'macOS' | ||
- name: Test binary after build (windows) | ||
shell: cmd | ||
# todo: fix tests on windows | ||
run: .\${{ matrix.file_name }} --ignore-version-in-build-file compile --no-color jvm213 | ||
if: runner.os == 'Windows' | ||
|
||
- name: Temporarily save package | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ matrix.artifact_name }} | ||
path: | | ||
dist/bleep-* | ||
path: ${{ matrix.file_name }} | ||
retention-days: 1 | ||
|
||
release: | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
needs: [ build-native-image ] | ||
needs: [ build, build-native-image ] | ||
if: "startsWith(github.ref, 'refs/tags/v')" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
@@ -144,20 +120,12 @@ jobs: | |
path: artifacts | ||
- name: Display structure of downloaded files | ||
run: find artifacts | ||
- uses: graalvm/setup-graalvm@v1 | ||
with: | ||
version: '22.1.0' | ||
java-version: '17' | ||
components: 'native-image' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Release | ||
run: | | ||
chmod +x ./artifacts/linux-binary/bleep-linux | ||
./artifacts/linux-binary/bleep-linux generate-resources | ||
./artifacts/linux-binary/bleep-linux publish | ||
chmod +x ./artifacts/bleep-x86_64-pc-linux/bleep | ||
./artifacts/bleep-x86_64-pc-linux/bleep generate-resources | ||
./artifacts/bleep-x86_64-pc-linux/bleep publish | ||
env: | ||
CI_RELEASE: ${{ secrets.CI_RELEASE }} | ||
CI_SNAPSHOT_RELEASE: ${{ secrets.CI_SNAPSHOT_RELEASE }} | ||
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} | ||
PGP_SECRET: ${{ secrets.PGP_SECRET }} | ||
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | ||
|
This file contains 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
This file contains 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
91 changes: 67 additions & 24 deletions
91
bleep-cli/src/main/scala/bleep/internal/FetchBleepRelease.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,92 @@ | ||
package bleep.internal | ||
package bleep | ||
package internal | ||
|
||
import bleep.logging.Logger | ||
import bleep.{model, BuildException} | ||
import coursier.cache.{ArchiveCache, FileCache} | ||
import coursier.cache.{ArchiveCache, ArtifactError, FileCache} | ||
import coursier.jvm.JvmIndex | ||
import coursier.util.{Artifact, Task} | ||
|
||
import java.io.File | ||
import java.nio.file.Path | ||
import scala.concurrent.duration.Duration | ||
import scala.concurrent.{Await, ExecutionContext} | ||
import scala.concurrent.{Await, ExecutionContext, Future} | ||
|
||
object FetchBleepRelease { | ||
def apply(wanted: model.Version, logger: Logger, executionContext: ExecutionContext): Either[BuildException, Path] = { | ||
// file names were changed in 0.0.1-M8 | ||
val oldLayouts: Set[model.Version] = Range.inclusive(1, 7).toSet.map((n: Int) => model.Version(s"0.0.1-M$n")) | ||
|
||
def findExecutable(file: File): Either[String, File] = | ||
if (file.isDirectory) { | ||
file.list().toList match { | ||
case Nil => Left(s"no files found in directory $file") | ||
case List(one) => findExecutable(new File(file, one)) | ||
case more => Left(s"expected one file inside $file, got ${more.mkString(", ")}") | ||
} | ||
} else Right(file) | ||
|
||
def apply(wanted: model.Version, logger: Logger, executionContext: ExecutionContext): Either[BuildException, Path] = | ||
apply(wanted, logger, executionContext, JvmIndex.currentArchitecture, JvmIndex.currentOs) | ||
|
||
def apply( | ||
wanted: model.Version, | ||
logger: Logger, | ||
executionContext: ExecutionContext, | ||
arch: Either[String, String], | ||
os: Either[String, String] | ||
): Either[BuildException, Path] = { | ||
val base = s"https://github.com/oyvindberg/bleep/releases/download/v${wanted.value}" | ||
|
||
val isOldLayout = oldLayouts(wanted) | ||
|
||
val maybeUrl: Either[String, String] = | ||
(JvmIndex.currentArchitecture, JvmIndex.currentOs) match { | ||
case (Right("amd64"), Right("darwin")) => Right(s"$base/bleep-${wanted.value}-x86-64-apple-darwin.gz") | ||
case (Right("amd64"), Right("linux")) => Right(s"$base/bleep-${wanted.value}-x86-64-pc-linux.gz") | ||
case (Right("amd64"), Right("windows")) => Right(s"$base/bleep-${wanted.value}-x86-64-pc-win32.zip") | ||
case (Right(arch), Right(os)) => Left(s"Unsupported combination of architecture $arch and os $os") | ||
case (Left(unsupported), _) => Left(unsupported) | ||
case (_, Left(unsupported)) => Left(unsupported) | ||
(arch, os) match { | ||
case (Right("amd64"), Right("darwin")) if isOldLayout => Right(s"$base/bleep-${wanted.value}-x86-64-apple-darwin.gz") | ||
case (Right("amd64"), Right("linux")) if isOldLayout => Right(s"$base/bleep-${wanted.value}-x86-64-pc-linux.gz") | ||
case (Right("amd64"), Right("windows")) if isOldLayout => Right(s"$base/bleep-${wanted.value}-x86-64-pc-win32.zip") | ||
case (Right("amd64"), Right("darwin")) => Right(s"$base/bleep-x86_64-apple-darwin.tar.gz") | ||
case (Right("amd64"), Right("linux")) => Right(s"$base/bleep-x86_64-pc-linux.tar.gz") | ||
case (Right("amd64"), Right("windows")) => Right(s"$base/bleep-x86_64-pc-win32.zip") | ||
case (Right(arch), Right(os)) => Left(s"Unsupported combination of architecture $arch and os $os") | ||
case (Left(unsupported), _) => Left(unsupported) | ||
case (_, Left(unsupported)) => Left(unsupported) | ||
} | ||
|
||
maybeUrl match { | ||
case Left(msg) => Left(new BuildException.Text(msg)) | ||
case Right(uri) => | ||
Await.result( | ||
ArchiveCache[Task]() | ||
.withCache(FileCache().withLogger(new CoursierLogger(logger))) | ||
.get(Artifact(uri)) | ||
.value(executionContext), | ||
Duration.Inf | ||
) match { | ||
val fetching: Future[Either[ArtifactError, File]] = ArchiveCache[Task]() | ||
.withCache(FileCache().withLogger(new CoursierLogger(logger))) | ||
.get(Artifact(uri)) | ||
.value(executionContext) | ||
|
||
Await.result(fetching, Duration.Inf) match { | ||
case Left(artifactError) => | ||
Left(new BuildException.ArtifactResolveError(artifactError, s"bleep version ${wanted.value}")) | ||
case Right(file) => | ||
JvmIndex.currentOs match { | ||
case Right("darwin" | "linux") => | ||
file.setExecutable(true) | ||
case _ => () | ||
findExecutable(file) match { | ||
case Left(msg) => | ||
Left(new BuildException.Text(msg)) | ||
case Right(executable) => | ||
JvmIndex.currentOs match { | ||
case Right("darwin" | "linux") => | ||
file.setExecutable(true) | ||
case _ => () | ||
} | ||
Right(executable.toPath) | ||
} | ||
Right(file.toPath) | ||
} | ||
} | ||
} | ||
} | ||
|
||
object Tester { | ||
def main(args: Array[String]): Unit = println( | ||
FetchBleepRelease( | ||
model.Version("0.0.1-IM8"), | ||
bleep.logging.stdout(LogPatterns.logFile).untyped, | ||
ExecutionContext.global, | ||
Right("amd64"), | ||
Right("linux") | ||
) | ||
) | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.