From e3f000b8cabf19d9cd5ccca98c07071a7ad0f821 Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Tue, 30 Jul 2024 07:21:24 -0600 Subject: [PATCH] Use standardized GitHub workflow Signed-off-by: Taylor Smock --- .github/workflows/ant.yml | 103 +++++++++++++++----------------------- 1 file changed, 40 insertions(+), 63 deletions(-) diff --git a/.github/workflows/ant.yml b/.github/workflows/ant.yml index 153d9d2a..417a4782 100644 --- a/.github/workflows/ant.yml +++ b/.github/workflows/ant.yml @@ -2,71 +2,48 @@ name: Java CI on: push: - branches: [ main, fixup-tests ] + branches: + - main + - $default-branch + - $protected-branches pull_request: - branches: [ main ] - release: - types: [created] + branches: + - main + - $default-branch + workflow_dispatch: jobs: - build: + check-release-needed: runs-on: ubuntu-latest + outputs: + release_needed: ${{ steps.create_release_needed.outputs.release_needed }} steps: - - name: Set up JDK 8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - - name: Cache - uses: actions/cache@v2.0.0 - with: - path: | - ~/.ivy2/cache/ - $GITHUB_WORKSPACE/josm/core/tools/ - key: ${{ runner.os }}-ivy2-${{ hashFiles('josm/plugins/${{ github.event.repository.name }}/build.xml', 'josm/plugins/00_core_tools/ivy.xml', 'josm/core/ivy.xml', 'josm/core/tools/ivy.xml') }} - - name: Clone JOSM - run: | - svn co --depth=immediates https://josm.openstreetmap.de/osmsvn/applications/editors/josm $GITHUB_WORKSPACE/josm - cd $GITHUB_WORKSPACE/josm - svn up --set-depth=immediates plugins - svn up --set-depth=infinity --accept=theirs-full core i18n plugins/{00_core_test_config,00_core_test_lib,00_core_tools,00_tools} - svn propget svn:externals | grep core | xargs -L1 svn co - cd core - ant dist - cd ../plugins - svn propget svn:externals | grep 00_core | xargs -L1 svn co - - uses: actions/checkout@v3 - with: - path: josm/plugins/${{ github.event.repository.name }} - - name: Build with Ant - run: | - cd $GITHUB_WORKSPACE/josm/plugins/${{ github.event.repository.name }} - if [ $GITHUB_REF_TYPE == "tag" ]; then - version=$GITHUB_REF_NAME - else - version="$GITHUB_REF_NAME-$GITHUB_SHA" - fi - ant -noinput -buildfile build.xml -Dplugin.version=$version - - name: Test with Ant - run: | - cd $GITHUB_WORKSPACE/josm/plugins/${{ github.event.repository.name }} - ant -noinput -buildfile build.xml -Dplugin.version=$version -Dtest.headless test - - name: Dump errors if failed - if: ${{ failure() }} - run: "grep -L ', Failures: 0, Skipped: ' test/report/*.txt | xargs cat" - - name: Upload Ant reports - if: ${{ always() }} - uses: actions/upload-artifact@v2 - with: - name: Ant reports for JOSM plugin ${{ github.event.repository.name }} - path: | - $GITHUB_WORKSPACE/josm/plugins/${{ github.event.repository.name }}/test/report/*.txt - $GITHUB_WORKSPACE/josm/plugins/${{ github.event.repository.name }}/test/report/TEST*.xml - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: | - josm/dist/${{ github.event.repository.name }}.jar - josm/dist/${{ github.event.repository.name }}-javadoc.jar - josm/dist/${{ github.event.repository.name }}-sources.jar + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: ${{ (github.repository == 'JOSM/wikipedia' && github.ref_type == 'branch' && github.ref_name == 'main' && github.event_name != 'schedule' && github.event_name != 'pull_request') && '0' || '1' }} + + - name: Set release needed + id: create_release_needed + run: | + last_tag=$(git describe --tags --abbrev=0 --always) + release_needed="false" + for file in $(git diff ${last_tag}..HEAD --name-only); do + if [[ $file = "src/main"* ]] || [[ $file = "" ]]; then + release_needed="true" + break + fi + done + echo "release_needed=$release_needed" >> $GITHUB_OUTPUT + + + call-workflow: + needs: check-release-needed + strategy: + matrix: + josm-revision: ["", "r18877"] + uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v2 + with: + josm-revision: ${{ matrix.josm-revision }} + perform-revision-tagging: ${{ matrix.josm-revision == 'r18877' && needs.check-release-needed.outputs.release_needed == 'true' }} + secrets: inherit