| 1 | name: Java CI
|
|---|
| 2 | env:
|
|---|
| 3 | junit_platform_version: '1.7.0'
|
|---|
| 4 | # ANT_HOME is also our ant version
|
|---|
| 5 | ANT_HOME: 'apache-ant-1.10.9'
|
|---|
| 6 | on:
|
|---|
| 7 | push:
|
|---|
| 8 | branches: [master]
|
|---|
| 9 | pull_request:
|
|---|
| 10 | branches: [master]
|
|---|
| 11 |
|
|---|
| 12 | defaults:
|
|---|
| 13 | run:
|
|---|
| 14 | shell: bash
|
|---|
| 15 |
|
|---|
| 16 | jobs:
|
|---|
| 17 |
|
|---|
| 18 | createrelease:
|
|---|
| 19 | name: Create Release
|
|---|
| 20 | runs-on: ubuntu-latest
|
|---|
| 21 | env:
|
|---|
| 22 | LANG: en_US.UTF-8
|
|---|
| 23 | outputs:
|
|---|
| 24 | upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|---|
| 25 | josm_revision: ${{ steps.create_revision.outputs.josm_revision }}
|
|---|
| 26 | josm_prerelease: ${{ steps.create_revision.outputs.josm_prerelease }}
|
|---|
| 27 | josm_release_tag: ${{ steps.create_revision.outputs.josm_release_tag }}
|
|---|
| 28 | steps:
|
|---|
| 29 | - name: Checkout
|
|---|
| 30 | uses: actions/checkout@v2
|
|---|
| 31 | with:
|
|---|
| 32 | fetch-depth: 256
|
|---|
| 33 |
|
|---|
| 34 | - name: Set revision env variable
|
|---|
| 35 | id: create_revision
|
|---|
| 36 | # grab josm revision from last git-svn-id
|
|---|
| 37 | run: |
|
|---|
| 38 | josm_revision="$(git log -1 --grep 'git-svn-id: https://josm.openstreetmap.de/svn/trunk@' --pretty=format:%B | tail -1 | sed -n 's%git-svn-id: https://josm.openstreetmap.de/svn/trunk@\([0-9]*\) [-0-9a-f]*%\1%p')"
|
|---|
| 39 | if [[ "$josm_revision" == "$(curl --silent https://josm.openstreetmap.de/tested)" ]]; then
|
|---|
| 40 | echo "josm_prerelease=false" >> $GITHUB_ENV
|
|---|
| 41 | echo "::set-output name=josm_prerelease::false"
|
|---|
| 42 | josm_release_tag=$josm_revision-tested
|
|---|
| 43 | else
|
|---|
| 44 | echo "josm_prerelease=true" >> $GITHUB_ENV
|
|---|
| 45 | echo "::set-output name=josm_prerelease::true"
|
|---|
| 46 | josm_release_tag=$josm_revision
|
|---|
| 47 | fi
|
|---|
| 48 | echo "josm_revision=$josm_revision" >> $GITHUB_ENV
|
|---|
| 49 | echo "::set-output name=josm_revision::$josm_revision"
|
|---|
| 50 | echo "josm_release_tag=$josm_release_tag" >> $GITHUB_ENV
|
|---|
| 51 | echo "::set-output name=josm_release_tag::$josm_release_tag"
|
|---|
| 52 |
|
|---|
| 53 | - name: Create release
|
|---|
| 54 | id: create_release
|
|---|
| 55 | uses: actions/create-release@v1
|
|---|
| 56 | env:
|
|---|
| 57 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
|---|
| 58 | with:
|
|---|
| 59 | tag_name: ${{ env.josm_release_tag }}
|
|---|
| 60 | release_name: JOSM.app release ${{ env.josm_release_tag }}
|
|---|
| 61 | body: |
|
|---|
| 62 | JOSM.app release ${{ env.josm_release_tag }}
|
|---|
| 63 | draft: false
|
|---|
| 64 | prerelease: ${{ env.josm_prerelease }}
|
|---|
| 65 |
|
|---|
| 66 | build:
|
|---|
| 67 | needs: createrelease
|
|---|
| 68 | runs-on: ${{ matrix.os }}
|
|---|
| 69 | env:
|
|---|
| 70 | LANG: en_US.UTF-8
|
|---|
| 71 | strategy:
|
|---|
| 72 | fail-fast: false
|
|---|
| 73 | matrix:
|
|---|
| 74 | # test against latest update of each major Java version, as well as specific updates of LTS versions:
|
|---|
| 75 | java: [8, 11, 16, 17-ea]
|
|---|
| 76 | os: [ubuntu-latest, macos-latest, windows-latest]
|
|---|
| 77 | headless: ["true", "false"]
|
|---|
| 78 | exclude:
|
|---|
| 79 | - java: 8
|
|---|
| 80 | os: macos-latest
|
|---|
| 81 | - java: 11
|
|---|
| 82 | os: macos-latest
|
|---|
| 83 | - headless: "false"
|
|---|
| 84 | os: macos-latest
|
|---|
| 85 | - headless: "false"
|
|---|
| 86 | os: windows-latest
|
|---|
| 87 | name: Java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }}
|
|---|
| 88 | steps:
|
|---|
| 89 | - name: Checkout
|
|---|
| 90 | uses: actions/checkout@v2
|
|---|
| 91 | with:
|
|---|
| 92 | fetch-depth: 256
|
|---|
| 93 |
|
|---|
| 94 | - name: Cache
|
|---|
| 95 | uses: actions/cache@v2.0.0
|
|---|
| 96 | with:
|
|---|
| 97 | path: |
|
|---|
| 98 | ~/.ivy2/cache/
|
|---|
| 99 | ~/work/josm/josm/tools/
|
|---|
| 100 | build-tools-cache/
|
|---|
| 101 | key: ${{ runner.os }}-ivy2-${{ hashFiles('ivy.xml') }}
|
|---|
| 102 |
|
|---|
| 103 | - name: Setup java
|
|---|
| 104 | uses: actions/setup-java@v1.4.3
|
|---|
| 105 | with:
|
|---|
| 106 | java-version: ${{ matrix.java }}
|
|---|
| 107 |
|
|---|
| 108 | - name: Install ant ${{ env.ANT_HOME }} and junit ${{ env.junit_platform_version }}
|
|---|
| 109 | run: |
|
|---|
| 110 | mkdir -p build-tools-cache/
|
|---|
| 111 | cd build-tools-cache/
|
|---|
| 112 | if [ ! -f ${{ env.ANT_HOME }}-bin.tar.gz ]; then
|
|---|
| 113 | curl -o ${{ env.ANT_HOME }}-bin.tar.gz https://downloads.apache.org/ant/binaries/${{ env.ANT_HOME }}-bin.tar.gz
|
|---|
| 114 | fi
|
|---|
| 115 | if [ ! -f junit-platform-console-standalone-${{ env.junit_platform_version }}.jar ]; then
|
|---|
| 116 | curl -o junit-platform-console-standalone-${{ env.junit_platform_version }}.jar https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/${{ env.junit_platform_version }}/junit-platform-console-standalone-${{ env.junit_platform_version }}.jar
|
|---|
| 117 | fi
|
|---|
| 118 | cd ..
|
|---|
| 119 | tar zxf build-tools-cache/${{ env.ANT_HOME }}-bin.tar.gz
|
|---|
| 120 | cp build-tools-cache/junit-platform-console-standalone-${{ env.junit_platform_version }}.jar ${{ env.ANT_HOME }}/lib/junit-platform-console-standalone-${{ env.junit_platform_version }}.jar
|
|---|
| 121 |
|
|---|
| 122 | - name: Print ant version, expecting ${{ env.ANT_HOME }}
|
|---|
| 123 | run: ${{ env.ANT_HOME }}/bin/ant -version
|
|---|
| 124 |
|
|---|
| 125 | - name: Optimise images
|
|---|
| 126 | if: ${{ runner.os == 'macos' && always() }}
|
|---|
| 127 | run: |
|
|---|
| 128 | brew install --cask imageoptim
|
|---|
| 129 | defaults write net.pornel.ImageOptim SvgoEnabled 1
|
|---|
| 130 | defaults write net.pornel.ImageOptim PngCrush2Enabled 1
|
|---|
| 131 | defaults write net.pornel.ImageOptim PngOutEnabled 1
|
|---|
| 132 | /Applications/ImageOptim.app/Contents/MacOS/ImageOptim resources/images
|
|---|
| 133 |
|
|---|
| 134 | - name: Build with Ant
|
|---|
| 135 | # Calls ant with -Dreleasebuild=true if we're a 'tested' build
|
|---|
| 136 | run: |
|
|---|
| 137 | if [ "${{ needs.createrelease.outputs.josm_prerelease }}" == "true" ]; then
|
|---|
| 138 | ANT="${{ env.ANT_HOME }}/bin/ant"
|
|---|
| 139 | else
|
|---|
| 140 | ANT="${{ env.ANT_HOME }}/bin/ant -Dreleasebuild=true"
|
|---|
| 141 | fi
|
|---|
| 142 | $ANT dist
|
|---|
| 143 |
|
|---|
| 144 | - name: Upload jar
|
|---|
| 145 | # Only run on matrix.headless to avoid double jars. They should be the same jars.
|
|---|
| 146 | if: ${{ always() && matrix.headless == 'true' }}
|
|---|
| 147 | id: upload-jar
|
|---|
| 148 | env:
|
|---|
| 149 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|---|
| 150 | uses: actions/upload-release-asset@v1
|
|---|
| 151 | with:
|
|---|
| 152 | upload_url: ${{ needs.createrelease.outputs.upload_url }} # This pulls from the CREATE RELEASE job above, referencing its ID to get its outputs object, which include a `upload_url`.
|
|---|
| 153 | asset_path: dist/josm-custom.jar
|
|---|
| 154 | asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
|
|---|
| 155 | asset_content_type: application/java-archive
|
|---|
| 156 |
|
|---|
| 157 | - name: Test with Ant, headless ${{ matrix.headless }}
|
|---|
| 158 | if: ${{ needs.createrelease.outputs.josm_prerelease }}
|
|---|
| 159 | run: |
|
|---|
| 160 | ANT="${{ env.ANT_HOME }}/bin/ant -DnoJavaFX=true test-unit-hardfail"
|
|---|
| 161 | if [ "${{ matrix.headless }}" == "true" ]; then
|
|---|
| 162 | $ANT -Dtest.headless=true
|
|---|
| 163 | else
|
|---|
| 164 | xvfb-run $ANT -Dtest.headless=false
|
|---|
| 165 | fi
|
|---|
| 166 |
|
|---|
| 167 | - name: Dump errors if failed
|
|---|
| 168 | if: ${{ failure() }}
|
|---|
| 169 | run: "grep -L ', Failures: 0, Skipped: ' test/report/*.txt | xargs cat"
|
|---|
| 170 |
|
|---|
| 171 | - name: Upload Ant reports
|
|---|
| 172 | if: ${{ always() }}
|
|---|
| 173 | uses: actions/upload-artifact@v2
|
|---|
| 174 | with:
|
|---|
| 175 | name: Ant reports for JOSM ${{ needs.createrelease.outputs.josm_revision }} on java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }}
|
|---|
| 176 | path: test/report/*.txt
|
|---|
| 177 |
|
|---|
| 178 | - name: Publish Test Report with junit-report-annotations-action
|
|---|
| 179 | uses: ashley-taylor/junit-report-annotations-action@1.3
|
|---|
| 180 | if: always()
|
|---|
| 181 | with:
|
|---|
| 182 | access-token: ${{ secrets.GITHUB_TOKEN }}
|
|---|
| 183 | path: 'test/report/TEST*.xml'
|
|---|
| 184 |
|
|---|
| 185 | - name: Publish Test Report with action-junit-report
|
|---|
| 186 | if: always()
|
|---|
| 187 | uses: mikepenz/action-junit-report@v1
|
|---|
| 188 | with:
|
|---|
| 189 | report_paths: 'test/report/TEST*.xml'
|
|---|
| 190 | github_token: ${{ secrets.GITHUB_TOKEN }}
|
|---|
| 191 |
|
|---|
| 192 | - name: Build and package for macOS
|
|---|
| 193 | if: ${{ runner.os == 'macos' && always() }}
|
|---|
| 194 | env:
|
|---|
| 195 | CERT_MACOS_P12: ${{ secrets.CERT_MACOS_P12 }}
|
|---|
| 196 | CERT_MACOS_PW: ${{ secrets.CERT_MACOS_PW }}
|
|---|
| 197 | APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }}
|
|---|
| 198 | run: |
|
|---|
| 199 | ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
|
|---|
| 200 |
|
|---|
| 201 | - name: Upload app
|
|---|
| 202 | if: ${{ runner.os == 'macos' && always() }}
|
|---|
| 203 | id: upload-app
|
|---|
| 204 | uses: actions/upload-release-asset@v1
|
|---|
| 205 | env:
|
|---|
| 206 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|---|
| 207 | with:
|
|---|
| 208 | upload_url: ${{ needs.createrelease.outputs.upload_url }} # This pulls from the CREATE RELEASE job above, referencing its ID to get its outputs object, which include a `upload_url`.
|
|---|
| 209 | asset_path: app/JOSM.zip
|
|---|
| 210 | asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}.zip
|
|---|
| 211 | asset_content_type: application/zip
|
|---|