-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.yml
95 lines (91 loc) · 3.11 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Default configuration shared between jobs
defaults: &defaults
working_directory: ~/docker-hunspell-wasm
docker:
- image: circleci/golang:1.10.3-stretch-browsers
version: 2
jobs:
# Jobs for building wasm binary for hunspell
build:
<<: *defaults
steps:
- setup_remote_docker
- checkout
- run:
name: Generate build artifact location
command: mkdir -p ~/build
- run:
name: Build docker image for hunspell 1.6.2
command: |
BRANCH=v1.6.2
TARGET=wasm
# Build docker image, specify commit sha of hunspell
docker build -t hunspell-wasm-$CIRCLE_BUILD_NUM --build-arg BRANCH=$BRANCH --build-arg TARGET=$TARGET .
- run:
name: Build wasm binary for node environment
command: |
ENVIRONMENT=node
# Run built docker image
docker run --name $CIRCLE_BUILD_NUM$ENVIRONMENT -t hunspell-wasm-$CIRCLE_BUILD_NUM /bin/bash -l -c "./build.sh -o /out/hunspell_$ENVIRONMENT.js -s ENVIRONMENT=$ENVIRONMENT"
# Copy build output
docker cp $CIRCLE_BUILD_NUM$ENVIRONMENT:/out ~/build
- run:
name: Build wasm binary for web environment
command: |
ENVIRONMENT=web,worker
# Run built docker image
docker run --name $CIRCLE_BUILD_NUM-web -t hunspell-wasm-$CIRCLE_BUILD_NUM /bin/bash -l -c "./build.sh -o /out/hunspell_browser.js -s ENVIRONMENT=$ENVIRONMENT"
# Copy build output
docker cp $CIRCLE_BUILD_NUM-web:/out ~/build
- run:
working_directory: ~/build
name: Copy artifacts
command: |
# File copied from docker container has root access only, modify permission
sudo chmod -R go+wr ~/build
# Generate hash
for filename in ./out/*; do
sha512sum $filename > $filename.sha512
done
# Generate archive for convinience
tar -zcvf ./hunspell-asm-$(echo $CIRCLE_SHA1 | cut -c -7).tar.gz out
# Flatten file out path
mv ./out/* ./ && rm -rf ./out
# Upload artifact into CircleCi artifacts
- store_artifacts:
path: ~/build
destination: build
# Persist build results to share between different jobs
- persist_to_workspace:
root: ~/build
paths:
- ./*
# Jobs to create github release for tagged build
release:
<<: *defaults
steps:
# Acquire persisted build results
- attach_workspace:
at: ~/build
- run:
name: Create Release
command: |
go get github.com/tcnksm/ghr
ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME -replace $CIRCLE_TAG ~/build
workflows:
version: 2
default:
jobs:
- build:
filters:
tags:
only: /.*/
- release:
# Filter jobs to run on tag only
filters:
branches:
ignore: /.*/
tags:
only: /.*/
requires:
- build