-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from hoangmaihuy/universal-packager
feat: Universal packager
- Loading branch information
Showing
27 changed files
with
2,919 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
updates: | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '**' | ||
pull_request: | ||
|
||
# cancel older runs of a pull request; | ||
# this will not cancel anything for normal git pushes | ||
concurrency: | ||
group: cancel-old-pr-runs-${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
|
||
jobs: | ||
build: | ||
name: Build and Test | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest] | ||
java-version: [11] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up JDK ${{ matrix.java-version }} | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ matrix.java-version }} | ||
distribution: temurin | ||
|
||
- name: Check publishing local | ||
run: ./millw -i __.publishLocal $(pwd)/testRepo | ||
|
||
- name: Test | ||
run: ./millw -i -k __.test | ||
|
||
publish: | ||
name: Publish to Maven Central | ||
needs: [build] | ||
if: github.repository == 'hoangmaihuy/mill-universal-packager' && github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
concurrency: publish-{{ github.sha }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 11 | ||
distribution: temurin | ||
|
||
- name: Publish to Maven Central | ||
run: ./millw -i io.kipp.mill.ci.release.ReleaseModule/publishAll | ||
env: | ||
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} | ||
PGP_SECRET: ${{ secrets.PGP_SECRET }} | ||
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | ||
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: ["*"] | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
- run: ./millw -i io.kipp.mill.ci.release.ReleaseModule/publishAll | ||
env: | ||
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} | ||
PGP_SECRET: ${{ secrets.PGP_SECRET }} | ||
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | ||
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.11.6 |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version = "3.7.14" | ||
runner.dialect = scala213 | ||
|
||
project.git = true | ||
style=default | ||
|
||
maxColumn = 120 | ||
|
||
align.preset = some | ||
align.openParenCallSite = false | ||
align.openParenDefnSite = false | ||
|
||
newlines.topLevelStatements = [before,after] | ||
newlines.alwaysBeforeElseAfterCurlyIf = false | ||
newlines.implicitParamListModifierForce = [before] | ||
newlines.penalizeSingleSelectMultiArgList = false | ||
newlines.avoidForSimpleOverflow = [punct] | ||
|
||
verticalMultiline.atDefnSite = true | ||
verticalMultiline.newlineAfterOpenParen = true | ||
danglingParentheses.exclude = [] | ||
|
||
optIn.configStyleArguments = true | ||
|
||
runner.optimizer.forceConfigStyleOnOffset = 70 | ||
runner.optimizer.forceConfigStyleMinArgCount = 3 | ||
|
||
continuationIndent.defnSite = 2 | ||
continuationIndent.callSite = 2 | ||
continuationIndent.ctorSite = 2 | ||
|
||
danglingParentheses.defnSite = true | ||
danglingParentheses.callSite = true |
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,2 +1,49 @@ | ||
# mill-universal-packager | ||
Universal packaging for Mill | ||
|
||
Universal packaging for Java application, ported from [sbt-native-packager](https://github.com/sbt/sbt-native-packager). | ||
|
||
Currently, `mill-universal-packager` only supports universal `zip` archive with Bash start script. | ||
|
||
## Usage | ||
|
||
```scala | ||
// build.sc | ||
import $ivy.`io.github.hoangmaihuy::mill-universal-packager::<latest-version>` | ||
|
||
import io.github.hoangmaihuy.mill.packager.archetypes.JavaAppPackagingModule | ||
|
||
object example extends JavaAppPackagingModule { | ||
override def packageVersion = "0.1.0" | ||
} | ||
``` | ||
|
||
Run `universalPackage` command | ||
|
||
```bash | ||
> mill example.universalPackage | ||
``` | ||
|
||
Zip package will be saved at `universalPackage.dest` in Mill's `out` folder. | ||
|
||
## Configuration | ||
|
||
`mill-universal-packager` configurations are similar to `JavaAppPackaging` and `Universal` plugin keys | ||
from `sbt-native-packager`. | ||
|
||
| Key | Type | Default | Description | | ||
|----------------------|----------------------------|-------------------------------------------|------------------------------------------------------------------------| | ||
| packageVersion | String | | Package version to use in `packageName` | | ||
| packageName | String | `artifactName() + "-" + packageVersion()` | Package file name | | ||
| maintainer | String | | Maintainer name | ||
| executableScriptName | String | `artifactName()` | Executable script file name | | ||
| topLevelDirectory | Option[String] | `None` | Top level directory in archive file | | ||
| universalSources | PathRef | `millSourcePath / "universal"` | Files to be included in archive, for example `.conf`, `.ini` files,... | | ||
| universalMappings | Seq[(os.Path, os.SubPath)] | | A list of mappings from original path to archive path | | ||
|
||
## More information | ||
|
||
This plugin was ported from ported from [sbt-native-packager](https://github.com/sbt/sbt-native-packager). Core functions were copied from `sbt-native-packager` with some modifications to work with Mill. | ||
|
||
## Licenses | ||
|
||
This software is released under the Apache License 2.0. More information in the file LICENSE distributed with this project. |
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import $ivy.`de.tototec::de.tobiasroeser.mill.integrationtest::0.7.1` | ||
import $ivy.`io.chris-kipp::mill-ci-release::0.1.9` | ||
|
||
import mill._ | ||
import mill.scalalib._ | ||
import mill.scalalib.publish._ | ||
import mill.scalalib.api.ZincWorkerUtil.scalaNativeBinaryVersion | ||
|
||
import de.tobiasroeser.mill.integrationtest._ | ||
import io.kipp.mill.ci.release.CiReleaseModule | ||
import io.kipp.mill.ci.release.SonatypeHost | ||
|
||
def millVersionFile = T.source(PathRef(os.pwd / ".mill-version")) | ||
|
||
def millVersion = T { | ||
os.read(millVersionFile().path).trim | ||
} | ||
|
||
object Versions { | ||
lazy val scala = "2.13.12" | ||
} | ||
|
||
object `mill-universal-packager` extends ScalaModule with CiReleaseModule { | ||
|
||
override def scalaVersion = Versions.scala | ||
|
||
override def sonatypeHost = Some(SonatypeHost.s01) | ||
|
||
override def versionScheme: T[Option[VersionScheme]] = T(Option(VersionScheme.EarlySemVer)) | ||
|
||
override def pomSettings = PomSettings( | ||
description = "Universal packaging for Mill", | ||
organization = "io.github.hoangmaihuy", | ||
url = "https://github.com/hoangmaihuy/mill-universal-packager", | ||
licenses = Seq(License.`Apache-2.0`), | ||
versionControl = VersionControl.github(owner = "hoangmaihuy", repo = "mill-universal-packager"), | ||
developers = Seq(Developer("hoangmaihuy", "Hoang Mai", "https://github.com/hoangmaihuy")) | ||
) | ||
|
||
override def artifactName = "mill-universal-packager" | ||
|
||
override def artifactSuffix = | ||
"_mill" + scalaNativeBinaryVersion(millVersion()) + | ||
super.artifactSuffix() | ||
|
||
override def scalacOptions = Seq("-Ywarn-unused", "-deprecation") | ||
|
||
override def compileIvyDeps = super.compileIvyDeps() ++ Agg( | ||
ivy"com.lihaoyi::mill-scalalib:${millVersion()}" | ||
) | ||
} | ||
|
||
object itest extends MillIntegrationTestModule { | ||
|
||
override def millTestVersion = millVersion | ||
|
||
override def pluginsUnderTest = Seq(`mill-universal-packager`) | ||
|
||
def testBase = millSourcePath / "src" | ||
|
||
override def testInvocations = Seq( | ||
PathRef(testBase / "example") -> Seq( | ||
TestInvocation.Targets(Seq("universalPackage")) | ||
) | ||
) | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import $file.plugins | ||
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0` | ||
|
||
import mill._ | ||
import mill.scalalib._ | ||
import de.tobiasroeser.mill.vcs.version.VcsVersion | ||
|
||
import io.github.hoangmaihuy.mill.packager.archetypes._ | ||
|
||
object example extends RootModule with ScalaModule with JavaAppPackagingModule { | ||
|
||
|
||
override def artifactName = "example" | ||
|
||
override def scalaVersion = "3.3.1" | ||
|
||
override def mainClass = Some("MainApp") | ||
|
||
override def packageVersion = VcsVersion.vcsState().format() | ||
|
||
override def ivyDeps = super.ivyDeps() ++ Seq( | ||
ivy"dev.zio::zio:2.0.19" | ||
) | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import zio.* | ||
|
||
object MainApp extends ZIOAppDefault { | ||
|
||
override def run: ZIO[Any & ZIOAppArgs & Scope, Any, Any] = { | ||
ZIO.succeed(println("Hello, World!")) | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import zio.* | ||
|
||
object SecondMainApp extends ZIOAppDefault { | ||
|
||
override def run: ZIO[Any & ZIOAppArgs & Scope, Any, Any] = { | ||
ZIO.succeed(println("Hello, Second World!")) | ||
} | ||
|
||
} |
Oops, something went wrong.