Skip to content

Commit d043288

Browse files
authored
Merge pull request #10 from cryptosense/docker
Add release script
2 parents a81e095 + 9b5bc08 commit d043288

File tree

9 files changed

+95
-50
lines changed

9 files changed

+95
-50
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**/.merlin
2+
**/_build
3+
4+
.git
5+
.github
6+
docker
7+
make_release.bash

.travis-release.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ARG DISTRIB
2+
FROM ocaml/opam2:${DISTRIB} as code
3+
4+
# Set up user
5+
ENV PATH "/home/opam/.local/bin:$PATH"
6+
7+
# Set up OCaml and OPAM
8+
ARG OCAML_VERSION
9+
RUN opam update \
10+
&& opam switch $OCAML_VERSION
11+
RUN opam repository set-url default https://opam.ocaml.org/
12+
13+
RUN mkdir /home/opam/workdir
14+
WORKDIR /home/opam/workdir
15+
COPY --chown=opam cs_api_client.opam .
16+
RUN opam update \
17+
&& opam pin add cs_api_client.dev . --no-action \
18+
&& opam depext cs_api_client --yes --update --with-doc --with-test \
19+
&& opam install . --deps-only --with-doc --with-test
20+
COPY --chown=opam . .
21+
ARG VERSION
22+
RUN ./ci/subst.bash "$VERSION" \
23+
&& opam exec -- dune build @all @runtest

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,12 @@ For more advanced configuration, please refer to the `curl` documentation.
5252

5353
* Install the binary client from source: `dune build @install && dune install`
5454
* Run tests: `dune runtest`
55+
56+
## Release
57+
58+
* Create a tag:
59+
* `git tag --message 'Version 1.2.3' 1.2.3`
60+
* `git push --tags`
61+
* Create a release on GitHub for the new tag.
62+
* Run `./make_release.bash 1.2.3 .`
63+
* Upload `cs-api-1.2.3.tar.gz` to the GitHub release.

ci/build.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

ci/subst.bash

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -o errexit
3+
set -o pipefail
4+
set -o nounset
5+
6+
log() {
7+
local name="$(basename "$0")"
8+
echo -e "\033[36;1m[${name%.*}] $*\033[0m" > /dev/stderr
9+
}
10+
11+
main() {
12+
local version=$1; shift
13+
14+
find . -type f -name '*.ml' -exec sed --in-place "s/%%VERSION_NUM%%/$version/g" {} +
15+
}
16+
17+
version=$1
18+
main "$version"

ci/test.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

make_release.bash

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -o errexit
3+
set -o nounset
4+
set -o pipefail
5+
6+
main() {
7+
local version=$1; shift
8+
local dest=$1; shift
9+
10+
local image_tag="cs-api"
11+
local container_name="cs-api"
12+
13+
local tmp=$(mktemp --directory)
14+
local archive="cs-api-$version"
15+
mkdir "$tmp/$archive"
16+
17+
docker build \
18+
--build-arg DISTRIB=centos-7 \
19+
--build-arg OCAML_VERSION=4.10 \
20+
--build-arg VERSION=$version \
21+
--tag "$image_tag" \
22+
.
23+
docker create --name "$container_name" "$image_tag"
24+
docker cp \
25+
--follow-link \
26+
"$container_name:/home/opam/workdir/_build/install/default/bin/cs-api" \
27+
"$tmp/$archive/cs-api"
28+
docker rm "$container_name"
29+
30+
chmod 755 "$tmp/$archive/cs-api"
31+
(cd "$tmp" && tar pcvzf "$archive.tar.gz" "$archive")
32+
mv "$tmp/$archive.tar.gz" "$dest/"
33+
rm -rf "$tmp"
34+
}
35+
36+
version=$1; shift
37+
dest=$1; shift
38+
main "$version" "$dest"

0 commit comments

Comments
 (0)