From 45fa5f2ef95336448768ee8890fb8036b8031d81 Mon Sep 17 00:00:00 2001 From: Armin Samii Date: Wed, 24 Jan 2024 15:18:09 -0500 Subject: [PATCH] create zip of all dependencies --- .github/actions/gradle-and-sha/action.yml | 20 ++++----- .github/actions/sha/action.yml | 24 +++++++++++ .github/workflows/release.yml | 49 ++++++++++++++++++++--- build.gradle | 46 +++++++++++++++++---- 4 files changed, 113 insertions(+), 26 deletions(-) create mode 100644 .github/actions/sha/action.yml diff --git a/.github/actions/gradle-and-sha/action.yml b/.github/actions/gradle-and-sha/action.yml index 355c90c73..f68a6ee66 100644 --- a/.github/actions/gradle-and-sha/action.yml +++ b/.github/actions/gradle-and-sha/action.yml @@ -22,17 +22,11 @@ runs: - name: "Rename output file" shell: bash - run: mv ${{ inputs.intermediate-filepath }} ${{ inputs.final-filepath }} + run: | + ls build/*/* + mv ${{ inputs.intermediate-filepath }} ${{ inputs.final-filepath }} - - name: "Generate SHA512 for Linux" - shell: bash - if: runner.os == 'Linux' - run: sha512sum ${{ inputs.final-filepath }} > ${{ inputs.final-filepath }}.sha512 - - name: "Generate SHA512 for Windows" - shell: bash - if: runner.os == 'Windows' - run: certutil -hashfile ${{ inputs.final-filepath }} SHA512 >> ${{ inputs.final-filepath }}.sha512 - - name: "Generate SHA512 for OSX" - shell: bash - if: runner.os == 'macOS' - run: openssl dgst -sha512 > ${{ inputs.final-filepath }}.sha512 + - name: "Generate SHA512" + uses: ./.github/actions/sha + with: + filepath: ${{ inputs.final-filepath }} diff --git a/.github/actions/sha/action.yml b/.github/actions/sha/action.yml new file mode 100644 index 000000000..2682b0228 --- /dev/null +++ b/.github/actions/sha/action.yml @@ -0,0 +1,24 @@ +name: "Create SHA512 for a file" +description: "Cross-platform helper: creates SHA512" + +inputs: + filepath: + description: "The input file path" + required: true + +runs: + using: "composite" + steps: + - name: "Generate SHA512 for Linux" + shell: bash + if: runner.os == 'Linux' + run: sha512sum ${{ inputs.filepath }} > ${{ inputs.filepath }}.sha512 + - name: "Generate SHA512 for Windows" + shell: bash + if: runner.os == 'Windows' + run: certutil -hashfile ${{ inputs.filepath }} SHA512 >> ${{ inputs.filepath }}.sha512 + - name: "Generate SHA512 for macOS" + shell: bash + if: runner.os == 'macOS' + run: openssl dgst -sha512 > ${{ inputs.filepath }}.sha512 + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1617c1fe1..16b015b5e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,11 +3,11 @@ name: "Generate Releases" on: release: types: [ published ] -## To test this workflow without creating a release, uncomment the following and add a branch name (making sure "push" -## is at the same indent level as "release": -# push: -# branches: -# - 'branch-name' +# To test this workflow without creating a release, uncomment the following and add a branch name (making sure "push" +# is at the same indent level as "release": + push: + branches: + - 'feature/issue-756_airgap' jobs: release: @@ -50,7 +50,7 @@ jobs: if [ ${{ runner.os }} == 'Windows' ]; then echo "FILEPATH=build/jpackage/RCTab-1.3.999.exe" >> $GITHUB_OUTPUT elif [ ${{ runner.os }} == 'Linux' ]; then - echo "FILEPATH=build/jpackage/rctab_1.3.999-1_amd64.deb" >> $GITHUB_OUTPUT + echo "FILEPATH=build/jpackage/rctab_1.3.999_amd64.deb" >> $GITHUB_OUTPUT else echo "FILEPATH=build/jpackage/RCTab-1.3.999.dmg" >> $GITHUB_OUTPUT fi @@ -77,6 +77,39 @@ jobs: intermediate-filepath: build/rcv.zip final-filepath: ${{ steps.zipfn.outputs.FILEPATH }} + - name: "Create caches filename" + id: cachefn + shell: bash + run: | + echo "DEPENDENCY_FILEPATH=dependency.${{ runner.os }}.zip" >> $GITHUB_OUTPUT + echo "PLUGIN_FILEPATH=plugin.${{ runner.os }}.zip" >> $GITHUB_OUTPUT + + - name: "Create dependency zip" + uses: thedoctor0/zip-release@0.7.5 + with: + type: "zip" + command: ./gradlew copyLibs + filename: ${{steps.cachefn.outputs.DEPENDENCY_FILEPATH}} + path: ".dependencycache" + + - name: "Create plugins zip" + uses: thedoctor0/zip-release@0.7.5 + with: + type: "zip" + command: ./gradlew assemble && ls ~/.gradle + filename: ${{steps.cachefn.outputs.PLUGIN_FILEPATH}} + path: "../../.gradle/caches" # sadly, we can't use ~ or $HOME + + - name: "Generate SHA512 for dependency cache" + uses: ./.github/actions/sha + with: + filepath: ${{steps.cachefn.outputs.DEPENDENCY_FILEPATH}} + + - name: "Generate SHA512 for plugins cache" + uses: ./.github/actions/sha + with: + filepath: ${{steps.cachefn.outputs.PLUGIN_FILEPATH}} + - name: "Prepare keychain" if: matrix.os == 'macOS-latest' env: @@ -132,6 +165,10 @@ jobs: ${{ github.workspace }}/${{ steps.zipfn.outputs.FILEPATH }}.sha512 ${{ github.workspace }}/${{ steps.exefn.outputs.FILEPATH }} ${{ github.workspace }}/${{ steps.exefn.outputs.FILEPATH }}.sha512 + ${{ github.workspace }}/dependencycache.zip + ${{ github.workspace }}/dependencycache.zip.sha512 + ${{ github.workspace }}/plugincache.zip + ${{ github.workspace }}/plugincache.zip.sha512 retention-days: 90 - name: "Upload binaries to release" diff --git a/build.gradle b/build.gradle index 46821cfd5..049453211 100644 --- a/build.gradle +++ b/build.gradle @@ -15,14 +15,24 @@ repositories { mavenCentral() } +// Caching dependencies for a fully-offline build +def DEPENDENCY_CACHE_DIR = "$projectDir/.dependencycache/" + dependencies { - implementation 'commons-cli:commons-cli:1.5.0' - implementation 'org.apache.commons:commons-csv:1.10.0' - implementation 'org.apache.poi:poi-ooxml:5.2.3' - implementation 'com.fasterxml.jackson.core:jackson-core:2.15.2' - implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.2' - implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2' - implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.2' + if (gradle.startParameter.isOffline()) { + implementation fileTree(dir: DEPENDENCY_CACHE_DIR) + } else { + implementation 'commons-cli:commons-cli:1.5.0' + implementation 'org.apache.commons:commons-csv:1.10.0' + implementation 'org.apache.poi:poi-ooxml:5.2.3' + implementation 'com.fasterxml.jackson.core:jackson-core:2.15.2' + implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.2' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2' + implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.2' + implementation "com.github.spotbugs:spotbugs:4.8.3" + + } + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3' } @@ -235,3 +245,25 @@ tasks.jlink.doLast { into JLINK_DIR + "/sample_input" } } + +// Tooling to copy dependencies for a fully-offline build +configurations { + cacheableImplementation.extendsFrom implementation +} + +task deleteLibraryCache(type: Delete) { + delete DEPENDENCY_CACHE_DIR +} + +task copyLibs(type: Copy, dependsOn: 'deleteLibraryCache') { + from configurations.cacheableImplementation + into DEPENDENCY_CACHE_DIR +} + +// Necessary for offline builds to succeed +tasks.withType(Tar) { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} +tasks.withType(Zip) { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +}