|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + tags: |
| 7 | + - '*' |
| 8 | + pull_request: |
| 9 | + branches: [ master ] |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + |
| 16 | + - name: Git checkout |
| 17 | + uses: actions/checkout@v2 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Setup Node.js |
| 22 | + uses: actions/setup-node@v2 |
| 23 | + with: |
| 24 | + node-version: '12' |
| 25 | + |
| 26 | + - name: Set up JDK 8 |
| 27 | + uses: actions/setup-java@v2 |
| 28 | + with: |
| 29 | + java-version: '8' |
| 30 | + distribution: 'adopt' |
| 31 | + |
| 32 | + - name: Cache sbt |
| 33 | + uses: actions/cache@v2 |
| 34 | + with: |
| 35 | + path: | |
| 36 | + ~/.sbt |
| 37 | + ~/.ivy2/cache |
| 38 | + ~/.coursier/cache/v1 |
| 39 | + ~/.cache/coursier/v1 |
| 40 | + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt', 'project/**/*.scala') }} |
| 41 | + |
| 42 | + - name: Cache node_modules |
| 43 | + uses: actions/cache@v2 |
| 44 | + with: |
| 45 | + path: | |
| 46 | + ~/.npm |
| 47 | + ~/.nvm |
| 48 | + ~/work/scommons-react/scommons-react/core/target/scala-2.13/scalajs-bundler/test/node_modules |
| 49 | + ~/work/scommons-react/scommons-react/core/target/scala-2.13/scalajs-bundler/test/package-lock.json |
| 50 | + ~/work/scommons-react/scommons-react/dom/target/scala-2.13/scalajs-bundler/test/node_modules |
| 51 | + ~/work/scommons-react/scommons-react/dom/target/scala-2.13/scalajs-bundler/test/package-lock.json |
| 52 | + ~/work/scommons-react/scommons-react/redux/target/scala-2.13/scalajs-bundler/test/node_modules |
| 53 | + ~/work/scommons-react/scommons-react/redux/target/scala-2.13/scalajs-bundler/test/package-lock.json |
| 54 | + ~/work/scommons-react/scommons-react/showcase/target/scala-2.13/scalajs-bundler/test/node_modules |
| 55 | + ~/work/scommons-react/scommons-react/showcase/target/scala-2.13/scalajs-bundler/test/package-lock.json |
| 56 | + ~/work/scommons-react/scommons-react/test/target/scala-2.13/scalajs-bundler/test/node_modules |
| 57 | + ~/work/scommons-react/scommons-react/test/target/scala-2.13/scalajs-bundler/test/package-lock.json |
| 58 | + ~/work/scommons-react/scommons-react/test-dom/target/scala-2.13/scalajs-bundler/test/node_modules |
| 59 | + ~/work/scommons-react/scommons-react/test-dom/target/scala-2.13/scalajs-bundler/test/package-lock.json |
| 60 | + key: ${{ runner.os }}-node_modules-cache-v2-${{ hashFiles('**/package-lock.json') }} |
| 61 | + restore-keys: | |
| 62 | + ${{ runner.os }}-node_modules-cache-v2- |
| 63 | +
|
| 64 | + - name: Extract Tag Name |
| 65 | + run: echo "TAG_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV |
| 66 | + if: ${{ startsWith(github.ref, 'refs/tags') }} |
| 67 | + |
| 68 | + - name: Run tests |
| 69 | + run: | |
| 70 | + sbt coverage test |
| 71 | + sbt coverageAggregate coveralls |
| 72 | + if: ${{ env.TAG_NAME == '' }} |
| 73 | + env: |
| 74 | + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} |
| 75 | + |
| 76 | + - name: Publish SNAPSHOT |
| 77 | + run: sbt clean publish |
| 78 | + if: ${{ !github.event.pull_request && env.TAG_NAME == '' }} |
| 79 | + env: |
| 80 | + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
| 81 | + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |
| 82 | + |
| 83 | + - name: Publish RELEASE |
| 84 | + run: | |
| 85 | + mkdir ./keys |
| 86 | + echo $PGP_PUBLIC | base64 --decode > ./keys/pubring.gpg |
| 87 | + echo $PGP_SECRET | base64 --decode > ./keys/secring.gpg |
| 88 | + VERSION="$(echo "$TAG_NAME" | cut -d'v' -f 2)" |
| 89 | + echo "Publish a release version=$VERSION for tag $TAG_NAME" |
| 90 | + version=$VERSION sbt clean publishSigned sonatypeBundleRelease |
| 91 | + if: ${{ env.TAG_NAME != '' }} |
| 92 | + env: |
| 93 | + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
| 94 | + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |
| 95 | + PGP_PUBLIC: ${{ secrets.PGP_PUBLIC }} |
| 96 | + PGP_SECRET: ${{ secrets.PGP_SECRET }} |
| 97 | + PGP_PASS: ${{ secrets.PGP_PASS }} |
0 commit comments