Skip to content

Commit

Permalink
Merge pull request #14 from psibi/master
Browse files Browse the repository at this point in the history
Add static binary as part of releases
  • Loading branch information
snoyberg committed Nov 29, 2022
2 parents ac768eb + a5f2bfd commit 2dd4f32
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
24 changes: 14 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2dd4f32

Please sign in to comment.