.gitlab-ci.yml 2.55 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
30
    - echo "BUILD_VERSION=$(date +%Y.%m.%d)" > build.env
    - export $(< build.env)
    - ./build-host.sh
Sven-Hendrik Haase's avatar
Sven-Hendrik Haase committed
31
32
33
34
35
36
37
  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
38
      dotenv: build.env
39
40
41
42
43

build:
  extends: .build
  except:
    - master
44
45
    - schedules
    - tags
46

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

61
62
63
64
65
66
67
68
69
70
71
72
tag_release:
  stage: publish
  tags:
    - secure
  only:
    refs:
      - schedules
    variables:
      - $SCHEDULED_PUBLISH == "TRUE"
  before_script:
    - pacman -Syu --needed --noconfirm httpie
  script:
73
    - >
74
75
76
77
        export ASSET_LINKS="{ \"links\": [ \
          { \"name\": \"Vagrant Cloud Release\", \"url\": \"https://app.vagrantup.com/archlinux/boxes/archlinux/versions/$BUILD_VERSION\" }, \
          { \"name\": \"qcow2 Image\", \"url\": \"https://gitlab.archlinux.org/archlinux/arch-boxes/-/jobs/artifacts/master/raw/output/Arch-Linux-x86_64-cloudimg-$BUILD_VERSION.qcow2?job=build:secure\" } \
        ]}"
78
79
80
81
82
    - http --ignore-stdin "$CI_API_V4_URL/projects/$CI_PROJECT_ID/releases"
        "JOB-TOKEN:$CI_JOB_TOKEN"
        "name=v$BUILD_VERSION"
        "tag_name=v$BUILD_VERSION"
        "ref=$CI_COMMIT_SHA"
83
        "assets:=$ASSET_LINKS"
84

85
86
87
publish:
  stage: publish
  tags:
88
    - secure
89
90
  only:
    - tags
91
  before_script:
92
    - pacman -Syu --needed --noconfirm vagrant
93
  script:
94
    - vagrant cloud auth login --token "${VAGRANT_API_TOKEN}"
95
96
    - vagrant cloud auth login --check
    - vagrant cloud box show archlinux/archlinux
Sven-Hendrik Haase's avatar
Sven-Hendrik Haase committed
97
98
    - vagrant cloud publish archlinux/archlinux "${BUILD_VERSION}" libvirt output/Arch-Linux-x86_64-libvirt-*.box --release -f
    - vagrant cloud publish archlinux/archlinux "${BUILD_VERSION}" virtualbox output/Arch-Linux-x86_64-virtualbox-*.box --release -f