Skip to content

Commit 2dd4f32

Browse files
authored
Merge pull request #14 from psibi/master
Add static binary as part of releases
2 parents ac768eb + a5f2bfd commit 2dd4f32

File tree

4 files changed

+51
-11
lines changed

4 files changed

+51
-11
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ jobs:
2727
uses: actions/checkout@v2
2828
with:
2929
submodules: 'true'
30-
30+
- uses: extractions/setup-just@v1
31+
with:
32+
just-version: 1.1.3
3133
- name: Cache dependencies
3234
uses: actions/cache@v2
3335
with:
@@ -44,3 +46,9 @@ jobs:
4446
set -exuo pipefail
4547
curl -sSL https://get.haskellstack.org/ | sh -s - -f
4648
stack test --fast --no-terminal --stack-yaml=${{ matrix.stack-yaml }} --resolver=${{ matrix.resolver }}
49+
- name: Static Binary check
50+
shell: bash
51+
run: |
52+
set -exuo pipefail
53+
just copy-static-pid1
54+
just test

.github/workflows/release.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ jobs:
1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v2
16-
- name: Create Release
17-
id: create_release
18-
uses: actions/create-release@v1
19-
env:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
- uses: extractions/setup-just@v1
2117
with:
22-
tag_name: ${{ github.ref }}
23-
release_name: pid1-${{ github.ref }}
24-
body_path: ChangeLog.md
25-
draft: false
26-
prerelease: false
18+
just-version: 1.1.3
19+
- name: Static Binary Generation
20+
shell: bash
21+
run: |
22+
set -exuo pipefail
23+
just copy-static-pid1
24+
just test
25+
- name: Release
26+
uses: softprops/action-gh-release@v1
27+
if: startsWith(github.ref, 'refs/tags/')
28+
with:
29+
files: pid1
30+
generate_release_notes: true

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM fpco/alpine-haskell-stack:9.2.5
2+
3+
COPY . /app
4+
5+
RUN apk add upx \
6+
&& env STACK_YAML=/app/stack.yaml stack --system-ghc install --local-bin-path /app --flag pid1:static \
7+
&& upx --best /app/pid1

justfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# List all recipies
2+
default:
3+
just --list --unsorted
4+
5+
# Build image
6+
build-image:
7+
docker build --file Dockerfile . --tag pid1
8+
9+
# Copy static binary from container
10+
copy-static-pid1: build-image
11+
#!/usr/bin/env bash
12+
set -euo pipefail
13+
CID=$(docker create pid1)
14+
docker cp ${CID}:/app/pid1 .
15+
docker rm ${CID}
16+
ls -lah pid1
17+
18+
# Sanity test the binary
19+
test:
20+
file ./pid1
21+
./pid1 -- ps

0 commit comments

Comments
 (0)