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

Last change on this file was 18225, checked in by Don-vip, 5 weeks ago

see #20522 - Prefer Java 17 over everything else

File size: 9.2 KB
Line 
1name: Java CI Build
2env:
3  junit_platform_version: '1.7.2'
4  # ANT_HOME is also our ant version
5  ANT_HOME: 'apache-ant-1.10.11'
6  JAVAFX_VERSION: '17'
7on:
8  push:
9    branches: [master]
10
11defaults:
12  run:
13    shell: bash
14
15jobs:
16
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
33      - name: Set revision env variable
34        id: create_revision
35        # grab josm revision from last git-svn-id
36        run: |
37          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')"
38          if [[ "$josm_revision" == "$(curl --silent https://josm.openstreetmap.de/tested)" ]]; then
39            echo "josm_prerelease=false" >> $GITHUB_ENV
40            echo "::set-output name=josm_prerelease::false"
41            josm_release_tag=$josm_revision-tested
42          else
43            echo "josm_prerelease=true" >> $GITHUB_ENV
44            echo "::set-output name=josm_prerelease::true"
45            josm_release_tag=$josm_revision
46          fi
47          echo "josm_revision=$josm_revision" >> $GITHUB_ENV
48          echo "::set-output name=josm_revision::$josm_revision"
49          echo "josm_release_tag=$josm_release_tag" >> $GITHUB_ENV
50          echo "::set-output name=josm_release_tag::$josm_release_tag"
51
52      - name: Create release
53        id: create_release
54        uses: actions/create-release@v1
55        env:
56          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
57        with:
58          tag_name: ${{ env.josm_release_tag }}
59          release_name: JOSM release ${{ env.josm_release_tag }}
60          body: |
61            JOSM release ${{ env.josm_release_tag }}
62          draft: false
63          prerelease: ${{ env.josm_prerelease }}
64
65  build:
66    needs: createrelease
67    runs-on: ${{ matrix.os }}
68    env:
69      LANG: en_US.UTF-8
70    strategy:
71      fail-fast: false
72      matrix:
73        # test against latest update of each major Java version, as well as specific updates of LTS versions:
74        java: [8, 11, 17, 18-ea]
75        os: [ubuntu-latest, macos-latest, windows-latest]
76    name: Java ${{ matrix.java }} on ${{ matrix.os }}
77    steps:
78      - name: Checkout
79        uses: actions/checkout@v2
80        with:
81          fetch-depth: 256
82
83      - name: Cache
84        uses: actions/cache@v2.0.0
85        with:
86          path: |
87            ~/.ivy2/cache/
88            ~/work/josm/josm/tools/
89          key: ${{ runner.os }}-ivy2-${{ hashFiles('build.xml', 'ivy.xml', 'tools/ivy.xml') }}
90
91      - name: Setup Java ${{ matrix.java }}
92        uses: actions/setup-java@v2
93        with:
94          distribution: 'zulu'
95          java-version: ${{ matrix.java }}
96
97      - name: Install Ant ${{ env.ANT_HOME }}
98        run: |
99          if [ ! -f tools/${{ env.ANT_HOME }}-bin.tar.gz ]; then
100            curl -o tools/${{ env.ANT_HOME }}-bin.tar.gz https://downloads.apache.org/ant/binaries/${{ env.ANT_HOME }}-bin.tar.gz
101          fi
102          tar zxf tools/${{ env.ANT_HOME }}-bin.tar.gz
103
104      - name: Ant diagnostics
105        run: ${{ env.ANT_HOME }}/bin/ant -diagnostics
106
107      - name: Optimise images
108        if: ${{ runner.os == 'macos' && always() }}
109        run: |
110          brew install --cask imageoptim
111          defaults write net.pornel.ImageOptim SvgoEnabled 1
112          defaults write net.pornel.ImageOptim PngCrush2Enabled 1
113          defaults write net.pornel.ImageOptim PngOutEnabled 1
114          /Applications/ImageOptim.app/Contents/MacOS/ImageOptim resources/images
115
116      - name: Build with Ant
117        env:
118          SIGN_ALIAS: ${{ secrets.SIGN_ALIAS }}
119          SIGN_CERT: ${{ secrets.SIGN_CERT }}
120          SIGN_KEYPASS: ${{ secrets.SIGN_KEYPASS }}
121          SIGN_STOREPASS: ${{ secrets.SIGN_STOREPASS }}
122          SIGN_TSA: ${{ secrets.SIGN_TSA }}
123        # Calls ant with -Dreleasebuild=true if we're a 'tested' build
124        run: |
125          export SIGN_KEYSTORE=certificate.p12
126          echo "$SIGN_CERT" | base64 --decode > $SIGN_KEYSTORE
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          rm $SIGN_KEYSTORE
134
135      - name: Upload jar
136        if: ${{ always() }}
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
146      - name: Build and package for macOS
147        if: ${{ runner.os == 'macos' && matrix.java != '8' && matrix.java != '11' && always() }}
148        env:
149          CERT_MACOS_P12: ${{ secrets.CERT_MACOS_P12 }}
150          CERT_MACOS_PW: ${{ secrets.CERT_MACOS_PW }}
151          APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }}
152        run: |
153          if [ ! -f tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip ]; then
154            curl -o tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_osx-x64_bin-jmods.zip
155          fi
156          unzip tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip
157          mv javafx-jmods-${JAVAFX_VERSION}/*.jmod $JAVA_HOME/jmods/
158          ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
159
160      - name: Setup Windows PATH
161        if: ${{ runner.os == 'windows' && matrix.java != '8' && matrix.java != '11' && always() }}
162        run: |
163          echo "C:\Program Files (x86)\WiX Toolset v3.11\bin" >> $GITHUB_PATH
164          echo "C:\Program Files (x86)\Windows Kits\10\bin\x64" >> $GITHUB_PATH
165
166      - name: Build and package for Windows
167        if: ${{ runner.os == 'windows' && matrix.java != '8' && matrix.java != '11' && always() }}
168        env:
169          SIGN_CERT: ${{ secrets.SIGN_CERT }}
170          SIGN_STOREPASS: ${{ secrets.SIGN_STOREPASS }}
171          SIGN_TSA: ${{ secrets.SIGN_TSA }}
172        run: |
173          if [ ! -f tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip ]; then
174            curl -o tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_windows-x64_bin-jmods.zip
175          fi
176          unzip tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip
177          mv javafx-jmods-${JAVAFX_VERSION}/*.jmod $JAVA_HOME/jmods/
178          ./native/windows/win-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
179
180      - name: Upload macOS app
181        if: ${{ runner.os == 'macos' && matrix.java != '8' && matrix.java != '11' && always() }}
182        uses: actions/upload-release-asset@v1
183        env:
184          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
185        with:
186          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`.
187          asset_path: app/JOSM.zip
188          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.zip
189          asset_content_type: application/zip
190
191      - name: Upload Windows Installer executable
192        if: ${{ runner.os == 'windows' && matrix.java != '8' && matrix.java != '11' && always() }}
193        uses: actions/upload-release-asset@v1
194        env:
195          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196        with:
197          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`.
198          asset_path: app/JOSM.exe
199          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.exe
200          asset_content_type: application/vnd.microsoft.portable-executable
201
202      - name: Upload Windows Installer package
203        if: ${{ runner.os == 'windows' && matrix.java != '8' && matrix.java != '11' && always() }}
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.msi
210          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.msi
211          asset_content_type: application/x-ole-storage
Note: See TracBrowser for help on using the repository browser.