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

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

update to ant 1.10.11

File size: 6.0 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'
6on:
7  push:
8    branches: [master]
9
10defaults:
11  run:
12    shell: bash
13
14jobs:
15
16  createrelease:
17    name: Create Release
18    runs-on: ubuntu-latest
19    env:
20      LANG: en_US.UTF-8
21    outputs:
22      upload_url: ${{ steps.create_release.outputs.upload_url }}
23      josm_revision: ${{ steps.create_revision.outputs.josm_revision }}
24      josm_prerelease: ${{ steps.create_revision.outputs.josm_prerelease }}
25      josm_release_tag: ${{ steps.create_revision.outputs.josm_release_tag }}
26    steps:
27      - name: Checkout
28        uses: actions/checkout@v2
29        with:
30          fetch-depth: 256
31
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
51      - name: Create release
52        id: create_release
53        uses: actions/create-release@v1
54        env:
55          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
56        with:
57          tag_name: ${{ env.josm_release_tag }}
58          release_name: JOSM.app release ${{ env.josm_release_tag }}
59          body: |
60            JOSM.app release ${{ env.josm_release_tag }}
61          draft: false
62          prerelease: ${{ env.josm_prerelease }}
63
64  build:
65    needs: createrelease
66    runs-on: ${{ matrix.os }}
67    env:
68      LANG: en_US.UTF-8
69    strategy:
70      fail-fast: false
71      matrix:
72        # test against latest update of each major Java version, as well as specific updates of LTS versions:
73        java: [8, 11, 16, 17-ea, 18-ea]
74        os: [ubuntu-latest, macos-latest, windows-latest]
75        exclude:
76          - java: 8
77            os: macos-latest
78          - java: 11
79            os: macos-latest
80    name: Java ${{ matrix.java }} on ${{ matrix.os }}
81    steps:
82      - name: Checkout
83        uses: actions/checkout@v2
84        with:
85          fetch-depth: 256
86
87      - name: Cache
88        uses: actions/cache@v2.0.0
89        with:
90          path: |
91            ~/.ivy2/cache/
92            ~/work/josm/josm/tools/
93          key: ${{ runner.os }}-ivy2-${{ hashFiles('build.xml', 'ivy.xml', 'tools/ivy.xml') }}
94
95      - name: Setup Java ${{ matrix.java }}
96        uses: actions/setup-java@v2
97        with:
98          distribution: 'zulu'
99          java-version: ${{ matrix.java }}
100
101      - name: Install Ant ${{ env.ANT_HOME }}
102        run: |
103          if [ ! -f tools/${{ env.ANT_HOME }}-bin.tar.gz ]; then
104            curl -o tools/${{ env.ANT_HOME }}-bin.tar.gz https://downloads.apache.org/ant/binaries/${{ env.ANT_HOME }}-bin.tar.gz
105          fi
106          tar zxf tools/${{ env.ANT_HOME }}-bin.tar.gz
107
108      - name: Ant diagnostics
109        run: ${{ env.ANT_HOME }}/bin/ant -diagnostics
110
111      - name: Optimise images
112        if: ${{ runner.os == 'macos' && always() }}
113        run: |
114          brew install --cask imageoptim
115          defaults write net.pornel.ImageOptim SvgoEnabled 1
116          defaults write net.pornel.ImageOptim PngCrush2Enabled 1
117          defaults write net.pornel.ImageOptim PngOutEnabled 1
118          /Applications/ImageOptim.app/Contents/MacOS/ImageOptim resources/images
119
120      - name: Build with Ant
121        # Calls ant with -Dreleasebuild=true if we're a 'tested' build
122        run: |
123          if [ "${{ needs.createrelease.outputs.josm_prerelease }}" == "true" ]; then
124            ANT="${{ env.ANT_HOME }}/bin/ant"
125          else
126            ANT="${{ env.ANT_HOME }}/bin/ant -Dreleasebuild=true"
127          fi
128          $ANT dist
129
130      - name: Upload jar
131        if: ${{ always() }}
132        id: upload-jar
133        env:
134          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135        uses: actions/upload-release-asset@v1
136        with:
137          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`.
138          asset_path: dist/josm-custom.jar
139          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
140          asset_content_type: application/java-archive
141
142      - name: Build and package for macOS
143        if: ${{ runner.os == 'macos' && always() }}
144        env:
145          CERT_MACOS_P12: ${{ secrets.CERT_MACOS_P12 }}
146          CERT_MACOS_PW: ${{ secrets.CERT_MACOS_PW }}
147          APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }}
148        run: |
149          ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
150
151      - name: Upload macOS app
152        if: ${{ runner.os == 'macos' && always() }}
153        id: upload-app
154        uses: actions/upload-release-asset@v1
155        env:
156          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157        with:
158          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`.
159          asset_path: app/JOSM.zip
160          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}.zip
161          asset_content_type: application/zip
Note: See TracBrowser for help on using the repository browser.