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

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

fix #20009 - Build macOS bundles on Java 15, not 16-ea (yet)

File size: 6.0 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  build:
18    runs-on: ${{ matrix.os }}
19    env:
20      LANG: en_US.UTF-8
21    strategy:
22      fail-fast: false
23      matrix:
24        # test against latest update of each major Java version, as well as specific updates of LTS versions:
25        java: [8, 11, 15, 16-ea]
26        os: [ubuntu-latest, macos-latest, windows-latest]
27        headless: ["true", "false"]
28        exclude:
29          - java: 8
30            os: macos-latest
31          - java: 11
32            os: macos-latest
33          - java: 16-ea
34            os: macos-latest
35          - headless: "false"
36            os: macos-latest
37          - headless: "false"
38            os: windows-latest
39    name: Java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }}
40    steps:
41      - name: Checkout
42        uses: actions/checkout@v2
43        with:
44          fetch-depth: 128
45      - name: Cache
46        uses: actions/cache@v2.0.0
47        with:
48          path:  |
49            ~/.ivy2/cache/
50            ~/work/josm/josm/tools/
51          key: ${{ runner.os }}-ivy2-${{ hashFiles('ivy.xml') }}
52      - name: Setup java
53        uses: actions/setup-java@v1.4.3
54        with:
55          java-version: ${{ matrix.java }}
56      - name: Install ant ${{ env.ANT_HOME }} and junit ${{ env.junit_platform_version }}
57        # Todo: cache ant and junit, saves 12 seconds.
58        run: |
59          curl -s https://downloads.apache.org/ant/binaries/${{ env.ANT_HOME }}-bin.tar.gz | tar -xz
60          curl -o ${{ env.ANT_HOME }}/lib/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"
61      - name: Print ant version, expecting ${{ env.ANT_HOME }}
62        run: ${{ env.ANT_HOME }}/bin/ant -version
63      - name: Set revision env variable
64        run: |
65          ant create-revision
66          josm_revision=`awk '/Revision/{print $2}' resources/REVISION`
67          if [[ "$josm_revision" == `curl --silent https://josm.openstreetmap.de/tested` ]]; then
68            sed -i .bak '/Is-Local-Build/d' resources/REVISION
69            echo "josm_prerelease=false" >> $GITHUB_ENV
70          else
71            echo "josm_prerelease=true" >> $GITHUB_ENV
72          fi
73          echo "josm_revision=$josm_revision" >> $GITHUB_ENV
74      - name: Build with Ant, headless ${{ matrix.headless }}
75        run: |
76          ANT="${{ env.ANT_HOME }}/bin/ant -DnoJavaFX=true test-unit-hardfail"
77          if [ "${{ matrix.headless }}" == "true" ]; then
78            $ANT -Dtest.headless=true
79          else
80            xvfb-run $ANT -Dtest.headless=false
81          fi
82      - name: Dump errors if failed
83        if: ${{ failure() }}
84        run: "grep -L ', Failures: 0, Skipped: ' test/report/*.txt | xargs cat"
85      - name: Upload Ant reports
86        if: ${{ always() }}
87        uses: actions/upload-artifact@v2
88        with:
89          name: Ant reports for JOSM ${{ env.josm_revision }} on java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }}
90          path: test/report/*.txt
91      - name: Optimise images
92        if: ${{ runner.os == 'macos' && always() }}
93        run: |
94          brew cask install imageoptim
95          defaults write net.pornel.ImageOptim SvgoEnabled 1
96          defaults write net.pornel.ImageOptim PngCrush2Enabled 1
97          defaults write net.pornel.ImageOptim PngOutEnabled 1
98          /Applications/ImageOptim.app/Contents/MacOS/ImageOptim resources/images
99      - name: Build and package for macOS
100        if: ${{ runner.os == 'macos' && always() }}
101        env:
102          CERT_MACOS_P12: ${{ secrets.CERT_MACOS_P12 }}
103          CERT_MACOS_PW: ${{ secrets.CERT_MACOS_PW }}
104          APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }}
105        run: |
106          $ANT_HOME/bin/ant -DnoErrorProne dist
107          ./native/macosx/macos-jpackage.sh ${{ env.josm_revision }}
108      - name: Create macOS release
109        if: ${{ runner.os == 'macos' && always() }}
110        id: create_release
111        uses: actions/create-release@v1
112        env:
113          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
114        with:
115          tag_name: ${{ env.josm_revision }}
116          release_name: JOSM.app release ${{ env.josm_revision }}
117          body: |
118            JOSM.app release ${{ env.josm_revision }}
119          draft: false
120          prerelease: ${{ env.josm_prerelease }}
121      - name: Upload app
122        if: ${{ runner.os == 'macos' && always() }}
123        id: upload-app
124        uses: actions/upload-release-asset@v1
125        env:
126          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127        with:
128          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
129          asset_path: app/JOSM.zip
130          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}.zip
131          asset_content_type: application/zip
132      - name: Upload jar
133        if: ${{ runner.os == 'macos' && always() }}
134        id: upload-jar
135        uses: actions/upload-release-asset@v1
136        env:
137          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138        with:
139          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
140          asset_path: dist/josm-custom.jar
141          asset_name: josm-latest.jar
142          asset_content_type: application/java-archive
Note: See TracBrowser for help on using the repository browser.