1 | name: Java CI Build
|
---|
2 | env:
|
---|
3 | junit_platform_version: '1.7.2'
|
---|
4 | # ANT_HOME is also our ant version
|
---|
5 | ANT_HOME: 'apache-ant-1.10.11'
|
---|
6 | WIX_HOME: 'wix3'
|
---|
7 | WIX_URL: 'https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip'
|
---|
8 | on:
|
---|
9 | push:
|
---|
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 release ${{ env.josm_release_tag }}
|
---|
61 | body: |
|
---|
62 | JOSM 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, 18-ea]
|
---|
76 | os: [ubuntu-latest, macos-latest, windows-latest]
|
---|
77 | exclude:
|
---|
78 | - java: 8
|
---|
79 | os: macos-latest
|
---|
80 | - java: 11
|
---|
81 | os: macos-latest
|
---|
82 | name: Java ${{ matrix.java }} on ${{ matrix.os }}
|
---|
83 | steps:
|
---|
84 | - name: Checkout
|
---|
85 | uses: actions/checkout@v2
|
---|
86 | with:
|
---|
87 | fetch-depth: 256
|
---|
88 |
|
---|
89 | - name: Cache
|
---|
90 | uses: actions/cache@v2.0.0
|
---|
91 | with:
|
---|
92 | path: |
|
---|
93 | ~/.ivy2/cache/
|
---|
94 | ~/work/josm/josm/tools/
|
---|
95 | key: ${{ runner.os }}-ivy2-${{ hashFiles('build.xml', 'ivy.xml', 'tools/ivy.xml') }}
|
---|
96 |
|
---|
97 | - name: Setup Java ${{ matrix.java }}
|
---|
98 | uses: actions/setup-java@v2
|
---|
99 | with:
|
---|
100 | distribution: 'zulu'
|
---|
101 | java-version: ${{ matrix.java }}
|
---|
102 |
|
---|
103 | - name: Install Ant ${{ env.ANT_HOME }}
|
---|
104 | run: |
|
---|
105 | if [ ! -f tools/${{ env.ANT_HOME }}-bin.tar.gz ]; then
|
---|
106 | curl -o tools/${{ env.ANT_HOME }}-bin.tar.gz https://downloads.apache.org/ant/binaries/${{ env.ANT_HOME }}-bin.tar.gz
|
---|
107 | fi
|
---|
108 | tar zxf tools/${{ env.ANT_HOME }}-bin.tar.gz
|
---|
109 |
|
---|
110 | - name: Ant diagnostics
|
---|
111 | run: ${{ env.ANT_HOME }}/bin/ant -diagnostics
|
---|
112 |
|
---|
113 | - name: Optimise images
|
---|
114 | if: ${{ runner.os == 'macos' && always() }}
|
---|
115 | run: |
|
---|
116 | brew install --cask imageoptim
|
---|
117 | defaults write net.pornel.ImageOptim SvgoEnabled 1
|
---|
118 | defaults write net.pornel.ImageOptim PngCrush2Enabled 1
|
---|
119 | defaults write net.pornel.ImageOptim PngOutEnabled 1
|
---|
120 | /Applications/ImageOptim.app/Contents/MacOS/ImageOptim resources/images
|
---|
121 |
|
---|
122 | - name: Build with Ant
|
---|
123 | # Calls ant with -Dreleasebuild=true if we're a 'tested' build
|
---|
124 | run: |
|
---|
125 | if [ "${{ needs.createrelease.outputs.josm_prerelease }}" == "true" ]; then
|
---|
126 | ANT="${{ env.ANT_HOME }}/bin/ant"
|
---|
127 | else
|
---|
128 | ANT="${{ env.ANT_HOME }}/bin/ant -Dreleasebuild=true"
|
---|
129 | fi
|
---|
130 | $ANT dist
|
---|
131 |
|
---|
132 | - name: Upload jar
|
---|
133 | if: ${{ always() }}
|
---|
134 | id: upload-jar
|
---|
135 | env:
|
---|
136 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
---|
137 | uses: actions/upload-release-asset@v1
|
---|
138 | with:
|
---|
139 | 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`.
|
---|
140 | asset_path: dist/josm-custom.jar
|
---|
141 | asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
|
---|
142 | asset_content_type: application/java-archive
|
---|
143 |
|
---|
144 | - name: Build and package for macOS
|
---|
145 | if: ${{ runner.os == 'macos' && always() }}
|
---|
146 | env:
|
---|
147 | CERT_MACOS_P12: ${{ secrets.CERT_MACOS_P12 }}
|
---|
148 | CERT_MACOS_PW: ${{ secrets.CERT_MACOS_PW }}
|
---|
149 | APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }}
|
---|
150 | run: |
|
---|
151 | ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
|
---|
152 |
|
---|
153 | - name: Build and package for Windows
|
---|
154 | if: ${{ runner.os == 'windows' && always() }}
|
---|
155 | run: |
|
---|
156 | if [ ! -f tools/${{ env.WIX_HOME }}-binaries.zip ]; then
|
---|
157 | curl -o tools/${{ env.WIX_HOME }}-binaries.zip ${{ env.WIX_URL }}
|
---|
158 | fi
|
---|
159 | Expand-Archive -Path tools/${{ env.WIX_HOME }}-binaries.zip -DestinationPath ${{ env.WIX_HOME }}
|
---|
160 | echo "${{ env.WIX_HOME }}" >> $GITHUB_PATH
|
---|
161 | ./native/windows/win-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
|
---|
162 |
|
---|
163 | - name: Upload macOS app
|
---|
164 | if: ${{ runner.os == 'macos' && always() }}
|
---|
165 | id: upload-app
|
---|
166 | uses: actions/upload-release-asset@v1
|
---|
167 | env:
|
---|
168 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
---|
169 | with:
|
---|
170 | 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`.
|
---|
171 | asset_path: app/JOSM.zip
|
---|
172 | asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}.zip
|
---|
173 | asset_content_type: application/zip
|
---|
174 |
|
---|
175 | - name: Upload Windows Installer package
|
---|
176 | if: ${{ runner.os == 'windows' && always() }}
|
---|
177 | id: upload-msi
|
---|
178 | uses: actions/upload-release-asset@v1
|
---|
179 | env:
|
---|
180 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
---|
181 | with:
|
---|
182 | 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`.
|
---|
183 | asset_path: app/JOSM.msi
|
---|
184 | asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}.msi
|
---|
185 | asset_content_type: application/x-ole-storage
|
---|