diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fdec1e..18a7452 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,9 @@ jobs: uses: actions/checkout@v2 with: submodules: 'true' - + - uses: extractions/setup-just@v1 + with: + just-version: 1.1.3 - name: Cache dependencies uses: actions/cache@v2 with: @@ -44,3 +46,9 @@ jobs: set -exuo pipefail curl -sSL https://get.haskellstack.org/ | sh -s - -f stack test --fast --no-terminal --stack-yaml=${{ matrix.stack-yaml }} --resolver=${{ matrix.resolver }} + - name: Static Binary check + shell: bash + run: | + set -exuo pipefail + just copy-static-pid1 + just test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index faa8d69..ecda934 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,14 +13,18 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: extractions/setup-just@v1 with: - tag_name: ${{ github.ref }} - release_name: pid1-${{ github.ref }} - body_path: ChangeLog.md - draft: false - prerelease: false + just-version: 1.1.3 + - name: Static Binary Generation + shell: bash + run: | + set -exuo pipefail + just copy-static-pid1 + just test + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: pid1 + generate_release_notes: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..14e9ca0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM fpco/alpine-haskell-stack:9.2.5 + +COPY . /app + +RUN apk add upx \ + && env STACK_YAML=/app/stack.yaml stack --system-ghc install --local-bin-path /app --flag pid1:static \ + && upx --best /app/pid1 diff --git a/justfile b/justfile new file mode 100644 index 0000000..50fc79a --- /dev/null +++ b/justfile @@ -0,0 +1,21 @@ +# List all recipies +default: + just --list --unsorted + +# Build image +build-image: + docker build --file Dockerfile . --tag pid1 + +# Copy static binary from container +copy-static-pid1: build-image + #!/usr/bin/env bash + set -euo pipefail + CID=$(docker create pid1) + docker cp ${CID}:/app/pid1 . + docker rm ${CID} + ls -lah pid1 + +# Sanity test the binary +test: + file ./pid1 + ./pid1 -- ps