From 6c057a83afc1fa216e96a4dfdb5500e172c31d68 Mon Sep 17 00:00:00 2001 From: Oscar Reimer Date: Tue, 5 Nov 2024 12:11:16 +0100 Subject: [PATCH] Fix Calculate checksum of soot wrapper --- .github/workflows/release.yml | 84 ++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff179617..344fc0a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,69 +9,91 @@ permissions: contents: write jobs: - soot-wrapper: + calculate-checksum: runs-on: ubuntu-latest - strategy: - matrix: - java-version: [ 11, 17, 21 ] + outputs: + next_latest_tag: ${{ steps.next-latest-tag.outputs.next_latest_tag }} + prev_hash: ${{ steps.calc-checksum.outputs.prev_hash }} + hash: ${{ steps.calc-checksum.outputs.hash }} steps: - uses: actions/checkout@v4 with: - repository: 'debricked/soot-wrapper' + fetch-depth: 30 + fetch-tags: true + ref: ${{ github.event.repository.default_branch }} + sparse-checkout: . + - name: Get next latest tag + id: next-latest-tag + run: | + CURRENT_TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name') + PREVIOUS_TAG=$(git describe --tags --abbrev=0 $CURRENT_TAG^) + echo "next_latest_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT + + - uses: actions/checkout@v4 + with: + repository: 'debricked/soot-wrapper' + - name: Calculate checksum id: calc-checksum run: | - TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name') - curl -LJO https://github.com/${{ github.repository }}/releases/download/${TAG}/soot-wrapper-rev-hash-${{ matrix.java-version }}.txt + curl -LJO https://github.com/${{ github.repository }}/releases/download/${{ steps.next-latest-tag.outputs.next_latest_tag }}/soot-wrapper-rev-hash.txt - echo "release_tag=$TAG" >> $GITHUB_OUTPUT echo "hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - if [ ! -f soot-wrapper-rev-hash-${{ matrix.java-version }}.txt ]; then - touch soot-wrapper-rev-hash-${{ matrix.java-version }}.txt + if [ ! -f soot-wrapper-rev-hash.txt ]; then + touch soot-wrapper-rev-hash.txt fi - echo "prev_hash=$(cat soot-wrapper-rev-hash-${{ matrix.java-version }}.txt)" >> $GITHUB_OUTPUT + echo "prev_hash=$(cat soot-wrapper-rev-hash.txt)" >> $GITHUB_OUTPUT + + - name: Store soot-wrapper revision hash + run: | + echo ${{ steps.calc-checksum.outputs.hash }} > soot-wrapper-rev-hash.txt + + - name: Upload file containing soot-wrapper revision hash + uses: actions/upload-artifact@v4 + with: + name: soot-wrapper-rev-hash.txt + path: soot-wrapper-rev-hash.txt + overwrite: 'true' + + soot-wrapper: + needs: calculate-checksum + runs-on: ubuntu-latest + strategy: + matrix: + java-version: [ 11, 17, 21 ] + steps: + - uses: actions/checkout@v4 + with: + repository: 'debricked/soot-wrapper' - name: Pull JAR from previous release if already built - if: steps.calc-checksum.outputs.hash == steps.calc-checksum.outputs.prev_hash + if: needs.calculate-checksum.outputs.hash == needs.calculate-checksum.outputs.prev_hash run: | - curl -LJO https://github.com/${{ github.repository }}/releases/download/${{ steps.calc-checksum.outputs.release_tag }}/soot-wrapper-${{ matrix.java-version }}.zip + curl -LJO https://github.com/${{ github.repository }}/releases/download/${{ needs.calculate-checksum.outputs.next_latest_tag }}/soot-wrapper-${{ matrix.java-version }}.zip env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up JDK ${{ matrix.java-version }} - if: steps.calc-checksum.outputs.hash != steps.calc-checksum.outputs.prev_hash + if: needs.calculate-checksum.outputs.hash != needs.calculate-checksum.outputs.prev_hash uses: actions/setup-java@v4 with: java-version: ${{ matrix.java-version }} distribution: 'adopt' - name: Build with Maven - if: steps.calc-checksum.outputs.hash != steps.calc-checksum.outputs.prev_hash + if: needs.calculate-checksum.outputs.hash != needs.calculate-checksum.outputs.prev_hash run: | cd java/common/ mvn clean package -X -DskipTests - name: Create archive with generated JARs - if: steps.calc-checksum.outputs.hash != steps.calc-checksum.outputs.prev_hash + if: needs.calculate-checksum.outputs.hash != needs.calculate-checksum.outputs.prev_hash run: | cd java/common/target/ zip -r soot-wrapper-${{ matrix.java-version }}.zip *.jar mv soot-wrapper-${{ matrix.java-version }}.zip ../../../soot-wrapper-${{ matrix.java-version }}.zip - - name: Store soot-wrapper revision hash - if: steps.calc-checksum.outputs.hash != steps.calc-checksum.outputs.prev_hash - run: | - echo ${{ steps.calc-checksum.outputs.hash }} > soot-wrapper-rev-hash-${{ matrix.java-version }}.txt - - - name: Upload file containing soot-wrapper revision hash - if: steps.calc-checksum.outputs.hash != steps.calc-checksum.outputs.prev_hash - uses: actions/upload-artifact@v4 - with: - name: soot-wrapper-rev-hash-${{ matrix.java-version }}.txt - path: soot-wrapper-rev-hash-${{ matrix.java-version }}.txt - overwrite: 'true' - - name: Upload the archive uses: actions/upload-artifact@v4 with: @@ -124,9 +146,7 @@ jobs: with: tag_name: ${{ github.ref_name }} files: | - soot-wrapper-rev-hash-11.txt/soot-wrapper-rev-hash-11.txt - soot-wrapper-rev-hash-17.txt/soot-wrapper-rev-hash-17.txt - soot-wrapper-rev-hash-21.txt/soot-wrapper-rev-hash-21.txt + soot-wrapper-rev-hash.txt/soot-wrapper-rev-hash.txt soot-wrapper-11.zip/soot-wrapper-11.zip soot-wrapper-17.zip/soot-wrapper-17.zip soot-wrapper-21.zip/soot-wrapper-21.zip