a container image capable of building tiempo consistently

This commit is contained in:
Abraham Toriz 2022-11-26 01:07:47 -06:00
parent 2dc6cda4f2
commit 1e68467d36
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
6 changed files with 71 additions and 31 deletions

3
.gitignore vendored
View File

@ -5,3 +5,6 @@
docs/*/build/
dev_config.toml
Pipfile*
artifacts/
build/
debian-package/

View File

@ -26,7 +26,6 @@ build-doc:
- gzip build/man/tiempo.1
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_TAG =~ /^v*/
artifacts:
paths:
- docs/build/html
@ -46,37 +45,9 @@ publish-doc:
build:
stage: build
image: categulario/rust-cli-image:latest
image: categulario/tiempo-build-env:1.65
script:
# build the binary
- cargo build --locked --release
# create the tar package
- mkdir -p build/bin build/share/doc/tiempo build/share/man/man1 build/share/bash-completion/completions build/share/zsh/site-functions build/share/fish/vendor_completions.d
# move binary
- cp target/release/t build/bin/
# move documentation
- cp CHANGELOG.md build/share/doc/tiempo/
- cp README.md build/share/doc/tiempo/
- cp LICENSE build/share/doc/tiempo/
- cp -R docs/build/html build/share/doc/tiempo/
# move man page
- cp docs/build/man/tiempo.1.gz build/share/man/man1/
# move completions
- cp completions/bash/t build/share/bash-completion/completions/
- cp completions/fish/t.fish build/share/fish/vendor_completions.d/
- cp completions/zsh/_t build/share/zsh/site-functions/
# compress the tar file
- tar -cvzf tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz build/
# makes the debian archive
- ./debpackage.sh
# computes the sums
- sha256sum tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz > tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz.sum
- sha256sum debian-package/tiempo_${CI_COMMIT_TAG:1}_amd64.deb > tiempo_${CI_COMMIT_TAG:1}_amd64.deb.sum
- mkdir artifacts
- mv tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz artifacts/
- mv debian-package/tiempo_${CI_COMMIT_TAG:1}_amd64.deb artifacts/
- mv tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz.sum artifacts/
- mv tiempo_${CI_COMMIT_TAG:1}_amd64.deb.sum artifacts/
- ./scripts/build.sh
artifacts:
paths:
- artifacts/

12
Containerfile Normal file
View File

@ -0,0 +1,12 @@
# This Containerfile builds the tiempo-build-env container image used to build
# tiempo in CI and local environments.
FROM docker.io/rust:1.65
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
fakeroot \
python3-minimal \
python3-sphinx \
python3-tomlkit \
&& apt-get -q clean \
&& rm -rf /var/lib/apt/lists/*

View File

@ -109,6 +109,20 @@ The contents of the man page are located in `docs/source/index.rst`,
formatted as
[reStructuredText](https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html).
### Building the packages like in CI but locally
First pull the image:
podman pull tiempo-build-env
Or build it yourself from this repo:
podman build -t tiempo-build-env .
Then build the packages:
podman run -it --rm -w /app -v ./:/app -e CI_COMMIT_TAG=v2.0.0 tiempo-build-env ./scripts/build.sh
## Special Thanks
To [timetrap](https://github.com/samg/timetrap) for existing, to

40
scripts/build.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
# Fail if any of the commands fail
set -e
# Build the docs
cd docs/
make man
gzip -f build/man/tiempo.1
cd ..
# build the binary
cargo build --locked --release
# create the tar package
mkdir -p build/bin build/share/doc/tiempo build/share/man/man1 build/share/bash-completion/completions build/share/zsh/site-functions build/share/fish/vendor_completions.d
# move binary
cp target/release/t build/bin/
# move documentation
cp CHANGELOG.md build/share/doc/tiempo/
cp README.md build/share/doc/tiempo/
cp LICENSE build/share/doc/tiempo/
# move man page
cp docs/build/man/tiempo.1.gz build/share/man/man1/
# move completions
cp completions/bash/t build/share/bash-completion/completions/
cp completions/fish/t.fish build/share/fish/vendor_completions.d/
cp completions/zsh/_t build/share/zsh/site-functions/
# compress the tar file
tar -cvzf tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz build/
# makes the debian archive
./scripts/debpackage.sh
# computes the sums
sha256sum tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz > tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz.sum
sha256sum debian-package/tiempo_${CI_COMMIT_TAG:1}_amd64.deb > tiempo_${CI_COMMIT_TAG:1}_amd64.deb.sum
mkdir -p artifacts
mv tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz artifacts/
mv debian-package/tiempo_${CI_COMMIT_TAG:1}_amd64.deb artifacts/
mv tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz.sum artifacts/
mv tiempo_${CI_COMMIT_TAG:1}_amd64.deb.sum artifacts/