Browse Source

ci: add ability to publish

ci/buildyboi
andrei 5 years ago
parent
commit
461fa909a4
  1. 35
      .ci/pipeline.ts

35
.ci/pipeline.ts

@ -4,16 +4,15 @@ import {
spawnChildJob, spawnChildJob,
} from "https://pkg.buildyboi.ci/buildy/[email protected]/mod.ts"; } from "https://pkg.buildyboi.ci/buildy/[email protected]/mod.ts";
import * as Docker from "https://pkg.buildyboi.ci/buildy/[email protected]/mod.ts"; import * as Docker from "https://pkg.buildyboi.ci/buildy/[email protected]/mod.ts";
import { readSecrets } from "https://pkg.buildyboi.ci/buildy/[email protected]/secrets.ts";
export async function runTests(job: Job) { async function getImage(version: string): Promise<string> {
const version: string = job.args.version;
const dockerFileTemplate = ` const dockerFileTemplate = `
FROM python:${version}-buster FROM python:${version}-buster
ADD requirements.txt . ADD requirements.txt .
RUN pip install -r requirements.txt flake8 RUN pip install -r requirements.txt flake8 twine
`; `;
const image = await Docker.buildImage({ const image = await Docker.buildImage({
@ -21,14 +20,20 @@ export async function runTests(job: Job) {
include: ["requirements.txt"], include: ["requirements.txt"],
}); });
return image.id;
}
export async function runTests(job: Job) {
const imageId = await getImage(job.args.version);
pushStep("Tests"); pushStep("Tests");
await Docker.run(`python setup.py test`, { await Docker.run(`python setup.py test`, {
image: image.id, image: imageId,
}); });
pushStep("Flake8"); pushStep("Flake8");
await Docker.run(`flake8 disco/`, { await Docker.run(`flake8 disco/`, {
image: image.id, image: imageId,
}); });
} }
@ -44,3 +49,21 @@ export async function run(job: Job) {
}); });
} }
} }
export async function runRelease(job: Job) {
const imageId = await getImage("3.8");
const [twineUsername, twinePassword] = await readSecrets(
"TWINE_USERNAME",
"TWINE_PASSWORD"
);
await Docker.run(`python setup.py sdist`, {
image: imageId,
});
await Docker.run(`python3 -m twine upload dist/*`, {
image: imageId,
env: [`TWINE_USERNAME=${twineUsername}`, `TWINE_PASSWORD=${twinePassword}`],
});
}

Loading…
Cancel
Save