|
13 | 13 | VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }}
|
14 | 14 | # Needed for Packer when calling ansible (https://github.com/ansible/ansible/issues/32499)
|
15 | 15 | OBJC_DISABLE_INITIALIZE_FORK_SAFETY: YES
|
| 16 | + ACCELERATOR: hvf |
16 | 17 |
|
17 | 18 | jobs:
|
18 |
| - |
19 |
| -############## |
20 |
| -# libvirt |
21 |
| -############## |
22 |
| - |
23 |
| - build-libvirt: |
| 19 | + build-boxes: |
24 | 20 | name: "*"
|
25 |
| - runs-on: [self-hosted, linux, x64] |
| 21 | + runs-on: macos-latest |
26 | 22 | strategy:
|
27 |
| - max-parallel: 1 |
28 | 23 | fail-fast: false
|
29 | 24 | matrix:
|
30 | 25 | stage:
|
|
39 | 34 | - windows-server-2012_r2-standard-x64-eval-libvirt
|
40 | 35 | - windows-server-2016-standard-x64-eval-libvirt
|
41 | 36 | - windows-server-2019-standard-x64-eval-libvirt
|
42 |
| - |
43 |
| - steps: |
44 |
| - - name: Skip image build if it already exists in Vagrant Cloud |
45 |
| - run: | |
46 |
| - BUILD="${{ matrix.stage }}" |
47 |
| - PACKER_VAGRANT_PROVIDER="${BUILD##*-}" |
48 |
| - NAME="${BUILD%-*}" |
49 |
| -
|
50 |
| - # Check if the boxes (virtualbox/libvirt) with the same git hash already exists |
51 |
| - CURRENT_VERSION_DESCRIPTION_MARKDOWN="$(curl -L --silent "https://app.vagrantup.com/api/v1/box/${VAGRANT_CLOUD_USER}/${NAME}" | jq '.current_version.version as $current_version | .versions[] | select (.version == $current_version) .description_markdown')" |
52 |
| - if [[ "${CURRENT_VERSION_DESCRIPTION_MARKDOWN}" =~ ${GITHUB_SHA} ]]; then |
53 |
| - echo "*** Git hash \"${GITHUB_SHA}\" found in current markdown description: https://app.vagrantup.com/${VAGRANT_CLOUD_USER}/boxes/${NAME}/" |
54 |
| - # Skip build if the box already exists |
55 |
| - CURRENT_VERSION_PROVIDER_URL="$(curl -L --silent "https://app.vagrantup.com/api/v1/box/${VAGRANT_CLOUD_USER}/${NAME}" | jq -r ".current_version.version as \$current_version | .versions[] | select (.version == \$current_version) .providers[] | select (.name == \"${PACKER_VAGRANT_PROVIDER}\") .download_url")" |
56 |
| - if [ -n "${CURRENT_VERSION_PROVIDER_URL}" ]; then |
57 |
| - echo "*** Found already build image \"${BUILD}\" with hash \"${GITHUB_SHA}\": ${CURRENT_VERSION_PROVIDER_URL}" |
58 |
| - echo "*** This build will be skipped..." |
59 |
| - echo "::set-env name=skip::true" |
60 |
| - else |
61 |
| - # Set BOX_VERSION variable from existing provider (if exists) or from "date" |
62 |
| - BOX_VERSION="$(curl -L --silent "https://app.vagrantup.com/api/v1/box/${VAGRANT_CLOUD_USER}/${NAME}" | jq -r ".current_version.version")" |
63 |
| - echo "*** Using previously defined box version \"${BOX_VERSION}\", because there is already builded box with git hash \"${GITHUB_SHA}\"" |
64 |
| - fi |
65 |
| - else |
66 |
| - BOX_VERSION="$(date +%Y%m%d).01" |
67 |
| - echo "*** Using new box version based on current date: ${BOX_VERSION}" |
68 |
| - fi |
69 |
| - echo "::set-env name=BOX_VERSION::${BOX_VERSION}" |
70 |
| -
|
71 |
| - - uses: actions/checkout@v2 |
72 |
| - if: env.skip != 'true' |
73 |
| - with: |
74 |
| - submodules: true |
75 |
| - |
76 |
| - - name: Build image - ${{ matrix.stage }} |
77 |
| - if: env.skip != 'true' |
78 |
| - run: | |
79 |
| - test -d "${PACKER_CACHE_DIR}" || mkdir -v "${PACKER_CACHE_DIR}" |
80 |
| - ln -sv "${PACKER_CACHE_DIR}" packer_cache |
81 |
| - ./build.sh "${{ matrix.stage }}" |
82 |
| -
|
83 |
| - - name: Check the created box image - ${{ matrix.stage }} |
84 |
| - if: env.skip != 'true' |
85 |
| - run: | |
86 |
| - ./vagrant_init_destroy_boxes.sh "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box" |
87 |
| -
|
88 |
| - - name: Upload box to Vagrant Cloud - ${{ matrix.stage }} |
89 |
| - env: |
90 |
| - BOX_VERSION: ${{ env.BOX_VERSION }} |
91 |
| - if: env.skip != 'true' && ( github.event_name == 'schedule' || ( github.event_name == 'repository_dispatch' && github.event.action == 'build_release_upload' ) ) |
92 |
| - run: | |
93 |
| - ./upload_box_to_vagrantcloud.sh "${VAGRANT_CLOUD_USER}@${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box" |
94 |
| -
|
95 |
| - - name: Build log cleanup - ${{ matrix.stage }} |
96 |
| - if: env.skip != 'true' && ( github.event_name == 'schedule' || ( github.event_name == 'repository_dispatch' && github.event.action == 'build_release_upload' ) ) |
97 |
| - run: | |
98 |
| - rm -v "${LOGDIR}/${{ matrix.stage }}-packer.log" |
99 |
| - rm -v "${LOGDIR}/${{ matrix.stage }}-init.log" |
100 |
| - rm -v "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box" |
101 |
| -
|
102 |
| -############## |
103 |
| -# VirtualBox |
104 |
| -############## |
105 |
| - |
106 |
| - build-virtualbox: |
107 |
| - name: "*" |
108 |
| - runs-on: macos-latest |
109 |
| - strategy: |
110 |
| - fail-fast: false |
111 |
| - matrix: |
112 |
| - stage: |
113 | 37 | - my_ubuntu-20.04-server-amd64-virtualbox
|
114 | 38 | - my_windows-10-enterprise-x64-eval-virtualbox
|
115 | 39 | - ubuntu-16.04-server-amd64-virtualbox
|
@@ -160,25 +84,23 @@ jobs:
|
160 | 84 | run: |
|
161 | 85 | brew install ansible bash coreutils gnu-sed qemu
|
162 | 86 | pip3 install pywinrm
|
| 87 | + echo "::add-path::/usr/local/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:${PATH}" |
163 | 88 |
|
164 | 89 | - name: Build image - ${{ matrix.stage }}
|
165 | 90 | if: env.skip != 'true'
|
166 | 91 | run: |
|
167 |
| - export PATH="/usr/local/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:${PATH}" |
168 | 92 | ./build.sh ${{ matrix.stage }}
|
169 | 93 |
|
170 | 94 | - name: Check the created box image - ${{ matrix.stage }}
|
171 |
| - if: env.skip != 'true' |
| 95 | + if: env.skip != 'true' && contains( matrix.stage, 'virtualbox' ) |
172 | 96 | run: |
|
173 |
| - export PATH="/usr/local/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:${PATH}" |
174 | 97 | ./vagrant_init_destroy_boxes.sh "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
|
175 | 98 |
|
176 | 99 | - name: Upload box to Vagrant Cloud - ${{ matrix.stage }}
|
177 | 100 | if: env.skip != 'true' && ( github.event_name == 'schedule' || ( github.event_name == 'repository_dispatch' && github.event.action == 'build_release_upload' ) )
|
178 | 101 | env:
|
179 | 102 | BOX_VERSION: ${{ env.BOX_VERSION }}
|
180 | 103 | run: |
|
181 |
| - export PATH="/usr/local/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:${PATH}" |
182 | 104 | ./upload_box_to_vagrantcloud.sh "${VAGRANT_CLOUD_USER}@${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
|
183 | 105 |
|
184 | 106 | cleanup:
|
|
0 commit comments