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 5c81c6e
Show file tree
Hide file tree
Showing 4 changed files with 113 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

49 changes: 43 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,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/[email protected]
with:
type: "zip"
command: ./gradlew copyLibs
filename: ${{steps.cachefn.outputs.DEPENDENCY_FILEPATH}}
path: ".dependencycache"

- name: "Create plugins zip"
uses: thedoctor0/[email protected]
with:
type: "zip"
command: ./gradlew assemble
filename: ${{steps.cachefn.outputs.PLUGIN_FILEPATH}}
path: "~/.gradle/caches"

- 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 +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"
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 5c81c6e

Please sign in to comment.