diff --git a/.github/workflows/binary-check.yml b/.github/workflows/binary-check.yml new file mode 100644 index 0000000..d8b8da7 --- /dev/null +++ b/.github/workflows/binary-check.yml @@ -0,0 +1,31 @@ +name: Validate Binary Compatibility + +on: + workflow_call: + inputs: + java: + type: string + required: false + default: 8 + +jobs: + cmd: + name: JDK ${{ inputs.java }} + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves + fetch-depth: 0 + + - name: Coursier Cache + uses: coursier/cache-action@v6.3 + + - name: Install AdoptOpenJDK + uses: coursier/setup-action@v1.1.2 + with: + jvm: adopt:${{ inputs.java }} + + - name: Binary Compatibility + run: sbt +mimaReportBinaryIssues diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..9edaa36 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,45 @@ +name: Publish + +on: + workflow_call: + inputs: + java: + type: string + required: false + default: 8 + secrets: + username: + required: true + password: + required: true + pgp_passphrase: + required: true + pgp_secret: + required: true + +jobs: + cmd: + name: JDK ${{ inputs.java }} + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves + fetch-depth: 0 + + - name: Coursier Cache + uses: coursier/cache-action@v6.3 + + - name: Install AdoptOpenJDK + uses: coursier/setup-action@v1.1.2 + with: + jvm: adopt:${{ inputs.java }} + + - name: Publish artifcats + run: sbt ci-release + env: + SONATYPE_USERNAME: ${{ secrets.username }} + SONATYPE_PASSWORD: ${{ secrets.password }} + PGP_PASSPHRASE: ${{ secrets.pgp_passphrase }} + PGP_SECRET: ${{ secrets.pgp_secret }} diff --git a/.github/workflows/sbt-matrix.yml b/.github/workflows/sbt-matrix.yml new file mode 100644 index 0000000..4866fde --- /dev/null +++ b/.github/workflows/sbt-matrix.yml @@ -0,0 +1,43 @@ +name: SBT command on matrix Java/Scala versions + +on: + workflow_call: + inputs: + java: + type: string + required: true + scala: + type: string + required: true + cmd: + type: string + required: true + +jobs: + cmd: + name: Scala ${{ matrix.scala }} & JDK ${{ matrix.java }} + runs-on: ubuntu-20.04 + strategy: + # WA: https://github.community/t/reusable-workflow-with-strategy-matrix/205676/6 + matrix: + java: ${{ fromJson(inputs.java) }} + scala: ${{ fromJson(inputs.scala) }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves + fetch-depth: 0 + + - name: Coursier Cache + uses: coursier/cache-action@v6.3 + + - name: Install AdoptOpenJDK + uses: coursier/setup-action@v1.1.2 + with: + jvm: adopt:${{ matrix.java }} + + - name: Run sbt command + run: ${{ inputs.cmd }} + env: + SCALA_VERSION: ${{ matrix.scala }} diff --git a/.github/workflows/sbt.yml b/.github/workflows/sbt.yml new file mode 100644 index 0000000..1c4789a --- /dev/null +++ b/.github/workflows/sbt.yml @@ -0,0 +1,49 @@ +name: SBT command on single Java verion + +on: + workflow_call: + inputs: + java: + type: string + required: false + default: 8 + cmd: + required: true + type: string + cache-key: + type: string + required: false + default: "" + cache-path: + type: string + required: false + default: "" + +jobs: + cmd: + name: JDK ${{ inputs.java }} + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves + fetch-depth: 0 + + - name: Coursier Cache + uses: coursier/cache-action@v6.3 + + - name: Custom Cache + uses: actions/cache@v2 + if: ${{ inputs.cache-key != '' && inputs.cache-path != '' }} + with: + key: ${{ inputs.cache-key }} + path: ${{ inputs.cache-path }} + + - name: Install AdoptOpenJDK + uses: coursier/setup-action@v1.1.2 + with: + jvm: adopt:${{ inputs.java }} + + - name: Run sbt command + run: ${{ inputs.cmd }} diff --git a/README.md b/README.md index a46ae92..cbb4c9c 100644 --- a/README.md +++ b/README.md @@ -1 +1,142 @@ -# .github \ No newline at end of file +# Playframework GitHub integration + +This repository contains a few configurations of GitHub features. For example a [Reusing workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows) or +[Starter workflows](https://docs.github.com/en/actions/using-workflows/creating-starter-workflows-for-your-organization) as [GitHub Actions](https://docs.github.com/en/actions) features. + +## GitHub Actions Reusing Workflows + +* [Single SBT task](#single-sbt-task) +* [Java/Scala matrix SBT task](#javascala-matrix-sbt-task) +* [Publishing to Sonatype](#publishing-to-sonatype) +* [Validate Binary Compatibility](#validate-binary-compatibility) + +### Single SBT task + +This workflow is used for running a single SBT task. It can to use for running an any BASH script or command, but we don't recommend doing that. + +**Path**: [`.github/workflows/sbt.yml`](.github/workflows/sbt.yml) + +**Image**: [Ubuntu 20.04](https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-57df66b9fc9ce2947e434b4aa02dbe16f6685e20db0c170917d4a1962a5fe6a9?context=explore) + +**Uses actions**: +* [Coursier/Setup Action](https://github.com/coursier/setup-action) +* [Coursier/Cache Action](https://github.com/coursier/cache-action) + +**Parameters**: + +| Parameter | Since | Required | Default | Description | +|------------|-------|--------------------|---------|----------------------| +| cmd | 1.0.0 | :exclamation: | - | Running command | +| java | 1.0.0 | :heavy_minus_sign: | 8 | _AdoptJDK_ version | +| cache-key | 1.0.0 | :heavy_minus_sign: | '' | Key of custom cache | +| cache-path | 1.0.0 | :heavy_minus_sign: | '' | Path of custom cache | + +**How to use**: + +```yaml +uses: playframework/.github/.github/workflows/sbt.yml@v1 +with: + cmd: sbt test +``` + +### Java/Scala matrix SBT task + +This workflow is used for running an SBT task on matrix of Java/Scala versions. + +**Path**: [`.github/workflows/sbt-matrix.yml`](.github/workflows/sbt-matrix.yml) + +**Image**: [Ubuntu 20.04](https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-57df66b9fc9ce2947e434b4aa02dbe16f6685e20db0c170917d4a1962a5fe6a9?context=explore) + +**Uses actions**: +* [Coursier/Setup Action](https://github.com/coursier/setup-action) +* [Coursier/Cache Action](https://github.com/coursier/cache-action) + +**Parameters**: + +| Parameter | Since | Required | Default | Description | +|-----------|-------|-----------------|---------|--------------------| +| cmd | 1.0.0 | :exclamation: | - | Running command | +| java | 1.0.0 | :exclamation: | - | _AdoptJDK_ version | +| scala | 1.0.0 | :exclamation: | - | _Scala_ version | + +**How to use**: + +```yaml +uses: playframework/.github/.github/workflows/sbt-matrix.yml@v1 +with: + java: >- + [ "11", "8" ] + scala: >- + [ "2.12.15", "2.13.8", "3.0.2" ] + cmd: sbt test +``` + +### Publishing to Sonatype + +This workflow is used for publishing snapshots artifacts to [Sonatype Snapshots](https://oss.sonatype.org/content/repositories/snapshots/com/typesafe/play/) repository or release artifacts to [Maven Central](https://repo1.maven.org/maven2/com/typesafe/play/). + +:warning: For using this workflow project must uses the [CI Release](https://github.com/sbt/sbt-ci-release) plugin. + +**Path**: [`.github/workflows/publish.yml`](.github/workflows/publish.yml) + +**Image**: [Ubuntu 20.04](https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-57df66b9fc9ce2947e434b4aa02dbe16f6685e20db0c170917d4a1962a5fe6a9?context=explore) + +**Uses actions**: +* [Coursier/Setup Action](https://github.com/coursier/setup-action) +* [Coursier/Cache Action](https://github.com/coursier/cache-action) + +**Parameters**: + +| Parameter | Since | Required | Default | Description | +|-----------|-------|--------------------|---------|--------------------| +| java | 1.0.0 | :heavy_minus_sign: | 8 | _AdoptJDK_ version | + +**Secrets**: + +| Secret | Since | Required | Default | Description | +|----------------|-------|-----------------|---------|---------------------------| +| username | 1.0.0 | :exclamation: | - | Sonatype account username | +| password | 1.0.0 | :exclamation: | - | Sonatype account password | +| pgp_passphrase | 1.0.0 | :exclamation: | - | Password for GPG key | +| pgp_secret | 1.0.0 | :exclamation: | - | Base64 of GPG private key | + +**How to use**: + +```yaml +uses: playframework/.github/.github/workflows/publish.yml@v1 +secrets: + username: ${{ secrets.SONATYPE_USERNAME }} + password: ${{ secrets.SONATYPE_PASSWORD }} + pgp_passphrase: ${{ secrets.PGP_PASSPHRASE }} + pgp_secret: ${{ secrets.PGP_SECRET }} +``` + +### Validate Binary Compatibility + +This workflow is used for validate binary compatibility the current version. + +:warning: For using this workflow project must uses the [SBT MiMa](https://github.com/lightbend/mima) plugin. + +**Path**: [`.github/workflows/binary-check.yml`](.github/workflows/binary-check.yml) + +**Image**: [Ubuntu 20.04](https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-57df66b9fc9ce2947e434b4aa02dbe16f6685e20db0c170917d4a1962a5fe6a9?context=explore) + +**Uses actions**: +* [Coursier/Setup Action](https://github.com/coursier/setup-action) +* [Coursier/Cache Action](https://github.com/coursier/cache-action) + +**Parameters**: + +| Parameter | Since | Required | Default | Description | +|-----------|-------|--------------------|---------|--------------------| +| java | 1.0.0 | :heavy_minus_sign: | 8 | _AdoptJDK_ version | + +**How to use**: + +```yaml +uses: playframework/.github/.github/workflows/binary-check.yml@v1 +``` + +## GitHub Actions Starter workflows + +TODO