source: josm/trunk/.github/workflows/ant.yml @ 17539

Last change on this file since 17539 was 17539, checked in by Don-vip, 7 months ago

see #19724, see #20522 - upgrade to equalsverifier 3.5.5 - enable Java 16/17 for mac build

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