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

variables:
  PACKER_LOG: 1
6
7

stages:
8
  - lint
9
  - build
10
  - publish
11

Christian Rebischke's avatar
Christian Rebischke committed
12
shellcheck:
13
  stage: lint
14
15
  before_script:
    - pacman -Syu --needed --noconfirm shellcheck
Christian Rebischke's avatar
Christian Rebischke committed
16
  script:
17
    - find . -iname "*.sh" -exec shellcheck {} +
Christian Rebischke's avatar
Christian Rebischke committed
18
19

shfmt:
20
  stage: lint
21
22
  before_script:
    - pacman -Syu --needed --noconfirm shfmt
Christian Rebischke's avatar
Christian Rebischke committed
23
  script:
24
    - find . -iname "*.sh" -exec shfmt -i 2 -ci -d {} +
Christian Rebischke's avatar
Christian Rebischke committed
25
26

validate-packer:
27
  stage: lint
28
29
  before_script:
    - pacman -Syu --needed --noconfirm packer
Christian Rebischke's avatar
Christian Rebischke committed
30
  script:
31
    - packer validate config.json
Christian Rebischke's avatar
Christian Rebischke committed
32

33
34
# Note: We explicitly need the `ipv6` tag here because otherwise we'd get random
# gpg/pacman-key issues.
35
36
build:cloud-qemu:
  stage: build
Sven-Hendrik Haase's avatar
Sven-Hendrik Haase committed
37
38
  tags:
    - ipv6
39
40
41
  before_script:
    - pacman -Syu --needed --noconfirm packer qemu-headless
  script:
42
    - packer build -only=cloud -except=sign config.json
43
  artifacts:
Sven-Hendrik Haase's avatar
Sven-Hendrik Haase committed
44
    name: "archlinux_x86_64_qcow2"
45
    paths:
46
      - "Arch-Linux-x86_64-cloudimg-*.*"
47
48
    expire_in: 2d

49
50
51
52
53
54
55
build:vagrant-virtualbox:
  stage: build
  tags:
    - ipv6
  before_script:
    - pacman -Syu --needed --noconfirm packer qemu-headless
  script:
56
57
58
59
60
61
    - packer build -only=virtualbox config.json
  artifacts:
    name: "archlinux_x86_64_virtualbox"
    paths:
      - "*.box"
    expire_in: 2d
62

63
build:vagrant-qemu:
64
  stage: build
Sven-Hendrik Haase's avatar
Sven-Hendrik Haase committed
65
66
  tags:
    - ipv6
67
  before_script:
68
    - pacman -Syu --needed --noconfirm packer qemu-headless
69
  script:
70
71
72
73
74
75
    - packer build -only=libvirt config.json
  artifacts:
    name: "archlinux_x86_64_libvirt"
    paths:
      - "*.box"
    expire_in: 2d
76
77
78
79

publish:
  stage: publish
  tags:
80
81
    - ipv6
    - secure
82
  before_script:
83
    - pacman -Syu --needed --noconfirm vagrant
84
  script:
85
86
87
88
89
90
91
    - vagrant cloud auth login --token $VAGRANT_API_TOKEN
    - vagrant cloud auth login --check
    - vagrant cloud box show archlinux/archlinux
    - LIBVIRT_RELEASE=`ls Arch-Linux-x86_64-libvirt-*.box | awk -F "." '{print $1}'  | awk -F "-" '{print $5"."$6"."$7}'`
    - VIRTUALBOX_RELEASE=`ls Arch-Linux-x86_64-virtualbox-*.box | awk -F "." '{print $1}'  | awk -F "-" '{print $5"."$6"."$7}'`
    - vagrant cloud publish archlinux/archlinux $LIBVIRT_RELEASE libvirt Arch-Linux-x86_64-libvirt-*.box --release -f
    - vagrant cloud publish archlinux/archlinux $VIRTUALBOX_RELEASE virtualbox Arch-Linux-x86_64-virtualbox-*.box --release -f
92
93
94
  only:
    variables:
      - $SCHEDULED_PUBLISH == "TRUE"
95
  resource_group: vm-build