Skip to content
Snippets Groups Projects
Commit 141ef541 authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'ci-win64-build' into 'dev'

CI build release for windows 64 bits

See merge request !80
parents 1c52b40b d939787a
No related branches found
Tags 0.1.0-a0.1
1 merge request!80CI build release for windows 64 bits
stages:
- build_and_tests
- fmt
- tests
- clippy
- publish_crate
- publish_doc
......@@ -11,14 +11,14 @@ stages:
variables:
CARGO_HOME: $CI_PROJECT_DIR/cargo
.rust_stable_env: &rust_stable_env
.rust_stable_lin64: &rust_stable_lin64
tags:
- redshift-rs-stable
before_script:
- export PATH="$HOME/.cargo/bin:$PATH"
- rustc --version && cargo --version
.rust_beta_env: &rust_beta_env
.rust_beta_lin64: &rust_beta_lin64
image: parity/rust:gitlab-ci
tags:
- redshift-rs-stable
......@@ -27,54 +27,76 @@ variables:
- rustup default beta
- rustup show && rustc --version && cargo --version
.rust_nightly_env: &rust_nightly_env
.rust_nightly_lin64: &rust_nightly_lin64
image: rustlang/rust:nightly
tags:
- redshift-rs-nightly
before_script:
- export PATH="$HOME/.cargo/bin:$PATH"
- rustc --version && cargo --version
.rust_stable_armv7: &rust_stable_armv7
image: registry.duniter.org/docker/rust/armv7-builder:v0.0.3
tags:
- redshift-rs-stable
before_script:
- rustc --version && cargo --version
.rust_stable_win64: &rust_stable_win64
image: registry.duniter.org/docker/rust/win64-builder:v0.0.4
tags:
- redshift-rs-stable
before_script:
- rustc --version && cargo --version
fmt:
<<: *rust_nightly_lin64
stage: fmt
before_script:
- rustup show
- rustup component add rustfmt-preview --toolchain nightly
script:
- cargo fmt -- --check
allow_failure: true
build_and_tests:stable:
<<: *rust_stable_env
stage: build_and_tests
tests:linux64:stable:
<<: *rust_stable_lin64
stage: tests
tags:
- redshift-rs-stable
script:
- cargo build --features strict
- cargo test --all
cache:
paths:
- cargo/
- target/
tests:armv7:stable:
<<: *rust_stable_armv7
stage: tests
script:
- cargo test --all --target=armv7-unknown-linux-gnueabihf
tests:win64:stable:
<<: *rust_stable_win64
stage: tests
script:
- cargo test --all --exclude duniter-tui --no-default-features --target=x86_64-pc-windows-gnu
build_and_tests:beta:
<<: *rust_beta_env
stage: build_and_tests
tests:linux64:beta:
<<: *rust_beta_lin64
stage: tests
script:
- cargo build --features strict
- cargo test --all
when: manual
allow_failure: true
build_and_tests:nightly:
<<: *rust_nightly_env
stage: build_and_tests
tests:linux64:nightly:
<<: *rust_nightly_lin64
stage: tests
script:
- cargo build --features strict
- cargo test --all
when: manual
allow_failure: true
fmt:
<<: *rust_nightly_env
stage: fmt
before_script:
- rustup show
- rustup component add rustfmt-preview --toolchain nightly
script:
- cargo fmt -- --check
allow_failure: true
clippy:
image: guangie88/rustfmt-clippy:nightly
......@@ -89,7 +111,7 @@ clippy:
allow_failure: true
publish:crate:
<<: *rust_stable_env
<<: *rust_stable_lin64
stage: publish_crate
script:
- IFS='/' read -r first a <<< "$CI_COMMIT_TAG"
......@@ -102,7 +124,7 @@ publish:crate:
when: manual
pages:
<<: *rust_stable_env
<<: *rust_stable_lin64
stage: publish_doc
script:
- cargo doc
......@@ -117,8 +139,8 @@ pages:
only:
- dev
package:test:linux-x64:
<<: *rust_stable_env
package:test:linux64:
<<: *rust_stable_lin64
stage: package
script:
- bash "release/arch/linux-x64/build-lin-x64.sh" "$(date +%Y%m%d).$(date +%H%M).$(date +%S)"
......@@ -134,15 +156,73 @@ package:test:linux-x64:
- tags
when: manual
package:prod:linux-x64:
<<: *rust_stable_env
package:test:armv7:
<<: *rust_stable_armv7
stage: package
script:
- bash "release/arch/linux-x64/build-lin-x64.sh" "${CI_COMMIT_TAG#v}"
- bash "release/arch/armv7/build-armv7.sh" "$(date +%Y%m%d).$(date +%H%M).$(date +%S)"
cache:
paths:
- cargo/
- target/
artifacts:
paths:
- work/bin/
expire_in: 1 weeks
except:
- tags
when: manual
package:test:win64:
<<: *rust_stable_win64
stage: package
script:
- bash "release/arch/win64/build-win64.sh" "$(date +%Y%m%d).$(date +%H%M).$(date +%S)"
cache:
paths:
- cargo/
- target/
artifacts:
paths:
- work/bin/
expire_in: 1 weeks
except:
- tags
when: manual
package:prod:linux64:
<<: *rust_stable_lin64
stage: package
script:
- bash "release/arch/linux-x64/build-lin-x64.sh" "${CI_COMMIT_TAG#v}"
artifacts:
paths:
- work/bin/
expire_in: 2 weeks
only:
- tags
when: manual
allow_failure: false
package:prod:armv7:
<<: *rust_stable_armv7
stage: package
script:
- bash "release/arch/armv7/build-armv7.sh" "${CI_COMMIT_TAG#v}"
artifacts:
paths:
- work/bin/
expire_in: 2 weeks
only:
- tags
when: manual
allow_failure: false
package:prod:win64:
<<: *rust_stable_win64
stage: package
script:
- bash "release/arch/win64/build-win64.sh" "${CI_COMMIT_TAG#v}"
artifacts:
paths:
- work/bin/
......
#!/bin/bash
if [[ -z "${1}" ]]; then
echo "Fatal: no version given to build script"
exit 1
fi
# ---------
# Functions
# ---------
# Create description.
# -
# Parameters:
# 1. Initial file name.
# 2. Building type (either “desktop” or “server”).
# 3. Category (OS, distribution).
create_desc() {
cat >"${1}".desc <<-EOF
{
"version": "${DURS_TAG}",
"job": "${CI_JOB_ID}",
"type": "${2^}",
"category": "${3}",
"arch": "arm v7"
}
EOF
}
# Server specific building phase.
# -
# Parameters:
# 1. Building directory.
build_extra_server() {
mkdir -p "${1}/lib/systemd/system" || exit 1
cp "${ROOT}/release/extra/systemd/durs.service" "${1}/lib/systemd/system" || exit 1
}
# Debian package building.
# -
# Parameters:
# 1. Building type (either “desktop” or “server”).
# 2. Debian package name.
build_deb_pack() {
rm -rf "${RELEASES}/durs-armv7"
mkdir "${RELEASES}/durs-armv7" || exit 1
cp -r "${ROOT}/release/extra/debian/package/"* "${RELEASES}/durs-armv7" || exit 1
build_extra_${1} "${RELEASES}/durs-armv7"
mkdir -p "${RELEASES}/durs-armv7/opt/durs/" || exit 1
chmod 755 "${RELEASES}/durs-armv7/DEBIAN/"post* || exit 1
chmod 755 "${RELEASES}/durs-armv7/DEBIAN/"pre* || exit 1
sed -i "s/Version:.*/Version:${DURS_DEB_VER}/g" "${RELEASES}/durs-armv7/DEBIAN/control" || exit 1
cd "${RELEASES}/${1}_/"
zip -qr "${RELEASES}/durs-armv7/opt/durs/durs.zip" * || exit 1
sed -i "s/Package: .*/Package: ${2}/g" "${RELEASES}/durs-armv7/DEBIAN/control" || exit 1
cd "${RELEASES}"
dpkg-deb --build durs-armv7 || exit 1
mv durs-armv7.deb "${BIN}/duniter-rust-${1}-${DURS_TAG}-armv7.deb" || exit 1
create_desc "${BIN}/duniter-rust-${1}-${DURS_TAG}-armv7.deb" "${1}" "Linux (Ubuntu/Debian/Raspbian)"
}
# -----------
# Prepare
# -----------
DURS_TAG="v${1}"
DURS_DEB_VER=" ${1}"
TARGET="armv7-unknown-linux-gnueabihf"
# -----------
# Folders
# -----------
ROOT="${PWD}"
WORK_NAME=work
WORK="${ROOT}/${WORK_NAME}"
DOWNLOADS="${WORK}/downloads"
RELEASES="${WORK}/releases"
BIN="${WORK}/bin"
mkdir -p "${DOWNLOADS}" "${RELEASES}" "${BIN}" || exit 1
rm -rf "${BIN}/"*.{deb,tar.gz}{,.desc} # Clean up
# -----------
# Downloads
# -----------
cd "${DOWNLOADS}"
# -----------
# Releases
# -----------
# Prepare sources
mkdir -p "${RELEASES}/durs" || exit 1
cp -r $(find "${ROOT}" -mindepth 1 -maxdepth 1 ! -name "${WORK_NAME}") "${RELEASES}/durs" || exit 1
cd "${RELEASES}/durs"
rm -Rf .gitignore .git || exit 1 # Remove git files
# Build binary
echo ">> Building binary..."
cd "${ROOT}"
cargo build --release --target=${TARGET} || exit 1
mkdir -p "${RELEASES}/server_" || exit 1
cp "${ROOT}/target/${TARGET}/release/durs" "${RELEASES}/server_/" || exit 1
#cp "${ROOT}/target/release/durs" "${RELEASES}/desktop_" || exit 1
# Copy logo
cp "${ROOT}/images/duniter-rs.png" "${RELEASES}/server_/" || exit 1
#cp "${ROOT}/images/duniter-rs.png" "${RELEASES}/desktop_" || exit 1
# ---------------
# Build .tar.gz
# ---------------
cd "${RELEASES}/server_"
tar czf "${BIN}/duniter-rust-server-${DURS_TAG}-armv7.tar.gz" * || exit 1
create_desc "${BIN}/duniter-rust-server-${DURS_TAG}-armv7.tar.gz" "Server" "Linux (generic)"
# -----------------------
# Build Debian packages
# -----------------------
build_deb_pack server durs
#build_deb_pack desktop durs
#!/bin/bash
if [[ -z "${1}" ]]; then
echo "Fatal: no version given to build script"
exit 1
fi
# ---------
# Functions
# ---------
# Create description.
# -
# Parameters:
# 1. Initial file name.
# 2. Building type (either “desktop” or “server”).
# 3. Category (OS, distribution).
create_desc() {
cat >"${1}".desc <<-EOF
{
"version": "${DURS_TAG}",
"job": "${CI_JOB_ID}",
"type": "${2^}",
"category": "${3}",
"arch": "x64"
}
EOF
}
# -----------
# Prepare
# -----------
DURS_TAG="v${1}"
DURS_VER=" ${1}"
TARGET="x86_64-pc-windows-gnu"
#rustup add target ${TARGET} || exit 1
# -----------
# Folders
# -----------
ROOT="${PWD}"
WORK_NAME=work
WORK="${ROOT}/${WORK_NAME}"
DOWNLOADS="${WORK}/downloads"
RELEASES="${WORK}/releases"
BIN="${WORK}/bin"
mkdir -p "${DOWNLOADS}" "${RELEASES}" "${BIN}" || exit 1
rm -rf "${BIN}/"*.{deb,tar.gz}{,.desc} # Clean up
# -----------
# Downloads
# -----------
cd "${DOWNLOADS}"
# -----------
# Releases
# -----------
# Prepare sources
mkdir -p "${RELEASES}/durs" || exit 1
cp -r $(find "${ROOT}" -mindepth 1 -maxdepth 1 ! -name "${WORK_NAME}") "${RELEASES}/durs" || exit 1
cd "${RELEASES}/durs"
rm -Rf .gitignore .git || exit 1 # Remove git files
# Build binary
echo ">> Building binary..."
cd "${ROOT}"
cargo build --target=${TARGET} --release --no-default-features || exit 1
mkdir -p "${RELEASES}/server_" || exit 1
cp "${ROOT}/target/${TARGET}/release/durs.exe" "${RELEASES}/server_/" || exit 1
#cp "${ROOT}/target/${TARGET}/release/durs" "${RELEASES}/desktop_" || exit 1
# Copy logo
#cp "${ROOT}/images/duniter-rs.png" "${RELEASES}/server_/" || exit 1
#cp "${ROOT}/images/duniter-rs.png" "${RELEASES}/desktop_" || exit 1
# ---------------
# Build .zip
# ---------------
cd "${RELEASES}/server_"
zip "${BIN}/duniter-rust-server-${DURS_TAG}-windows-x64.zip" * || exit 1
create_desc "${BIN}/duniter-rust-server-${DURS_TAG}-windows-x64.zip" "Server" "Windows"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment