Skip to content

Commit

Permalink
Merge pull request #57 from gerlero/standalone
Browse files Browse the repository at this point in the history
Support standalone builds
  • Loading branch information
gerlero authored Jul 17, 2022
2 parents 336215e + 206c8a4 commit 53903a1
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 99 deletions.
115 changes: 95 additions & 20 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,104 @@ on:
required: false

jobs:
deps:
runs-on: macos-10.15
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache deps
if: inputs.cache
uses: actions/cache@v3
with:
path: build/*-deps.sparsebundle
key: deps-${{ inputs.openfoam-version }}-${{ runner.arch }}-${{ hashFiles('Brewfile', 'Makefile') }}
- name: Reuse cached deps if possible
run: |
touch -c build/*-deps.sparsebundle
- name: Make deps
run: >
make deps
OPENFOAM_VERSION=${{ inputs.openfoam-version }}
- name: Upload deps artifact
uses: actions/upload-artifact@v3
with:
name: deps-${{ inputs.openfoam-version }}-${{ runner.arch }}
path: build/*-deps.sparsebundle
if-no-files-found: error

build:
needs: deps
runs-on: macos-10.15
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache DMG file
- name: Download deps artifact
uses: actions/download-artifact@v3
with:
name: deps-${{ inputs.openfoam-version }}-${{ runner.arch }}
path: build
- name: Use deps artifact
run: |
touch -c build/*-deps.sparsebundle
- name: Cache build
if: inputs.cache
uses: actions/cache@v3
with:
path: |
build/*.dmg
key: dmg-${{ inputs.openfoam-version }}-${{ runner.arch }}-${{ hashFiles('Brewfile', 'configure.sh', 'icon.icns', 'Makefile', format('OpenFOAM-v${0}.tgz.sha256', inputs.openfoam-version)) }}
- name: Reuse cached DMG if possible
path: build/*-build.sparsebundle
key: build-${{ inputs.openfoam-version }}-${{ runner.arch }}-${{ hashFiles('build/*-deps.sparsebundle', 'configure.sh', 'Makefile', format('OpenFOAM-v${0}.tgz.sha256', inputs.openfoam-version)) }}
- name: Reuse cached build if possible
run: |
touch -c build/*.dmg
touch -c build/*-build.sparsebundle
- name: Build
run: >
make zip
make build
OPENFOAM_VERSION=${{ inputs.openfoam-version }}
${{ inputs.source-tarball-url != '' && format('SOURCE_TARBALL_URL={0}', inputs.source-tarball-url) || '' }}
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ inputs.openfoam-version }}-${{ runner.arch }}
path: build/*-build.sparsebundle
if-no-files-found: error

app:
needs: build
strategy:
matrix:
dependencies-kind: [standalone, homebrew]
fail-fast: false
runs-on: macos-10.15
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build-${{ inputs.openfoam-version }}-${{ runner.arch }}
path: build
- name: Use build artifact
run: |
touch -c build/*-build.sparsebundle
- name: Build zipped app
run: >
make zip
APP_VERSION=${{ inputs.app-version }}
DEPENDENCIES_KIND=${{ matrix.dependencies-kind }}
OPENFOAM_VERSION=${{ inputs.openfoam-version }}
${{ inputs.source-tarball-url != '' && format('SOURCE_TARBALL_URL={0}', inputs.source-tarball-url) || '' }}
- name: Upload ZIP artifact
- name: Upload zip artifact
uses: actions/upload-artifact@v3
with:
name: zip-${{ inputs.openfoam-version }}
name: zip-${{ inputs.openfoam-version }}-${{ matrix.dependencies-kind }}-${{ runner.arch }}
path: build/*-app-*.zip
if-no-files-found: error

test:
needs: build
needs: app
strategy:
matrix:
os: [macos-10.15, macos-11, macos-12]
dependencies-kind: [standalone, homebrew]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -65,31 +130,41 @@ jobs:
- name: Download ZIP artifact
uses: actions/download-artifact@v3
with:
name: zip-${{ inputs.openfoam-version }}
name: zip-${{ inputs.openfoam-version }}-${{ matrix.dependencies-kind }}-${{ runner.arch }}
path: build
- name: Unzip app
run: |
unzip *-app-homebrew-$(uname -m).zip
unzip *-app-*.zip
working-directory: build
- name: Test
- name: Install Homebrew dependencies
if: matrix.dependencies-kind == 'homebrew'
run: |
make install-dependencies OPENFOAM_VERSION=${{ inputs.openfoam-version }}
make test OPENFOAM_VERSION=${{ inputs.openfoam-version }}
brew bundle --verbose
- name: Test
run: >
make test
APP_VERSION=${{ inputs.app-version }}
OPENFOAM_VERSION=${{ inputs.openfoam-version }}
DEPENDENCIES_KIND=${{ matrix.dependencies-kind }}
release:
if: ${{ inputs.release }}
needs: test
if: inputs.release
runs-on: ubuntu-latest
strategy:
matrix:
dependencies-kind: [standalone, homebrew]
fail-fast: false
steps:
- name: Download ZIP artifact
- name: Download zip artifact
uses: actions/download-artifact@v3
with:
name: zip-${{ inputs.openfoam-version }}
- name: Upload ZIP to release
name: zip-${{ inputs.openfoam-version }}-${{ matrix.dependencies-kind }}-${{ runner.arch }}
- name: Upload zip to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: '*.zip'
file: '*-app-*.zip'
tag: ${{ github.ref }}
file_glob: true
overwrite: false
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

openfoam2206:
needs: get-version
name: OpenFOAM-v2206.app
name: OpenFOAM v2206
uses: ./.github/workflows/build-test.yml
with:
openfoam-version: 2206
Expand All @@ -27,7 +27,7 @@ jobs:

openfoam2112:
needs: get-version
name: OpenFOAM-v2112.app
name: OpenFOAM v2112
uses: ./.github/workflows/build-test.yml
with:
openfoam-version: 2112
Expand Down
4 changes: 2 additions & 2 deletions Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleVersion</key>
<string>{{APP_VERSION}}-homebrew-{{ARCH}}</string>
<string>{{APP_VERSION}}-{{DEPENDENCIES_KIND}}-{{ARCH}}</string>
<key>CFBundleShortVersionString</key>
<string>{{APP_VERSION}}</string>
</dict>
</plist>
</plist>
6 changes: 4 additions & 2 deletions Contents/MacOS/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ SCRIPT_DIR="$(\cd $(dirname ${BASH_SOURCE:-${ZSH_NAME:+$0}}) && \pwd -L)"

VOLUME=`"$SCRIPT_DIR/volume" -show-prefix`

# Keep the volume directory open in this process (prevents accidental ejection)
exec {fd}<"$VOLUME"
if [ ${BASH_VERSINFO:-4} -ge 4 ]; then
# Keep the volume directory open in this process (prevents accidental ejection)
exec {fd}<"$VOLUME"
fi

. "$VOLUME/etc/bashrc"
2 changes: 1 addition & 1 deletion Contents/MacOS/openfoam
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ VOLUME=$("$APP_BUNDLE/Contents/MacOS/volume" -show-prefix)
exec {fd}<"$VOLUME"

echo "Activating the OpenFOAM environment..."
exec bash "$VOLUME/etc/openfoam" "$@"
PATH="$VOLUME/usr/bin:$PATH" exec bash "$VOLUME/etc/openfoam" "$@"
2 changes: 1 addition & 1 deletion Contents/MacOS/volume
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ case "$1" in
$QUIET || echo "The $APP_NAME volume is already mounted."
else
$QUIET || echo "Mounting the $APP_NAME volume..."
if ! hdiutil attach -quiet "$DMG_FILE"; then
if ! hdiutil attach -quiet -noverify "$DMG_FILE"; then
echo "ERROR: Failed to mount the $APP_NAME volume" 1>&2
exit 1
fi
Expand Down
Loading

0 comments on commit 53903a1

Please sign in to comment.