Skip to content

Commit e0edf6f

Browse files
authored
CI for homebrew binary formula (#108)
* Create homebrew formula for installing mac binary * Ignore gh-pages branch * Fix binary path * Add test for formula. * Correct working directory * Correct copy command * Correct git commands * Add write deploy key for homebrew tap. * Test the local formula before push * Rejig to depend on release. Remainder must be developed and released on master
1 parent 4a30af0 commit e0edf6f

File tree

2 files changed

+106
-8
lines changed

2 files changed

+106
-8
lines changed

.circleci/config.yml

+74-8
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
###########################################
149149
# Copy release binaries to GitHub release #
150150
###########################################
151-
release:
151+
draft-release:
152152

153153
docker:
154154
- image: circleci/python:3.7.1-stretch
@@ -305,44 +305,110 @@ jobs:
305305
paths:
306306
- '*'
307307

308+
################################################################
309+
# Create homebrew formula for the mac binary and commit to tap #
310+
################################################################
311+
update-homebrew:
312+
macos:
313+
xcode: "10.1.0"
314+
environment:
315+
HOMEBREW_NO_INSTALL_CLEANUP: 1
316+
steps:
317+
- add_ssh_keys:
318+
fingerprints:
319+
- "2d:94:c7:5f:ed:59:aa:61:e0:9c:60:64:45:b0:bc:86"
320+
- attach_workspace:
321+
at: /tmp/workspace
322+
- run:
323+
name: install the binary as /tmp/eu
324+
command: |
325+
cp /tmp/workspace/binaries/eucalypt-x86_64-osx.tgz /tmp
326+
cd /tmp
327+
tar xvzf /tmp/eucalypt-x86_64-osx.tgz
328+
chmod +x /tmp/eu
329+
/tmp/eu -e eu.build
330+
- checkout
331+
- run: |
332+
cd ci
333+
cp /tmp/workspace/package.yaml .
334+
shasum -a 256 /tmp/workspace/binaries/eucalypt-x86_64-osx.tgz > eucalypt-x86_64-osx.tgz.sha
335+
/tmp/eu eucalypt.rb.eu > eucalypt.rb
336+
cat eucalypt.rb
337+
cp eucalypt.rb /tmp/workspace/
338+
- run:
339+
name: Checkout homebrew-tap
340+
command: |
341+
cd /tmp
342+
git clone [email protected]:curvelogic/homebrew-tap.git
343+
cp /tmp/workspace/eucalypt.rb homebrew-tap/Formula/eucalypt.rb
344+
cd homebrew-tap
345+
git status
346+
git add Formula/eucalypt.rb
347+
/tmp/eu --version | git commit -F -
348+
- run:
349+
name: Test formula
350+
command: |
351+
brew install /tmp/homebrew-tap/Formula/eucalypt.rb
352+
eu -e eu.build
353+
eu -e eu.build > a.txt
354+
/tmp/eu -e eu.build > b.txt
355+
diff -q a.txt b.txt
356+
- run:
357+
name: git push
358+
command: |
359+
cd /tmp
360+
git push
361+
308362
309363
workflows:
310364
version: 2
311365
build-workflow:
312366
jobs:
313367
- build-test-harness:
314368
context: curvelogic-docker-hub
369+
filters: { branches: { ignore: [ "gh-pages" ]}}
315370
- build:
316371
context: curvelogic-docker-hub
372+
filters: { branches: { ignore: [ "gh-pages" ]}}
317373
- acceptance:
318374
context: curvelogic-docker-hub
319375
requires:
320376
- build
321377
- build-test-harness
378+
filters: { branches: { ignore: [ "gh-pages" ]}}
322379
- benchmark:
323380
context: curvelogic-docker-hub
324381
requires:
325382
- build
326383
- build-test-harness
384+
filters: { branches: { ignore: [ "gh-pages" ]}}
327385
- profile:
328386
context: curvelogic-docker-hub
329387
requires:
330388
- build
389+
filters: { branches: { ignore: [ "gh-pages" ]}}
331390
- build-mac-binary:
332391
requires:
333392
- build
334-
- release:
393+
filters: { branches: { ignore: [ "gh-pages" ]}}
394+
- draft-release:
335395
context: curvelogic-github-api
336396
requires:
337397
- acceptance
338398
- build-mac-binary
339-
filters:
340-
branches:
341-
only: master
399+
filters: { branches: { only: [ "master" ]}}
342400
- deploy-docs:
343401
context: curvelogic-github-api
344402
requires:
345403
- acceptance
346-
filters:
347-
branches:
348-
only: master
404+
filters: { branches: { only: [ "master" ]}}
405+
- publish-release:
406+
type: approval
407+
requires:
408+
- draft-release
409+
filters: { branches: { ignore: [ "gh-pages" ]}}
410+
- update-homebrew:
411+
requires:
412+
- build-mac-binary
413+
- publish-release
414+
filters: { branches: { only: [ "master" ]}}

ci/eucalypt.rb.eu

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env eu
2+
3+
{ import: ["package=package.yaml"
4+
,"sha=text@eucalypt-x86_64-osx.tgz.sha"] }
5+
6+
nest-in(pre, post, lines):
7+
{ content: lines map(" {}") }.(["", pre] ++ content ++ [post, ""])
8+
9+
q: ch.dq
10+
11+
hash: sha head str.extract("^(\S+)\s.*$")
12+
13+
metadata: {
14+
version: package.version
15+
desc: "Eucalypt (eu) tool for generating, templating and processing YAML, JSON, TOML"
16+
homepage: "https://curvelogic.github.io/eucalypt/"
17+
url: "https://github.com/curvelogic/eucalypt/releases/download/{version}/eucalypt-x86_64-osx.tgz"
18+
sha256: hash
19+
} map-kv("{0} {q}{1}{q}")
20+
21+
bottle: ["bottle :unneeded"]
22+
23+
install: nest-in("def install", "end", ["bin.install {q}eu{q}"])
24+
25+
test: [ "expected = {q}Eucalypt (Haskell Impl: v#{{package.version}}){q}"
26+
, "assert_equal expected, `#{{bin}}/eu --version`.strip"]
27+
nest-in("def test", "end")
28+
29+
` { target: :main format: :text }
30+
main:
31+
(metadata ++ bottle ++ install ++ test)
32+
nest-in("class Eucalypt < Formula", "end")

0 commit comments

Comments
 (0)