Skip to content

Commit 49e31cd

Browse files
bors[bot]MikailBag
andauthored
Merge #373
373: Fixup deploy r=MikailBag a=MikailBag Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
2 parents 4238458 + 9d74ffb commit 49e31cd

6 files changed

Lines changed: 63 additions & 98 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 12 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actions/deploy.yaml

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,18 @@ env:
1010
jobs:
1111
docker:
1212
name: docker
13-
runs-on: 'ubuntu-18.04'
13+
runs-on: "ubuntu-18.04"
1414
steps:
15-
- uses: actions/checkout@v1
16-
- name: install global dependencies
17-
run: bash scripts/ci-env.sh
18-
- name: cargo jjs-build
19-
run: cargo jjs-build
20-
env:
21-
JJS_DT_DEPLOY: docker
22-
- name: upload docker images
15+
- uses: actions/checkout@v2
16+
- $include: rustc
17+
- $include: sysdeps
18+
- name: Build images
2319
run: |
24-
docker login --username jjs-dev --password ${{ secrets.GITHUB_TOKEN }} docker.pkg.github.com
25-
docker login --username mikailbag --password ${{ secrets.DOCKER_HUB_TOKEN }}
26-
docker tag jjs:latest mikailbag/jjs:latest
27-
docker push mikailbag/jjs
28-
docker tag jjs:latest docker.pkg.github.com/jjs-dev/jjs/jjs:master
29-
docker push docker.pkg.github.com/jjs-dev/jjs/jjs:master
30-
deb:
31-
name: deb
32-
runs-on: 'ubuntu-18.04'
33-
steps:
34-
- uses: actions/checkout@v1
35-
- name: Setup env
36-
run: bash scripts/ci-env.sh
37-
- name: Build debian package
38-
run: cargo jjs-build
39-
env:
40-
JJS_DT_DEPLOY: deb
41-
- name: Publish debian package artifact
42-
uses: actions/upload-artifact@v1
43-
with:
44-
name: jjs-amd64.deb
45-
path: /opt/jjs/pkg/jjs.deb
46-
man:
47-
name: man
48-
runs-on: 'ubuntu-18.04'
49-
steps:
50-
- uses: actions/checkout@v1
51-
- name: install global dependencies
20+
mkdir artifacts
21+
DOCKER_OPT="--enable-docker --docker-tag=% --docker-tags-log=/tmp/taglog.txt --with-docker=docker"
22+
cargo jjs-build --out artifacts $DOCKER_OPT --enable=apiserver --enable=invoker
23+
- name: Upload images
5224
run: |
53-
bash scripts/ci-env.sh
54-
cargo install mdbook --no-default-features
55-
- name: cargo jjs-build
56-
run: cargo jjs-build
57-
env:
58-
JJS_DT_DEPLOY: man
59-
- name: copy man
60-
run: |
61-
mkdir ./built-docs
62-
cp -r /opt/jjs/share/docs/* ./built-docs
63-
- name: upload man
64-
uses: peaceiris/actions-gh-pages@v2
65-
env:
66-
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
67-
PUBLISH_BRANCH: gh-pages
68-
PUBLISH_DIR: ./built-docs
25+
docker login --username jjs-dev --password ${{ secrets.GITHUB_TOKEN }} docker.pkg.github.com
26+
echo "${{ secrets.GCR_UPLOAD_JSON_KEY }}" | base64 --decode | docker login --username _json_key --password-stdin gcr.io
27+
python3 ci-data/push_images.py

ci-data/push_images.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python3
2+
import subprocess
3+
4+
TEMPLATES = [
5+
"docker.pkg.github.com/jjs-dev/jjs/jjs-%:latest",
6+
"gcr.io/jjs-dev/jjs-%:latest"
7+
]
8+
9+
tags = open("/tmp/taglog.txt").readlines()
10+
all_images = []
11+
for comp in tags:
12+
comp = comp.strip()
13+
for tpl in TEMPLATES:
14+
new_tag = tpl.replace("%", comp)
15+
subprocess.check_call(["docker", "tag", comp, new_tag])
16+
all_images.append(new_tag)
17+
print("will push", all_images)
18+
19+
for img in all_images:
20+
subprocess.check_call(["docker", "push", img])

src/dist-builder/src/cfg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub struct DockerConfig {
3232
pub build_options: Vec<String>,
3333
/// None => default tag used
3434
pub tag: Option<String>,
35+
pub write_tags_to_file: Option<PathBuf>,
3536
}
3637

3738
/// Describes which components should be build

src/dist-builder/src/emit.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{artifact::Artifact, cfg::DockerConfig, package::OtherPackage, Params};
22
use anyhow::Context as _;
3-
use std::{path::Path, process::Command};
3+
use std::{io::Write, path::Path, process::Command};
44
use util::cmd::CommandExt;
55

66
pub(crate) struct DockerEmitter;
@@ -21,10 +21,18 @@ impl DockerEmitter {
2121
.clone()
2222
.unwrap_or_else(|| "jjs-%:latest".to_string())
2323
.replace('%', pkg_name);
24-
cmd.arg("-t").arg(tag);
24+
cmd.arg("-t").arg(&tag);
2525
cmd.arg(docker_context);
2626
cmd.try_exec()
2727
.with_context(|| format!("Failed to build image for package {}", pkg_name))?;
28+
if let Some(tag_log) = &options.write_tags_to_file {
29+
let mut file = std::fs::OpenOptions::new()
30+
.create(true)
31+
.append(true)
32+
.open(tag_log)
33+
.context("docker tag log unaccessible")?;
34+
writeln!(file, "{}", tag)?;
35+
}
2836
Ok(())
2937
}
3038

src/dist-builder/src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ struct Opt {
7171
/// Name or path to Docker or other tool which can run containers (e.g. Podman)
7272
#[structopt(long = "with-docker")]
7373
docker_name: Option<String>,
74+
/// If set, tags of built images will be written to this file,
75+
/// each file on separate line
76+
#[structopt(long)]
77+
docker_tags_log: Option<PathBuf>,
7478
/// Features to enable
7579
#[structopt(long = "enable-feature")]
7680
features: Vec<String>,
@@ -129,6 +133,7 @@ fn main() {
129133
Some(cfg::DockerConfig {
130134
build_options: opt.docker_build_opt.clone(),
131135
tag: opt.docker_tag.clone(),
136+
write_tags_to_file: opt.docker_tags_log.clone(),
132137
})
133138
} else {
134139
None
@@ -141,6 +146,9 @@ fn main() {
141146
build: build_config,
142147
components: comps_config,
143148
};
149+
if std::env::var("CI").is_ok() {
150+
println!("Options: {:?}", &config);
151+
}
144152
let params = Params {
145153
cfg: config,
146154
src: jjs_src_path,

0 commit comments

Comments
 (0)