Changeset 17487 in josm


Ignore:
Timestamp:
2021-02-08T20:52:53+01:00 (3 months ago)
Author:
GerdP
Message:

see #20257:macOS build process fixes and improvements

Location:
trunk
Files:
1 added
4 edited

Legend:

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

    r17373 r17487  
    2424      josm_revision: ${{ steps.create_revision.outputs.josm_revision }}
    2525      josm_prerelease: ${{ steps.create_revision.outputs.josm_prerelease }}
     26      josm_release_tag: ${{ steps.create_revision.outputs.josm_release_tag }}
    2627    steps:
    2728      - name: Checkout
    2829        uses: actions/checkout@v2
    2930        with:
    30           fetch-depth: 32
     31          fetch-depth: 256
    3132      - name: Set revision env variable
    3233        id: create_revision
     
    3536          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')"
    3637          if [[ "$josm_revision" == "$(curl --silent https://josm.openstreetmap.de/tested)" ]]; then
    37             sed -i '/Is-Local-Build/d' resources/REVISION
    3838            echo "josm_prerelease=false" >> $GITHUB_ENV
    3939            echo "::set-output name=josm_prerelease::false"
    40             echo "josm_release=$josm_revision-tested" >> $GITHUB_ENV
     40            josm_release_tag=$josm_revision-tested
    4141          else
    4242            echo "josm_prerelease=true" >> $GITHUB_ENV
    4343            echo "::set-output name=josm_prerelease::true"
    44             echo "josm_release=$josm_revision" >> $GITHUB_ENV
     44            josm_release_tag=$josm_revision
    4545          fi
    4646          echo "josm_revision=$josm_revision" >> $GITHUB_ENV
    4747          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"
    4850      - name: Create release
    4951        id: create_release
     
    5254          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
    5355        with:
    54           tag_name: ${{ env.josm_release }}
    55           release_name: JOSM.app release ${{ env.josm_release }}
     56          tag_name: ${{ env.josm_release_tag }}
     57          release_name: JOSM.app release ${{ env.josm_release_tag }}
    5658          body: |
    57             JOSM.app release ${{ env.josm_release }}
     59            JOSM.app release ${{ env.josm_release_tag }}
    5860          draft: false
    5961          prerelease: ${{ env.josm_prerelease }}
     
    8486        uses: actions/checkout@v2
    8587        with:
    86           fetch-depth: 32
     88          fetch-depth: 256
    8789      - name: Cache
    8890        uses: actions/cache@v2.0.0
     
    120122          defaults write net.pornel.ImageOptim PngOutEnabled 1
    121123          /Applications/ImageOptim.app/Contents/MacOS/ImageOptim resources/images
     124      - name: Set Is-Local-Build
     125        if: ${{ ! needs.createrelease.outputs.josm_prerelease }}
     126        run: |
     127          ant create-revision
     128          sed -i.bak '/Is-Local-Build/d' resources/REVISION
    122129      - name: Build with Ant
    123130        # Disables errorprone for Java 16
     
    130137          fi
    131138      - name: Upload jar
    132         if: ${{ always() && matrix.headless }}
     139        # Only run on matrix.headless to avoid double jars. They should be the same jars.
     140        # uses `gh release upload` to avoid https://github.com/actions/upload-release-asset/issues/69
     141        if: ${{ always() && matrix.headless == 'true' }}
    133142        id: upload-jar
     143        env:
     144          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    134145        uses: actions/upload-release-asset@v1
    135         env:
    136           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    137146        with:
    138147          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`.
     
    140149          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
    141150          asset_content_type: application/java-archive
     151        # run: |
     152        #   cp dist/josm-custom.jar JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
     153        #   gh release upload ${{ needs.createrelease.outputs.josm_release_tag }} JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
    142154      - name: Test with Ant, headless ${{ matrix.headless }}
    143155        if: ${{ needs.createrelease.outputs.josm_prerelease }}
     
    158170          name: Ant reports for JOSM ${{ needs.createrelease.outputs.josm_revision }} on java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }}
    159171          path: test/report/*.txt
     172      - name: Publish Test Report with junit-report-annotations-action
     173        uses: ashley-taylor/junit-report-annotations-action@1.3
     174        if: always()
     175        with:
     176          access-token: ${{ secrets.GITHUB_TOKEN }}
     177          path: 'test/report/TEST*.xml'
     178      - name: Publish Test Report with action-junit-report
     179        if: always()
     180        uses: mikepenz/action-junit-report@v1
     181        with:
     182          report_paths: 'test/report/TEST*.xml'
     183          github_token: ${{ secrets.GITHUB_TOKEN }}
    160184      - name: Build and package for macOS
    161185        if: ${{ runner.os == 'macos' && always() }}
  • trunk/native/macosx/macos-jpackage.sh

    r17373 r17487  
    11#!/bin/bash
     2
     3## Expected environment, passed from GitHub secrets:
     4# https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
     5# APPLE_ID_PW     Password for the Apple ID
     6# CERT_MACOS_P12  Certificate used for code signing, base64 encoded
     7# CERT_MACOS_PW   Password for that certificate
    28
    39set -Eeou pipefail
     
    612set +x
    713
    8 SIGNING_KEY_NAME="Developer ID Application: FOSSGIS e.V. (P8AAAGN2AM)"
     14APPLE_ID="thomas.skowron@fossgis.de"
    915IMPORT_AND_UNLOCK_KEYCHAIN=${IMPORT_AND_UNLOCK_KEYCHAIN:-1}
    1016
     
    1925mkdir app
    2026
    21 if [[ $IMPORT_AND_UNLOCK_KEYCHAIN == 1 ]]; then
    22     if [ -z "$CERT_MACOS_P12" ]
    23     then
    24         echo "CERT_MACOS_P12 must be set in the environment. Won't sign app."
    25         exit 1
    26     fi
    27 
    28 
    29     if [ -z "$CERT_MACOS_PW" ]
    30     then
    31         echo "CERT_MACOS_P12 must be set in the environment. Won't sign app."
    32         exit 1
    33     fi
    34 
     27if [ -z "$CERT_MACOS_P12" ] || [ -z "$CERT_MACOS_PW" ] || [ -z "$APPLE_ID_PW" ]
     28then
     29    echo "CERT_MACOS_P12, CERT_MACOS_PW and APPLE_ID_PW are not set in the environment."
     30    echo "I will create a JOSM.app but I won't attempt to sign and notarize it."
     31    SIGNAPP=false
     32else
    3533    echo "Preparing certificates/keychain for signing…"
    3634
    3735    KEYCHAIN=build.keychain
    3836    KEYCHAINPATH=~/Library/Keychains/$KEYCHAIN-db
    39     KEYCHAIN_PW=`head /dev/urandom | base64 | head -c 20`
     37    KEYCHAIN_PW=$(head /dev/urandom | base64 | head -c 20)
    4038    CERTIFICATE_P12=certificate.p12
    4139
    42     echo $CERT_MACOS_P12 | base64 --decode > $CERTIFICATE_P12
    43     security create-keychain -p $KEYCHAIN_PW $KEYCHAIN
     40    echo "$CERT_MACOS_P12" | base64 --decode > $CERTIFICATE_P12
     41    security create-keychain -p "$KEYCHAIN_PW" $KEYCHAIN
    4442    security default-keychain -s $KEYCHAIN
    45     security unlock-keychain -p $KEYCHAIN_PW $KEYCHAIN
    46     security import $CERTIFICATE_P12 -k $KEYCHAIN -P $CERT_MACOS_PW -T /usr/bin/codesign
    47     security set-key-partition-list -S apple-tool:,apple: -s -k $KEYCHAIN_PW $KEYCHAIN
     43    security unlock-keychain -p "$KEYCHAIN_PW" $KEYCHAIN
     44    security import $CERTIFICATE_P12 -k $KEYCHAIN -P "$CERT_MACOS_PW" -T /usr/bin/codesign
     45    security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PW" $KEYCHAIN
    4846    rm $CERTIFICATE_P12
    49 
     47    SIGNAPP=true
    5048    echo "Signing preparation done."
    5149fi
    5250
     51if $SIGNAPP; then
     52  JPACKAGEOPTIONS="--mac-sign --mac-signing-keychain $KEYCHAINPATH"
     53else
     54  JPACKAGEOPTIONS=""
     55fi
     56
    5357echo "Building and signin app"
    54     jpackage -n "JOSM" --input dist --main-jar josm-custom.jar \
     58    jpackage $JPACKAGEOPTIONS -n "JOSM" --input dist --main-jar josm-custom.jar \
    5559    --main-class org.openstreetmap.josm.gui.MainApplication \
    5660    --icon ./native/macosx/JOSM.icns --type app-image --dest app \
    5761    --java-options "-Xmx8192m" \
    58      --java-options "-Dapple.awt.application.appearance=system" \
    59     --app-version $1 \
     62    --app-version "$1" \
    6063    --copyright "JOSM, and all its integral parts, are released under the GNU General Public License v2 or later" \
    6164    --vendor "https://josm.openstreetmap.de" \
     
    7679echo "Building done."
    7780
    78 echo "Preparing for notarization"
    79 ditto -c -k --zlibCompressionLevel 9 --keepParent app/JOSM.app app/JOSM.zip
     81if $SIGNAPP; then
     82    echo "Preparing for notarization"
     83    ditto -c -k --zlibCompressionLevel 9 --keepParent app/JOSM.app app/JOSM.zip
    8084
    81 echo "Uploading to Apple"
    82 xcrun altool --notarize-app -f app/JOSM.zip -p "$APPLE_ID_PW" -u "thomas.skowron@fossgis.de" --primary-bundle-id de.openstreetmap.josm
     85    echo "Uploading to Apple"
     86    xcrun altool --notarize-app -f app/JOSM.zip -p "$APPLE_ID_PW" -u "$APPLE_ID" --primary-bundle-id de.openstreetmap.josm
     87fi
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r17399 r17487  
    77
    88import java.awt.AWTError;
     9import java.awt.Color;
    910import java.awt.Container;
    1011import java.awt.Dimension;
     
    10421043                Logging.log(Logging.LEVEL_ERROR, null, e);
    10431044            }
     1045        }
     1046        // Workaround for JDK-8251377: JTabPanel active tab is unreadable in Big Sur, see #20075
     1047        // os.version will return 10.16, or 11.0 depending on environment variable
     1048        // https://twitter.com/BriceDutheil/status/1330926649269956612
     1049        else {
     1050            final String laf = UIManager.getLookAndFeel().getID();
     1051            final String macOSVersion = getSystemProperty("os.version");
     1052            if(PlatformManager.isPlatformOsx() && (laf.contains("Mac") || laf.contains("Aqua")) && (macOSVersion.startsWith("10.16") || macOSVersion.startsWith("11"))){
     1053                UIManager.put("TabbedPane.foreground", Color.BLACK);
     1054            }
    10441055        }
    10451056    }
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r15121 r17487  
    2626import java.util.List;
    2727import java.util.Objects;
     28import java.util.Optional;
    2829import java.util.concurrent.ExecutionException;
    2930
     
    3132import org.openstreetmap.josm.gui.MainApplication;
    3233import org.openstreetmap.josm.io.CertificateAmendment.NativeCertAmend;
     34import org.openstreetmap.josm.spi.preferences.Config;
     35
    3336
    3437/**
     
    8184            }
    8285            // setup the dock icon. It is automatically set with application bundle and Web start but we need
    83             // to do it manually if run with `java -jar``
    84             eawtApplication.getDeclaredMethod("setDockIconImage", Image.class).invoke(appli, ImageProvider.get("logo").getImage());
     86            // to do it manually if run with `java -jar``.
     87            eawtApplication.getDeclaredMethod("setDockIconImage", Image.class).invoke(
     88                appli,
     89                Optional.ofNullable(
     90                    new ImageProvider(Config.getUrls().getJOSMWebsite()+"/logo-macos.png").setOptional(true).get()
     91                ).orElse( // Fall back to default icon
     92                    ImageProvider.get("logo")).getImage()
     93            );
     94       
    8595            // enable full screen
    8696            enableOSXFullscreen(MainApplication.getMainFrame());
Note: See TracChangeset for help on using the changeset viewer.