Skip to content

Commit

Permalink
chore: Merge branch 'release/4.17.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuthor committed Jul 8, 2024
2 parents f2a2af7 + d24ad55 commit c416792
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 58 deletions.
78 changes: 31 additions & 47 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
kms_version:
description: KMS version
type: string
default: 4.11.0
default: '4.17.0'

jobs:
kms-gui-build:
Expand All @@ -24,69 +24,45 @@ jobs:
rustup target add x86_64-apple-darwin
build: |
cargo build --release --target x86_64-apple-darwin
archive_name: ckms_gui_macos
archive_name: ckms_gui_macos_intel
ckms_gui: ./target/x86_64-apple-darwin/release/ckms_gui
- os: macos-14
prerequisites: |
rustup target add aarch64-apple-darwin
build: |
cargo build --release --target aarch64-apple-darwin
archive_name: ckms_gui_macos_arm
ckms_gui: ./target/aarch64-apple-darwin/release/ckms_gui
- os: ubuntu-22.04
prerequisites: |
sudo apt install librust-atk-sys-dev librust-gdk-sys-dev libssl-dev pkg-config
build: |
cargo build --release
archive_name: ckms_gui_ubuntu_22_04
ckms_gui: ./target/release/ckms_gui
# - os: ubuntu-22.04
# prerequisites: |
# sudo apt install librust-atk-sys-dev librust-gdk-sys-dev libssl-dev
# sudo apt-get install --no-install-recommends -qq libclang-dev gcc-mingw-w64-x86-64
# rustup target add x86_64-pc-windows-gnu
# build: |
# cargo build --release --target x86_64-pc-windows-gnu
# archive_name: ckms_gui_windows
# ckms_gui: ./target/x86_64-pc-windows-gnu/release/ckms_gui
- os: ubuntu-24.04
prerequisites: |
sudo apt install libgtk-3-dev libglib2.0-dev libssl-dev pkg-config
build: |
cargo build --release
archive_name: ckms_gui_ubuntu_24_04
ckms_gui: ./target/release/ckms_gui

steps:
- uses: actions/checkout@v3

- name: Set up cargo cache
id: cargo_cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ matrix.os }}-kms-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-${{ matrix.os }}-kms-${{ hashFiles('**/Cargo.lock') }}

- uses: dtolnay/rust-toolchain@master
if: steps.cargo_cache.outputs.cache-hit != 'true'
with:
toolchain: nightly-2024-01-09
components: rustfmt, clippy

- name: Set KMS version
if: inputs.kms_version && contains(runner.os, 'Linux')
run: |
sed -i "s/4.11.0/${VERSION}/g" Cargo.toml
sed -i "s/4.11.0/${VERSION}/g" build.rs
env:
VERSION: ${{ inputs.kms_version }}

- name: Set KMS version
if: inputs.kms_version && contains(runner.os, 'Mac')
run: |
sed -i '' "s/4.11.0/${VERSION}/g" Cargo.toml
sed -i '' "s/4.11.0/${VERSION}/g" build.rs
env:
VERSION: ${{ inputs.kms_version }}

- name: Install prerequisites
run: ${{ matrix.prerequisites }}

- name: Build
run: ${{ matrix.build }}
env:
VERSION: ${{ inputs.kms_version }}

- name: Upload KMS for ${{ matrix.os }}
uses: actions/upload-artifact@v3
Expand All @@ -104,30 +80,38 @@ jobs:
needs:
- kms-gui-build
runs-on: [self-hosted, not-sgx]
container:
image: cosmian/docker_doc_ci
volumes:
- /home/cosmian/.ssh/id_rsa:/root/.ssh/id_rsa

strategy:
fail-fast: false
matrix:
include:
- archive_name: ckms_gui_macos
- archive_name: ckms_gui_macos_intel
- archive_name: ckms_gui_macos_arm
- archive_name: ckms_gui_ubuntu_22_04
# - archive_name: ckms_gui_windows
- archive_name: ckms_gui_ubuntu_24_04

steps:
- uses: actions/download-artifact@v3
- run: find .

- name: Creating zip to be attached to release
run: |
sudo apt-get install -y zip
apt update -y
apt-get install -y zip
rm -f ${{ matrix.archive_name }}.zip
zip -r ${{ matrix.archive_name }}.zip ${{ matrix.archive_name }}
- name: Push to package.cosmian.com
if: inputs.kms_version
run: |
set -x
DESTINATION_DIR=/mnt/package/kms/$VERSION
ssh [email protected] mkdir -p $DESTINATION_DIR
scp ${{ matrix.archive_name }}.zip [email protected]:$DESTINATION_DIR/
ssh -o 'StrictHostKeyChecking no' -i /root/.ssh/id_rsa [email protected] mkdir -p $DESTINATION_DIR
scp -o 'StrictHostKeyChecking no' -i /root/.ssh/id_rsa ${{ matrix.archive_name }}.zip [email protected]:$DESTINATION_DIR/
env:
VERSION: ${{ inputs.kms_version }}

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
src/main.rs
/src/main.rs
/target
./.cargo_check
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckms_gui"
version = "4.16.0"
version = "4.17.0"
edition = "2021"
description = "Graphical interface for the CLI to interact with Cosmian KMS"

Expand Down
36 changes: 28 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
use std::process;

use serde::Deserialize;

#[derive(Deserialize)]
struct Release {
tag_name: String,
}

fn get_latest_kms_release(client: &reqwest::blocking::Client) -> Option<String> {
std::env::var("VERSION")
.ok()
.filter(|version| !version.is_empty())
.or_else(|| {
client
.get("https://api.github.com/repos/Cosmian/kms/releases/latest")
.send()
.ok()
.and_then(|response| response.json::<Release>().ok())
.and_then(|release| {
if release.tag_name.is_empty() {
None
} else {
Some(release.tag_name)
}
})
.or_else(|| option_env!("CARGO_PKG_VERSION").map(|version| version.to_string()))
})
}

fn main() {
let client = reqwest::blocking::Client::builder()
.user_agent("Cosmian/CKMS_GUI")
.build()
.unwrap();

// typically the `VERSION` env var is set by the KMS CI release pipeline
let latest_kms_release = std::env::var("VERSION").unwrap_or_else(|_| {
client
.get("https://api.github.com/repos/Cosmian/kms/releases/latest")
.send()
.unwrap()
.json::<Release>()
.unwrap()
.tag_name
let latest_kms_release = get_latest_kms_release(&client);

let latest_kms_release = latest_kms_release.unwrap_or_else(|| {
println!("Latest KMS release version cannot be empty");
process::exit(1);
});

println!("cargo:warning=Using KMS release {latest_kms_release}");
Expand Down

0 comments on commit c416792

Please sign in to comment.