.gitlab-ci.yml 1.73 KB
Newer Older
1
2
default:
  image: "archlinux:latest"
Sven-Hendrik Haase's avatar
Sven-Hendrik Haase committed
3

4
stages:
5
  - lint
6
  - build
7
  - publish
8

Christian Rebischke's avatar
Christian Rebischke committed
9
shellcheck:
10
  stage: lint
11
12
  before_script:
    - pacman -Syu --needed --noconfirm shellcheck
Christian Rebischke's avatar
Christian Rebischke committed
13
  script:
14
    - shellcheck **/*.sh
Christian Rebischke's avatar
Christian Rebischke committed
15
16

shfmt:
17
  stage: lint
18
19
  before_script:
    - pacman -Syu --needed --noconfirm shfmt
Christian Rebischke's avatar
Christian Rebischke committed
20
  script:
21
    - shfmt -i 2 -ci -d **/*.sh
Christian Rebischke's avatar
Christian Rebischke committed
22

23
.build:
24
  stage: build
25
  before_script:
26
    - pacman -Syu --needed --noconfirm qemu-headless libisoburn
27
  script:
28
29
    - echo "BUILD_DATE=$(date -I)" > build.env
    - . build.env
30
    - ./build-in-qemu.sh
31
    - mv build.env output/
Sven-Hendrik Haase's avatar
Sven-Hendrik Haase committed
32
33
34
35
36
37
38
  after_script:
    - echo "image_size_megabytes{image=\"qcow2\"} $(du -m output/*cloudimg*qcow2)" > metrics.txt
    - echo "image_size_megabytes{image=\"libvirt\"} $(du -m output/*libvirt*box)" >> metrics.txt
    - echo "image_size_megabytes{image=\"virtualbox\"} $(du -m output/*virtualbox*box)" >> metrics.txt
  artifacts:
    reports:
      metrics: metrics.txt
39
40
41
42
43
44
45
46
47
48
49
50

build:
  extends: .build
  except:
    - master

build:release:
  extends: .build
  tags:
    - secure
  only:
    - master
51
  artifacts:
52
    name: "output"
53
    paths:
54
      - "output/*"
55
    expire_in: 2d
56
57
58
59

publish:
  stage: publish
  tags:
60
    - secure
61
  before_script:
62
    - pacman -Syu --needed --noconfirm vagrant
63
  script:
64
65
    - . output/build.env
    - vagrant cloud auth login --token "${VAGRANT_API_TOKEN}"
66
67
    - vagrant cloud auth login --check
    - vagrant cloud box show archlinux/archlinux
68
69
    - vagrant cloud publish archlinux/archlinux "v${BUILD_DATE}" libvirt output/Arch-Linux-x86_64-libvirt-*.box --release -f
    - vagrant cloud publish archlinux/archlinux "v${BUILD_DATE}" virtualbox output/Arch-Linux-x86_64-virtualbox-*.box --release -f
70
71
72
  only:
    variables:
      - $SCHEDULED_PUBLISH == "TRUE"
73
  resource_group: vm-build