Skip to content

Commit

Permalink
Upgrade to latest sbt-web 1.5.x, use sbt-ci-release
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurz committed Jan 10, 2024
1 parent 46e8797 commit a9189f9
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 28 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Check

on:
pull_request:

push:
branches:
- main # Check branch after merge

concurrency:
# Only run once for latest commit per ref and cancel other (previous) runs.
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Tests
uses: playframework/.github/.github/workflows/cmd.yml@v3
with:
java: 17, 11, 8
scala: 2.12.18
cmd: |
sbt ++$MATRIX_SCALA test ^scripted
finish:
name: Finish
if: github.event_name == 'pull_request'
needs: # Should be last
- "tests"
uses: playframework/.github/.github/workflows/rtm.yml@v3
44 changes: 44 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish

on:
push:
branches: # Snapshots
- main
tags: ["**"] # Releases

jobs:
publish-artifacts:
name: JDK 8
runs-on: ubuntu-20.04
if: ${{ github.repository_owner == 'sbt' }}
steps:
- name: Checkout
uses: actions/checkout@v3
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
id: coursier-cache
uses: coursier/cache-action@v6

- name: Install Adoptium Temurin OpenJDK
uses: coursier/setup-action@v1
with:
jvm: adoptium:8

- name: Publish artifacts
run: sbt ci-release
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}

- name: Cleanup before cache
shell: bash
run: |
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ project/plugins/project/
.idea/
.idea_modules/

.bsp/
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ sbt-gzip

[sbt-web] plugin for gzip compressing web assets.

[![Build Status](https://travis-ci.org/sbt/sbt-gzip.png?branch=master)](https://travis-ci.org/sbt/sbt-gzip) [![Download](https://api.bintray.com/packages/sbt-web/sbt-plugin-releases/sbt-gzip/images/download.svg)](https://bintray.com/sbt-web/sbt-plugin-releases/sbt-gzip/_latestVersion)
[![Build Status](https://github.com/sbt/sbt-gzip/actions/workflows/build-test.yml/badge.svg)](https://github.com/sbt/sbt-gzip/actions/workflows/build-test.yml)

Add plugin
----------

Add the plugin to `project/plugins.sbt`. For example:

```scala
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.2")
addSbtPlugin("com.github.sbt" % "sbt-gzip" % "2.0.0")
```

Your project's build file also needs to enable sbt-web plugins. For example with build.sbt:
Expand All @@ -33,36 +33,31 @@ Include and exclude filters can be provided. For example, to only create
gzip files for `.js` files:

```scala
includeFilter in gzip := "*.js"
gzip / includeFilter := "*.js"
```

Or to exclude all `.js` files but include any other files:

```scala
excludeFilter in gzip := "*.js"
gzip / excludeFilter := "*.js"
```

The default filter is to only include `.html`, `.css`, and `.js` files:

```scala
includeFilter in gzip := "*.html" || "*.css" || "*.js"
gzip / includeFilter := "*.html" || "*.css" || "*.js"
```


Contribution policy
-------------------

Contributions via GitHub pull requests are gladly accepted from their original
author. Before we can accept pull requests, you will need to agree to the
[Typesafe Contributor License Agreement][cla] online, using your GitHub account.

Contributions via GitHub pull requests are gladly accepted from their original author.

License
-------

This code is licensed under the [Apache 2.0 License][apache].


[sbt-web]: https://github.com/sbt/sbt-web
[cla]: http://www.typesafe.com/contribute/cla
[apache]: http://www.apache.org/licenses/LICENSE-2.0.html
28 changes: 25 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
organization := "com.typesafe.sbt"
name := "sbt-gzip"
lazy val `sbt-gzip` = project in file(".")

enablePlugins(SbtWebBase)

sonatypeProfileName := "com.github.sbt.sbt-gzip" // See https://issues.sonatype.org/browse/OSSRH-77819#comment-1203625

description := "sbt-web plugin for gzipping assets"
addSbtWeb("1.4.2")

developers += Developer(
"playframework",
"The Play Framework Team",
"[email protected]",
url("https://github.com/playframework")
)

addSbtWeb("1.5.3")

// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
ThisBuild / dynverVTagPrefix := false

// Sanity-check: assert that version comes from a tag (e.g. not a too-shallow clone)
// https://github.com/dwijnand/sbt-dynver/#sanity-checking-the-version
Global / onLoad := (Global / onLoad).value.andThen { s =>
dynverAssertTagVersion.value
s
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.0.1
sbt.version=1.9.8
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-web-build-base" % "1.2.0")
addSbtPlugin("com.github.sbt" % "sbt-web-build-base" % "2.0.2")

addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
14 changes: 7 additions & 7 deletions src/main/scala/com/typesafe/sbt/gzip/SbtGzip.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ object SbtGzip extends AutoPlugin {
import autoImport._

override def projectSettings: Seq[Setting[_]] = Seq(
includeFilter in gzip := "*.html" || "*.css" || "*.js",
excludeFilter in gzip := HiddenFileFilter,
target in gzip := webTarget.value / gzip.key.label,
deduplicators += SbtWeb.selectFileFrom((target in gzip).value),
gzip / includeFilter := "*.html" || "*.css" || "*.js",
gzip / excludeFilter := HiddenFileFilter,
gzip / target := webTarget.value / gzip.key.label,
deduplicators += SbtWeb.selectFileFrom((gzip / target).value),
gzip := gzipFiles.value
)

def gzipFiles: Def.Initialize[Task[Pipeline.Stage]] = Def.task {
val targetDir = (target in gzip).value
val include = (includeFilter in gzip).value
val exclude = (excludeFilter in gzip).value
val targetDir = (gzip / target).value
val include = (gzip / includeFilter).value
val exclude = (gzip / excludeFilter).value
mappings =>
val gzipMappings = for {
(file, path) <- mappings if !file.isDirectory && include.accept(file) && !exclude.accept(file)
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/gzip/compress/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % sys.props("project.version"))
addSbtPlugin("com.github.sbt" % "sbt-gzip" % sys.props("project.version"))
2 changes: 1 addition & 1 deletion src/sbt-test/gzip/exclude/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % sys.props("project.version"))
addSbtPlugin("com.github.sbt" % "sbt-gzip" % sys.props("project.version"))
2 changes: 1 addition & 1 deletion src/sbt-test/gzip/existing/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % sys.props("project.version"))
addSbtPlugin("com.github.sbt" % "sbt-gzip" % sys.props("project.version"))
2 changes: 1 addition & 1 deletion src/sbt-test/gzip/include/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % sys.props("project.version"))
addSbtPlugin("com.github.sbt" % "sbt-gzip" % sys.props("project.version"))
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit a9189f9

Please sign in to comment.