From a9d7c9b3be010ca116dd1a07567b0f6b477d55b4 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 25 Jul 2020 21:24:47 -0400 Subject: [PATCH] automate all the things --- .drone.yml | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ docker.nix | 24 ++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 docker.nix diff --git a/.drone.yml b/.drone.yml index 5804639..0602263 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,3 +10,84 @@ steps: when: event: - push + + - name: auto-release + image: xena/gitea-release + pull: always + settings: + auth_username: cadey + gitea_server: https://tulpa.dev + gitea_token: + from_secret: GITEA_TOKEN + when: + event: + - push + branch: + - master + +--- + +kind: pipeline +name: cargo publish +steps: + - name: publish maj + image: rust:1 + commands: + - cargo login $CARGO_TOKEN + - "cargo publish ||:" + environment: + CARGO_TOKEN: + from_secret: CARGO_TOKEN + when: + event: + - tag + +--- + +kind: pipeline +name: docker +steps: + - name: build docker image + image: "monacoremo/nix:2020-04-05-05f09348-circleci" + environment: + USER: root + commands: + - true # cachix use xe + - nix-build -A majsite docker.nix + - cp $(readlink result) /result/site.tgz + - nix-build -A majc docker.nix + - cp $(readlink result) /result/majc.tgz + volumes: + - name: image + path: /result + when: + event: + - tag + + - name: push docker image + image: docker:dind + volumes: + - name: image + path: /result + - name: dockersock + path: /var/run/docker.sock + commands: + - docker load -i /result/site.tgz + - docker load -i /result/majc.tgz + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin + - docker push xena/majsite + - docker push xena/majc + environment: + DOCKER_USERNAME: xena + DOCKER_PASSWORD: + from_secret: DOCKER_PASSWORD + when: + event: + - tag + +volumes: + - name: image + temp: {} + - name: dockersock + host: + path: /var/run/docker.sock diff --git a/docker.nix b/docker.nix new file mode 100644 index 0000000..1ab3b2a --- /dev/null +++ b/docker.nix @@ -0,0 +1,24 @@ +{ system ? builtins.currentSystem }: + +let + pkgs = import { }; + callPackage = pkgs.lib.callPackageWith pkgs; + crates = callPackage ./default.nix { }; + + dockerImage = pkg: + pkgs.dockerTools.buildLayeredImage { + name = "xena/${pkg.name}"; + tag = "latest"; + + contents = [ pkg ]; + + config = { + Cmd = [ "/bin/${pkg.name}" ]; + WorkingDir = "/"; + }; + }; + +in { + majc = dockerImage crates.majc; + majsite = dockerImage crates.majsite; +}