babashka/.github/workflows/deploy.yml
2020-03-29 16:07:30 +02:00

176 lines
5.3 KiB
YAML

name: deploy
# on:
# push:
# tags:
# - "*.*.*"
on: [push
# , pull_request
]
jobs:
uberjar:
runs-on: ubuntu-18.04
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
submodules: 'true'
- name: Parse Ref
id: parse-ref
run: |
export VERSION="$(echo $GITHUB_SHA | head -c 7)"
echo "##[set-output name=version;]${VERSION}"
echo "##[set-output name=name;]babashka-${VERSION}"
- name: Cache deps
uses: actions/cache@v1
id: cache-deps
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }} # Other deps files?
restore-keys: |
${{ runner.os }}-maven-
- name: Fetch deps
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
lein deps
- name: Build into uberjar
run: |
echo ${{ steps.parse-ref.outputs.version }} > resources/BABASHKA_VERSION
lein uberjar
- uses: actions/upload-artifact@v1
with:
path: target/${{ steps.parse-ref.outputs.name }}-standalone.jar
name: jar
- name: reflection.json
run: |
lein with-profiles +reflection run
- uses: actions/upload-artifact@v1
with:
name: reflection.json
path: reflection.json
# Initial task to compile a JAR, store as a pipeline artifact to be used by
# downstream builders.
native-image-linux:
needs: [uberjar]
runs-on: ubuntu-18.04
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
submodules: 'true'
- uses: actions/download-artifact@v1
with:
name: jar
path: .
- uses: actions/download-artifact@v1
with:
name: reflection.json
path: .
- name: Parse Ref
id: parse-ref
run: |
export VERSION="$(echo $GITHUB_SHA | head -c 7)"
export BASE=babashka-${VERSION}
echo "##[set-output name=base;]${BASE}"
echo "##[set-output name=name;]${BASE}-linux"
# Look up at releases here https://github.com/graalvm/graalvm-ce-builds/releases
- name: Prepare GraalVM
uses: DeLaGuardo/setup-graalvm@2.0
with:
graalvm-version: "20.0.0.java8"
# Newer versions don't work yet
# graalvm-version: "19.3.1.java8"
# graalvm-version: "20.0.0.java8"
- name: Build Linux native image
run: |
echo "native image at $(which gu)"
export GRAALVM_DEBUG=1 # Seems to work (not ideal, can give runtime errors)
export JAR=${{ steps.parse-ref.outputs.base }}-standalone.jar
export BINARY_NAME=${{ steps.parse-ref.outputs.name }}
script/compile
- name: Test binary
run: |
export BINARY=./${{ steps.parse-ref.outputs.name }}
$BINARY -e '(println "OK")'
- run: tar -cvzf ${{ steps.parse-ref.outputs.name }}.tgz ./${{ steps.parse-ref.outputs.name }}
- uses: actions/upload-artifact@v1
with:
path: ${{ steps.parse-ref.outputs.name }}.tgz
name: binary-linux
# Use GraalVM on macOS to convert JAR to a native macOS binary
native-image-mac:
needs: [uberjar, native-image-linux] # Make it wait for a succesful Linux build as that one runs faster (because of a queue somewhere?). Is also more expensive.
runs-on: macOS-latest
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
submodules: 'true'
- uses: actions/download-artifact@v1
with:
name: jar
path: .
- uses: actions/download-artifact@v1
with:
name: reflection.json
path: .
- name: Parse Ref
id: parse-ref
run: |
export VERSION="$(echo $GITHUB_SHA | head -c 7)"
export BASE=babashka-${VERSION}
echo "##[set-output name=base;]${BASE}"
echo "##[set-output name=name;]${BASE}-mac"
# Look up at releases here https://github.com/graalvm/graalvm-ce-builds/releases
- name: Prepare GraalVM
uses: DeLaGuardo/setup-graalvm@2.0
with:
graalvm-version: "20.0.0.java8"
# graalvm-version: "19.3.1.java8"
- name: Build Mac native image
run: |
echo "native image at $(which gu)"
export GRAALVM_DEBUG=1 # Seems to work (not ideal, can give runtime errors)
export JAR=${{ steps.parse-ref.outputs.base }}-standalone.jar
export BINARY_NAME=${{ steps.parse-ref.outputs.name }}
script/compile
- name: Test binary
run: |
export BINARY=./${{ steps.parse-ref.outputs.name }}
$BINARY -e '(println "OK")'
- run: tar -cvzf ${{ steps.parse-ref.outputs.name }}.tgz ./${{ steps.parse-ref.outputs.name }}
- uses: actions/upload-artifact@v1
with:
path: ${{ steps.parse-ref.outputs.name }}.tgz
name: binary-mac