|
| 1 | +name: CI |
| 2 | + |
| 3 | +env: |
| 4 | + JAVA_OPTS: "-Dfile.encoding=UTF-8 -Xms1024M -Xmx3072M -Xss4M -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler" |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: '*' |
| 9 | + tags: [ "v[0-9]+*" ] |
| 10 | + pull_request: |
| 11 | + # avoid duplicate checks (push & PR) further in the review process |
| 12 | + types: [opened] |
| 13 | + |
| 14 | +jobs: |
| 15 | + test: |
| 16 | + name: Run tests |
| 17 | + runs-on: ubuntu-20.04 # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + scala: [ 2.12.14, 2.13.6 ] |
| 22 | + command: [ test ] |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v2 |
| 25 | + - name: Cache sbt |
| 26 | + uses: actions/cache@v2 |
| 27 | + with: |
| 28 | + path: | |
| 29 | + ~/.sbt |
| 30 | + ~/.ivy2/cache |
| 31 | + ~/.coursier/cache |
| 32 | + ~/.cache/coursier |
| 33 | + key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}-${{ hashFiles('project/Dependencies.scala') }} |
| 34 | + restore-keys: ${{ runner.os }}-sbt- |
| 35 | + - name: Set up JDK 11 |
| 36 | + uses: actions/setup-java@v1 |
| 37 | + with: |
| 38 | + java-version: 11 |
| 39 | + - name: Cache npm |
| 40 | + uses: actions/cache@v2 |
| 41 | + with: |
| 42 | + path: ~/.npm |
| 43 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 44 | + restore-keys: ${{ runner.os }}-node- |
| 45 | + - name: Set up node |
| 46 | + uses: actions/setup-node@v2-beta |
| 47 | + - name: Run tests |
| 48 | + run: sbt "set concurrentRestrictions in Global += Tags.limit(ScalaJSTags.Link, 1)" ++${{ matrix.scala }} ${{ matrix.command }} |
| 49 | + |
| 50 | + publish: |
| 51 | + name: Publish to Sonatype |
| 52 | + # only run on tag push |
| 53 | + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v')) |
| 54 | + needs: [ test ] |
| 55 | + runs-on: ubuntu-20.04 |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v2 |
| 58 | + - name: Cache sbt |
| 59 | + uses: actions/cache@v2 |
| 60 | + with: |
| 61 | + path: | |
| 62 | + ~/.sbt |
| 63 | + ~/.ivy2/cache |
| 64 | + ~/.coursier/cache |
| 65 | + ~/.cache/coursier |
| 66 | + key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}-${{ hashFiles('project/Dependencies.scala') }} |
| 67 | + restore-keys: ${{ runner.os }}-sbt- |
| 68 | + - name: Set up JDK 11 |
| 69 | + uses: actions/setup-java@v1 |
| 70 | + with: |
| 71 | + java-version: 11 |
| 72 | + - name: Get version |
| 73 | + id: get_tag_name |
| 74 | + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} |
| 75 | + - name: Import GPG key |
| 76 | + env: |
| 77 | + #exported via `gpg -a --export-secret-keys <key> | cat -e | sed 's/\$/\\n/g' | xclip -selection clipboard` and added to org secrets |
| 78 | + SONATYPE_GPG: ${{ secrets.SONATYPE_GPG }} |
| 79 | + run: echo -e $SONATYPE_GPG | gpg --import - |
| 80 | + - name: Publish artifacts |
| 81 | + env: |
| 82 | + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
| 83 | + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |
| 84 | + run: sbt 'set version in ThisBuild := "${{ steps.get_tag_name.outputs.VERSION }}"' +publishSigned |
| 85 | + - name: Release Sonatype bundle |
| 86 | + #https://github.com/xerial/sbt-sonatype#publishing-your-artifact |
| 87 | + if: ${{ !endsWith(steps.get_tag_name.outputs.VERSION, 'SNAPSHOT') }} |
| 88 | + env: |
| 89 | + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
| 90 | + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |
| 91 | + run: sbt 'set version in ThisBuild := "${{ steps.get_tag_name.outputs.VERSION }}"' sonatypeBundleRelease |
0 commit comments