Skip to content

Commit

Permalink
Merge #373
Browse files Browse the repository at this point in the history
373: Fixup deploy r=MikailBag a=MikailBag



Co-authored-by: Mikail Bagishov <[email protected]>
  • Loading branch information
bors[bot] and MikailBag authored Jun 21, 2020
2 parents 4238458 + 9d74ffb commit 49e31cd
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 98 deletions.
55 changes: 12 additions & 43 deletions .github/workflows/deploy.yaml

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

65 changes: 12 additions & 53 deletions actions/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,18 @@ env:
jobs:
docker:
name: docker
runs-on: 'ubuntu-18.04'
runs-on: "ubuntu-18.04"
steps:
- uses: actions/checkout@v1
- name: install global dependencies
run: bash scripts/ci-env.sh
- name: cargo jjs-build
run: cargo jjs-build
env:
JJS_DT_DEPLOY: docker
- name: upload docker images
- uses: actions/checkout@v2
- $include: rustc
- $include: sysdeps
- name: Build images
run: |
docker login --username jjs-dev --password ${{ secrets.GITHUB_TOKEN }} docker.pkg.github.com
docker login --username mikailbag --password ${{ secrets.DOCKER_HUB_TOKEN }}
docker tag jjs:latest mikailbag/jjs:latest
docker push mikailbag/jjs
docker tag jjs:latest docker.pkg.github.com/jjs-dev/jjs/jjs:master
docker push docker.pkg.github.com/jjs-dev/jjs/jjs:master
deb:
name: deb
runs-on: 'ubuntu-18.04'
steps:
- uses: actions/checkout@v1
- name: Setup env
run: bash scripts/ci-env.sh
- name: Build debian package
run: cargo jjs-build
env:
JJS_DT_DEPLOY: deb
- name: Publish debian package artifact
uses: actions/upload-artifact@v1
with:
name: jjs-amd64.deb
path: /opt/jjs/pkg/jjs.deb
man:
name: man
runs-on: 'ubuntu-18.04'
steps:
- uses: actions/checkout@v1
- name: install global dependencies
mkdir artifacts
DOCKER_OPT="--enable-docker --docker-tag=% --docker-tags-log=/tmp/taglog.txt --with-docker=docker"
cargo jjs-build --out artifacts $DOCKER_OPT --enable=apiserver --enable=invoker
- name: Upload images
run: |
bash scripts/ci-env.sh
cargo install mdbook --no-default-features
- name: cargo jjs-build
run: cargo jjs-build
env:
JJS_DT_DEPLOY: man
- name: copy man
run: |
mkdir ./built-docs
cp -r /opt/jjs/share/docs/* ./built-docs
- name: upload man
uses: peaceiris/actions-gh-pages@v2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./built-docs
docker login --username jjs-dev --password ${{ secrets.GITHUB_TOKEN }} docker.pkg.github.com
echo "${{ secrets.GCR_UPLOAD_JSON_KEY }}" | base64 --decode | docker login --username _json_key --password-stdin gcr.io
python3 ci-data/push_images.py
20 changes: 20 additions & 0 deletions ci-data/push_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
import subprocess

TEMPLATES = [
"docker.pkg.github.com/jjs-dev/jjs/jjs-%:latest",
"gcr.io/jjs-dev/jjs-%:latest"
]

tags = open("/tmp/taglog.txt").readlines()
all_images = []
for comp in tags:
comp = comp.strip()
for tpl in TEMPLATES:
new_tag = tpl.replace("%", comp)
subprocess.check_call(["docker", "tag", comp, new_tag])
all_images.append(new_tag)
print("will push", all_images)

for img in all_images:
subprocess.check_call(["docker", "push", img])
1 change: 1 addition & 0 deletions src/dist-builder/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct DockerConfig {
pub build_options: Vec<String>,
/// None => default tag used
pub tag: Option<String>,
pub write_tags_to_file: Option<PathBuf>,
}

/// Describes which components should be build
Expand Down
12 changes: 10 additions & 2 deletions src/dist-builder/src/emit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{artifact::Artifact, cfg::DockerConfig, package::OtherPackage, Params};
use anyhow::Context as _;
use std::{path::Path, process::Command};
use std::{io::Write, path::Path, process::Command};
use util::cmd::CommandExt;

pub(crate) struct DockerEmitter;
Expand All @@ -21,10 +21,18 @@ impl DockerEmitter {
.clone()
.unwrap_or_else(|| "jjs-%:latest".to_string())
.replace('%', pkg_name);
cmd.arg("-t").arg(tag);
cmd.arg("-t").arg(&tag);
cmd.arg(docker_context);
cmd.try_exec()
.with_context(|| format!("Failed to build image for package {}", pkg_name))?;
if let Some(tag_log) = &options.write_tags_to_file {
let mut file = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open(tag_log)
.context("docker tag log unaccessible")?;
writeln!(file, "{}", tag)?;
}
Ok(())
}

Expand Down
8 changes: 8 additions & 0 deletions src/dist-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ struct Opt {
/// Name or path to Docker or other tool which can run containers (e.g. Podman)
#[structopt(long = "with-docker")]
docker_name: Option<String>,
/// If set, tags of built images will be written to this file,
/// each file on separate line
#[structopt(long)]
docker_tags_log: Option<PathBuf>,
/// Features to enable
#[structopt(long = "enable-feature")]
features: Vec<String>,
Expand Down Expand Up @@ -129,6 +133,7 @@ fn main() {
Some(cfg::DockerConfig {
build_options: opt.docker_build_opt.clone(),
tag: opt.docker_tag.clone(),
write_tags_to_file: opt.docker_tags_log.clone(),
})
} else {
None
Expand All @@ -141,6 +146,9 @@ fn main() {
build: build_config,
components: comps_config,
};
if std::env::var("CI").is_ok() {
println!("Options: {:?}", &config);
}
let params = Params {
cfg: config,
src: jjs_src_path,
Expand Down

0 comments on commit 49e31cd

Please sign in to comment.