Skip to content

Commit

Permalink
create zip of all dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
artoonie committed Jan 24, 2024
1 parent 7b45e7e commit 06851f5
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 26 deletions.
20 changes: 7 additions & 13 deletions .github/actions/gradle-and-sha/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
24 changes: 24 additions & 0 deletions .github/actions/sha/action.yml
Original file line number Diff line number Diff line change
@@ -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

30 changes: 30 additions & 0 deletions .github/actions/zip/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Create zip of a directory"
description: "Cross-platform helper: creates SHA512"

inputs:
input:
description: "The input file path"
required: true
command:
description: "The command to run first"
required: true
zipFilename:
description: "The output file name"
required: true

runs:
using: "composite"
steps:
- name: "Run pre-command"
shell: bash
run: ${{ inputs.command }}

- name: "Generate zip for Linux"
if: runner.os == 'Linux' || runner.os == 'MacOS'
shell: bash
run: zip -r ${{inputs.zipFilename}} ${{inputs.input}}

- name: "Generate zip for Windows"
if: runner.os == 'Windows'
shell: powershell
run: Compress-Archive -Path ${{inputs.input}} -Destination ${{inputs.zipFilename}}
48 changes: 42 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -77,6 +77,38 @@ jobs:
intermediate-filepath: build/rcv.zip
final-filepath: ${{ steps.zipfn.outputs.FILEPATH }}

- name: "Create caches filename"
id: cachefn
shell: bash
run: |
echo "DEPENDENCY_FILEPATH=dependencycache.${{ runner.os }}.zip" >> $GITHUB_OUTPUT
echo "PLUGIN_FILEPATH=plugincache.${{ runner.os }}.zip" >> $GITHUB_OUTPUT
- name: "Create dependency zip"
uses: ./.github/actions/zip
with:
command: ./gradlew copyLibs
input: ".dependencycache"
zipFilename: ${{steps.cachefn.outputs.DEPENDENCY_FILEPATH}}

- name: "Create plugins zip"
uses: ./.github/actions/zip
with:
type: "zip"
command: ./gradlew assemble && ./gradlew --stop
input: "~/.gradle/caches"
zipFilename: ${{steps.cachefn.outputs.PLUGIN_FILEPATH}}

- 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:
Expand Down Expand Up @@ -132,6 +164,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"
Expand Down
46 changes: 39 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down Expand Up @@ -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
}

0 comments on commit 06851f5

Please sign in to comment.