.gitlab-ci.yml 2.52 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
44

build:
  extends: .build
  except:
    - master

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

59
60
61
62
63
64
65
66
67
68
69
70
tag_release:
  stage: publish
  tags:
    - secure
  only:
    refs:
      - schedules
    variables:
      - $SCHEDULED_PUBLISH == "TRUE"
  before_script:
    - pacman -Syu --needed --noconfirm httpie
  script:
71
72
73
74
75
    - >
        export ASSET_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\" }
        ]"
76
77
78
79
80
    - 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"
81
        "assets.links=$ASSET_LINKS"
82

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