Skip to content

Commit

Permalink
refactor: ci prod pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
joseluisq committed Dec 14, 2020
1 parent 49d61de commit 6c5b374
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*

!bin/paket
!docker/alpine/entrypoint.sh
!bin/**
25 changes: 14 additions & 11 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,38 +104,41 @@ steps:
auto_tag_aliases:
- latest

- name: release-darwin
image: joseluisq/rust-linux-darwin-builder:1.48.0
commands:
- make prod.release.darwin

- name: release-archive-linux
image: joseluisq/drone-archive
settings:
format: tar
src_base_path: ./target/x86_64-unknown-linux-musl/release
src_base_path: ./bin/x86_64-unknown-linux-musl
src: ./paket
dest: ./release/paket-${DRONE_TAG}-x86_64-unknown-linux-musl.tar.gz
checksum: true
checksum_algo: sha256
checksum_dest: ./release/paket-${DRONE_TAG}.SHA256SUM
checksum_dest: ./release/paket-${DRONE_TAG}-x86_64-unknown-linux-musl-SHA256SUM

- name: release-darwin
image: joseluisq/rust-linux-darwin-builder:1.48.0
commands:
- make prod.release.darwin

- name: release-archive-darwin
image: joseluisq/drone-archive
settings:
format: zip
src_base_path: ./target/x86_64-apple-darwin/release
src_base_path: ./bin/x86_64-apple-darwin
src: ./paket
dest: ./release/paket-${DRONE_TAG}-x86_64-apple-darwin.zip
checksum: true
checksum_algo: sha256
checksum_dest: ./release/paket-${DRONE_TAG}.SHA256SUM
checksum_dest: ./release/paket-${DRONE_TAG}-x86_64-apple-darwin-SHA256SUM

- name: release-archive-check
image: alpine:3.12
commands:
- du -sh ./release/*
- sha256sum -c ./release/*-SHA256SUM
- cd ./release
- cat paket-${DRONE_TAG}-x86_64-unknown-linux-musl-SHA256SUM paket-${DRONE_TAG}-x86_64-apple-darwin-SHA256SUM > paket-${DRONE_TAG}-x86_64-SHA256SUM
- rm -rf paket-${DRONE_TAG}-x86_64-apple-darwin-SHA256SUM
- rm -rf paket-${DRONE_TAG}-x86_64-unknown-linux-musl-SHA256SUM
- sha256sum -c *SHA256SUM

- name: github-release
image: plugins/github-release
Expand Down
29 changes: 18 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@ PKG_TARGET_DARWIN=x86_64-apple-darwin
RUST_VERSION ?= $(shell rustc --version | cut -d ' ' -f2)

PKG_BIN_PATH=./bin
PKG_TMP_PATH=/tmp

PKG_NAME=$(shell cat Cargo.toml | sed -n 's/name = "\([^}]*\)"/\1/p' | head -n1)
PKG_TAG=$(shell cat Cargo.toml | sed -n 's/version = "\([^}]*\)"/\1/p' | head -n1)

PKG_RELEASE_NAME=$(PKG_NAME)-v$(PKG_TAG)-$(PKG_TARGET)
PKG_RELEASE_NAME_DARWIN=$(PKG_NAME)-v$(PKG_TAG)-$(PKG_TARGET_DARWIN)

PKG_TMP_BIN_PATH=$(PKG_TMP_PATH)/$(PKG_RELEASE_NAME)
PKG_TMP_BIN_PATH_DARWIN=$(PKG_TMP_PATH)/$(PKG_RELEASE_NAME_DARWIN)


run:
@echo "Running application..."
@rustc -vV
Expand Down Expand Up @@ -47,6 +39,18 @@ docker.run:
@docker run -it --rm joseluisq/paket:latest -h
.PHONY: docker.run

pipeline-prod:
@drone exec \
--trusted \
--privileged \
--event=tag \
--exclude=test \
--exclude=publish-linux-local \
--exclude=publish-linux-dockerhub \
--exclude=github-release \
--pipeline=production
.PHONY: pipeline-prod


#######################################
########## Production tasks ###########
Expand All @@ -59,10 +63,11 @@ prod.release.linux:
@cargo build --release --target $(PKG_TARGET)
@du -sh ./target/$(PKG_TARGET)/release/$(PKG_NAME)

@echo "Shrinking binary release..."
@echo "Shrinking release binary..."
@strip ./target/$(PKG_TARGET)/release/$(PKG_NAME)
@du -sh ./target/$(PKG_TARGET)/release/$(PKG_NAME)
@./target/$(PKG_TARGET)/release/$(PKG_NAME) --help
@mkdir -p $(PKG_BIN_PATH)/$(PKG_TARGET)/
@cp ./target/$(PKG_TARGET)/release/$(PKG_NAME) $(PKG_BIN_PATH)/$(PKG_TARGET)/
.PHONY: prod.release.linux

prod.release.darwin:
Expand All @@ -71,7 +76,9 @@ prod.release.darwin:
@cargo build --release --target $(PKG_TARGET_DARWIN)
@du -sh ./target/$(PKG_TARGET_DARWIN)/release/$(PKG_NAME)

@echo "Shrinking binary release..."
@echo "Shrinking release binary..."
@x86_64-apple-darwin15-strip ./target/$(PKG_TARGET_DARWIN)/release/$(PKG_NAME)
@du -sh ./target/$(PKG_TARGET_DARWIN)/release/$(PKG_NAME)
@mkdir -p $(PKG_BIN_PATH)/$(PKG_TARGET_DARWIN)/
@cp ./target/$(PKG_TARGET_DARWIN)/release/$(PKG_NAME) $(PKG_BIN_PATH)/$(PKG_TARGET_DARWIN)/
.PHONY: prod.release.darwin
2 changes: 1 addition & 1 deletion docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN set -eux \
&& true

COPY ./docker/alpine/entrypoint.sh /
COPY ./target/x86_64-unknown-linux-musl/release/paket /usr/local/bin/
COPY ./bin/x86_64-unknown-linux-musl/paket /usr/local/bin/

ENTRYPOINT ["/entrypoint.sh"]

Expand Down

0 comments on commit 6c5b374

Please sign in to comment.