From 4562d732a2a648bf6a4d68b0bfebf5574dd86df2 Mon Sep 17 00:00:00 2001 From: Anton Iakimov Date: Thu, 8 Aug 2024 13:16:22 +0200 Subject: [PATCH] ci: add Jenkinsfile and flake.nix --- Jenkinsfile | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 26 ++++++++++++++++++++++ flake.nix | 33 ++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 Jenkinsfile create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..5e8532a --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,63 @@ +#!/usr/bin/env groovy +library 'status-jenkins-lib@v1.8.8' + +pipeline { + agent { label 'linux' } + + options { + disableConcurrentBuilds() + /* manage how many builds we keep */ + buildDiscarder(logRotator( + numToKeepStr: '20', + daysToKeepStr: '30', + )) + } + + environment { + GIT_COMMITTER_NAME = 'status-im-auto' + GIT_COMMITTER_EMAIL = 'auto@status.im' + } + + stages { + stage('Install') { + steps { + script { + nix.develop('yarn install') + } + } + } + + stage('Build') { + steps { + script { + nix.develop('yarn build') + jenkins.genBuildMetaJSON('dist/build.json') + } + } + } + + stage('Publish') { + steps { + sshagent(credentials: ['status-im-auto-ssh']) { + script { + nix.develop(""" + ghp-import \ + -b ${deployBranch()} \ + -c ${deployDomain()} \ + -p dist + """ + ) + } + } + } + } + } + + post { + cleanup { cleanWs() } + } +} + +def isMasterBranch() { GIT_BRANCH ==~ /.*master/ } +def deployBranch() { isMasterBranch() ? 'deploy-master' : 'deploy-develop' } +def deployDomain() { isMasterBranch() ? 'p.free.technology' : 'dev-p.free.technology' } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bf51175 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1722869614, + "narHash": "sha256-7ojM1KSk3mzutD7SkrdSflHXEujPvW1u7QuqWoTLXQU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "883180e6550c1723395a3a342f830bfc5c371f6b", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-24.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9117b39 --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "Flake file for logos website "; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-24.05"; + }; + + outputs = + { self, nixpkgs }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forEachSystem = nixpkgs.lib.genAttrs supportedSystems; + pkgsFor = forEachSystem (system: import nixpkgs { inherit system; }); + in + rec { + formatter = forEachSystem (system: pkgsFor.${system}.nixpkgs-fmt); + + devShells = forEachSystem (system: { + default = pkgsFor.${system}.mkShellNoCC { + packages = with pkgsFor.${system}.buildPackages; [ + yarn # 1.22.22 + nodejs_20 # v20.15.1 + ghp-import # 2.1.0 + ]; + }; + }); + }; +}