Changeset 17373 in josm for trunk/.github


Ignore:
Timestamp:
2020-11-28T17:39:56+01:00 (6 months ago)
Author:
Don-vip
Message:

see #20146 - Improvements to macOS build and github actions (patch by Stereo)

From https://github.com/openstreetmap/josm/pull/67:

  • Separate the create-release github action to pass the release url to all subsequent jobs, to be able to...
  • Upload .jar artefacts from all runs, and a separate .app for all java versions for macOS
  • Better caching for ant/junit
  • Support for the release workflow from #20146
  • A few cosmetic fixes, more readable syntax, etc.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/ant.yml

    r17287 r17373  
    1515
    1616jobs:
     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    steps:
     27      - name: Checkout
     28        uses: actions/checkout@v2
     29        with:
     30          fetch-depth: 32
     31      - name: Set revision env variable
     32        id: create_revision
     33        # grab josm revision from last git-svn-id
     34        run: |
     35          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')"
     36          if [[ "$josm_revision" == "$(curl --silent https://josm.openstreetmap.de/tested)" ]]; then
     37            sed -i '/Is-Local-Build/d' resources/REVISION
     38            echo "josm_prerelease=false" >> $GITHUB_ENV
     39            echo "::set-output name=josm_prerelease::false"
     40            echo "josm_release=$josm_revision-tested" >> $GITHUB_ENV
     41          else
     42            echo "josm_prerelease=true" >> $GITHUB_ENV
     43            echo "::set-output name=josm_prerelease::true"
     44            echo "josm_release=$josm_revision" >> $GITHUB_ENV
     45          fi
     46          echo "josm_revision=$josm_revision" >> $GITHUB_ENV
     47          echo "::set-output name=josm_revision::$josm_revision"
     48      - name: Create release
     49        id: create_release
     50        uses: actions/create-release@v1
     51        env:
     52          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
     53        with:
     54          tag_name: ${{ env.josm_release }}
     55          release_name: JOSM.app release ${{ env.josm_release }}
     56          body: |
     57            JOSM.app release ${{ env.josm_release }}
     58          draft: false
     59          prerelease: ${{ env.josm_prerelease }}
    1760  build:
     61    needs: createrelease
    1862    runs-on: ${{ matrix.os }}
    1963    env:
     
    3175          - java: 11
    3276            os: macos-latest
    33           - java: 16-ea
    34             os: macos-latest
    3577          - headless: "false"
    3678            os: macos-latest
     
    4284        uses: actions/checkout@v2
    4385        with:
    44           fetch-depth: 128
     86          fetch-depth: 32
    4587      - name: Cache
    4688        uses: actions/cache@v2.0.0
     
    4991            ~/.ivy2/cache/
    5092            ~/work/josm/josm/tools/
     93            build-tools-cache/
    5194          key: ${{ runner.os }}-ivy2-${{ hashFiles('ivy.xml') }}
    5295      - name: Setup java
     
    5598          java-version: ${{ matrix.java }}
    5699      - name: Install ant ${{ env.ANT_HOME }} and junit ${{ env.junit_platform_version }}
    57         # Todo: cache ant and junit, saves 12 seconds.
    58100        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"
     101          mkdir -p build-tools-cache/
     102          cd build-tools-cache/
     103          if [ ! -f ${{ env.ANT_HOME }}-bin.tar.gz ]; then
     104            curl -o ${{ env.ANT_HOME }}-bin.tar.gz https://downloads.apache.org/ant/binaries/${{ env.ANT_HOME }}-bin.tar.gz
     105          fi
     106          if [ ! -f junit-platform-console-standalone-${{ env.junit_platform_version }}.jar ]; then
     107            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
     108          fi
     109          cd ..
     110          tar zxf build-tools-cache/${{ env.ANT_HOME }}-bin.tar.gz
     111          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
    61112      - name: Print ant version, expecting ${{ env.ANT_HOME }}
    62113        run: ${{ env.ANT_HOME }}/bin/ant -version
    63       - name: Set revision env variable
     114      - name: Optimise images
     115        if: ${{ runner.os == 'macos' && always() }}
    64116        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
     117          brew cask install imageoptim
     118          defaults write net.pornel.ImageOptim SvgoEnabled 1
     119          defaults write net.pornel.ImageOptim PngCrush2Enabled 1
     120          defaults write net.pornel.ImageOptim PngOutEnabled 1
     121          /Applications/ImageOptim.app/Contents/MacOS/ImageOptim resources/images
     122      - name: Build with Ant
     123        # Disables errorprone for Java 16
     124        # See https://github.com/google/error-prone/issues/1872
     125        run: |
     126          if [[ "x${{ matrix.java }}x" =~ x1[6-9](-ea)?x ]]; then
     127            ${{ env.ANT_HOME }}/bin/ant -DnoErrorProne dist
    70128          else
    71             echo "josm_prerelease=true" >> $GITHUB_ENV
     129            ${{ env.ANT_HOME }}/bin/ant dist
    72130          fi
    73           echo "josm_revision=$josm_revision" >> $GITHUB_ENV
    74       - name: Build with Ant, headless ${{ matrix.headless }}
     131      - name: Upload jar
     132        if: ${{ always() && matrix.headless }}
     133        id: upload-jar
     134        uses: actions/upload-release-asset@v1
     135        env:
     136          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
     137        with:
     138          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`.
     139          asset_path: dist/josm-custom.jar
     140          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
     141          asset_content_type: application/java-archive
     142      - name: Test with Ant, headless ${{ matrix.headless }}
     143        if: ${{ needs.createrelease.outputs.josm_prerelease }}
    75144        run: |
    76145          ANT="${{ env.ANT_HOME }}/bin/ant -DnoJavaFX=true test-unit-hardfail"
     
    87156        uses: actions/upload-artifact@v2
    88157        with:
    89           name: Ant reports for JOSM ${{ env.josm_revision }} on java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }}
     158          name: Ant reports for JOSM ${{ needs.createrelease.outputs.josm_revision }} on java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }}
    90159          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
    99160      - name: Build and package for macOS
    100161        if: ${{ runner.os == 'macos' && always() }}
     
    104165          APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }}
    105166        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 }}
     167          ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
    121168      - name: Upload app
    122169        if: ${{ runner.os == 'macos' && always() }}
     
    126173          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    127174        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
     175          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`.
    129176          asset_path: app/JOSM.zip
    130177          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}.zip
    131178          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 TracChangeset for help on using the changeset viewer.