summaryrefslogtreecommitdiff
path: root/.github/workflows/vyos-rolling-nightly-build.yml
blob: a12fbb01fdb928d0aa3bdf3fa7f64ddb03cce0b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
name: VyOS rolling nightly build

on:
  schedule:
    - cron: "0 0 * * *"

  workflow_dispatch:
    inputs:
      BUILD_BY:
        description: 'Builder identifier (default: autobuild@vyos.net)'
        default: ''
      build_version:
        description: 'Version number (default: 1.5-rolling-ISO8601-TIMESTAMP)'
        default: ''
      SKIP_SMOKETEST_RAID1:
        description: 'Skip RAID1 Test'
        required: true
        type: boolean
        default: false
      SKIP_SMOKETEST_SYSTEM:
        description: 'Skip CLI smoketest'
        required: true
        type: boolean
        default: false
      SKIP_SMOKETEST_CONFIG:
        description: 'Skip config load test'
        required: true
        type: boolean
        default: false
      SKIP_SNAPSHOT_S3_UPLOAD:
        description: 'Skip snapshot upload to S3'
        required: true
        type: boolean
        default: false
      SKIP_RELEASE_PUBLISHING:
        description: 'Skip release publishing'
        required: true
        type: boolean
        default: false
      SKIP_SLACK_NOTIFICATIONS:
        description: 'Skip Slack notifications'
        required: true
        type: boolean
        default: false
      SKIP_DOWNLOADS_PAGE_UPDATE:
        description: 'Skip downloads page update'
        required: true
        type: boolean
        default: false

env:
  BUILD_BY: autobuild@vyos.net
  DEBIAN_MIRROR: http://deb.debian.org/debian/
  VYOS_MIRROR: https://rolling-packages.vyos.net/current/
  DOCKER_CALL_ON_KVM_HOST_WITH_IMAGE_PULL: docker run --rm --privileged --pull=always -v ~/vyos-build:/vyos -w /vyos vyos/vyos-build:current

jobs:
  build_iso:
    runs-on: ubuntu-24.04
    permissions:
      contents: write
    container:
      image: vyos/vyos-build:current
      options: --sysctl net.ipv6.conf.lo.disable_ipv6=0 --privileged
    outputs:
      build_version: ${{ steps.set_env_variables.outputs.build_version }}
    steps:
      ### Initialization ###
      - uses: actions/checkout@v4
      - name: "Initialization: set env variables"
        id: set_env_variables
        run: |
          set -x
          if [ -n "${{ github.event.inputs.BUILD_BY }}" ]; then
            echo "BUILD_BY=${{ github.event.inputs.BUILD_BY }}" >> $GITHUB_ENV
          fi
          if [ -z "${{ github.event.inputs.build_version }}" ]; then
            echo "build_version=1.5-rolling-$(date -u +%Y%m%d%H%M)" >> $GITHUB_OUTPUT
          else
            echo "build_version=${{ github.event.inputs.build_version }}" >> $GITHUB_OUTPUT
          fi
          echo "TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
          echo "PREVIOUS_SUCCESS_BUILD_TIMESTAMP=$(cat version.json | jq -r '.[0].timestamp')" >> $GITHUB_ENV

      - name: Clone vyos-build source code
        uses: actions/checkout@v4
        with:
          repository: vyos/vyos-build
          path: vyos-build

      - name: Build generic ISO image
        id: build_generic_iso
        run: |
          cd vyos-build
          sudo --preserve-env ./build-vyos-image \
          --architecture amd64 \
          --build-by $BUILD_BY \
          --build-type release \
          --custom-package vyos-1x-smoketest \
          --debian-mirror $DEBIAN_MIRROR \
          --version ${{ steps.set_env_variables.outputs.build_version }} \
          --vyos-mirror $VYOS_MIRROR \
          generic
          # move artifact one level up for minisign
          mv build/vyos-${{ steps.set_env_variables.outputs.build_version }}-generic-amd64.iso ..

      - name: Sign generic ISO image
        shell: bash
        run: |
          ls -al
          echo "${{ secrets.minisign_private_key }}" > /tmp/minisign.key
          echo ${{ secrets.minisign_password }} | $GITHUB_WORKSPACE/bin/minisign -s /tmp/minisign.key -Sm vyos-${{ steps.set_env_variables.outputs.build_version }}-generic-amd64.iso
          echo "${{ secrets.minisign_public_key }}" > /tmp/minisign.pub
          $GITHUB_WORKSPACE/bin/minisign -Vm vyos-${{ steps.set_env_variables.outputs.build_version }}-generic-amd64.iso -x vyos-${{ steps.set_env_variables.outputs.build_version }}-generic-amd64.iso.minisig -p /tmp/minisign.pub
          ls -al
          rm /tmp/minisign.key /tmp/minisign.pub

      - uses: actions/upload-artifact@v4
        with:
          name: vyos-${{ steps.set_env_variables.outputs.build_version }}-generic-amd64
          path: vyos-${{ steps.set_env_variables.outputs.build_version }}-*
          retention-days: 30
          if-no-files-found: error

  test_smoketest_cli:
    needs: build_iso
    runs-on: ubuntu-24.04
    if: ${{ !inputs.SKIP_SMOKETEST_SYSTEM }}
    steps:
      # We need the test script from vyos-build repo
      - name: Clone vyos-build source code
        uses: actions/checkout@v4
        with:
          repository: vyos/vyos-build
      - uses: actions/download-artifact@v4
        with:
          name: vyos-${{ needs.build_iso.outputs.build_version }}-generic-amd64
          path: build
      - name: VyOS CLI smoketests
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USER }}
          port: ${{ secrets.SSH_PORT }}
          key: ${{ secrets.SSH_KEY }}
          timeout: 15m
          command_timeout: 180m
          script_stop: true
          script: |
            ${{ env.DOCKER_CALL_ON_KVM_HOST_WITH_IMAGE_PULL }} /bin/bash -c "sudo make test | tee smoketest_system.log"

  test_config_load:
    needs: build_iso
    runs-on: ubuntu-24.04
    if: ${{ !inputs.SKIP_SMOKETEST_CONFIG }}
    steps:
      # We need the test script from vyos-build repo
      - name: Clone vyos-build source code
        uses: actions/checkout@v4
        with:
          repository: vyos/vyos-build
      - uses: actions/download-artifact@v4
        with:
          name: vyos-${{ needs.build_iso.outputs.build_version }}-generic-amd64
          path: build
      - name: VyOS config load tests
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USER }}
          port: ${{ secrets.SSH_PORT }}
          key: ${{ secrets.SSH_KEY }}
          timeout: 15m
          command_timeout: 180m
          script_stop: true
          script: |
            ${{ env.DOCKER_CALL_ON_KVM_HOST_WITH_IMAGE_PULL }} /bin/bash -c "sudo make testc | tee smoketest_configuration.log"

  test_raid1_install:
    needs: build_iso
    runs-on: ubuntu-24.04
    if: ${{ !inputs.SKIP_SMOKETEST_RAID1 }}
    steps:
      # We need the test script from vyos-build repo
      - name: Clone vyos-build source code
        uses: actions/checkout@v4
        with:
          repository: vyos/vyos-build
      - uses: actions/download-artifact@v4
        with:
          name: vyos-${{ needs.build_iso.outputs.build_version }}-generic-amd64
          path: build
      - name: RAID1 installation tests
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USER }}
          port: ${{ secrets.SSH_PORT }}
          key: ${{ secrets.SSH_KEY }}
          timeout: 15m
          command_timeout: 180m
          script_stop: true
          script: |
            ${{ env.DOCKER_CALL_ON_KVM_HOST_WITH_IMAGE_PULL }} /bin/bash -c "set -o pipefail && sudo make testraid | tee smoketest_raid.log"

  publish:
    needs:
      - test_config_load
      - test_raid1_install
      - test_smoketest_cli
    runs-on: ubuntu-24.04
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
      - name: Clone vyos-build source code
        uses: actions/checkout@v4
        with:
          repository: vyos/vyos-build
          path: vyos-build
      - name: Clone vyos-1x source code
        uses: actions/checkout@v4
        with:
          repository: vyos/vyos-1x
          path: vyos-1x
      -  id: commit_ids
         shell: bash
         run: |
          cd vyos-build
          echo "CHANGELOG_COMMIT_build=$(git log --since "${{ env.PREVIOUS_SUCCESS_BUILD_TIMESTAMP }}" --format="%H" --reverse | head -n1)" >> $GITHUB_OUTPUT
          cd ../vyos-1x
          echo "CHANGELOG_COMMIT_1x=$(git log --since "${{ env.PREVIOUS_SUCCESS_BUILD_TIMESTAMP }}" --format="%H" --reverse | head -n1)" >> $GITHUB_OUTPUT

      - name: "Release publishing: generate changelog for vyos-1x"
        if: ${{ !inputs.SKIP_RELEASE_PUBLISHING }}
        id: generate_changelog_for_vyos-1x
        uses: mikepenz/release-changelog-builder-action@v4.1.0
        with:
          owner: "vyos"
          repo: "vyos-1x"
          fetchReviewers: false
          fromTag: ${{ steps.commit_ids.outputs.CHANGELOG_COMMIT_1x }}
          toTag: HEAD
          configurationJson: |
            {
              "categories": [{"title": "", "labels": []}],
              "template": "#{{CHANGELOG}}",
              "pr_template": "- #{{TITLE}}\n   - PR: vyos/vyos-1x##{{NUMBER}}"
            }

      - name: "Release publishing: generate changelog for vyos-build"
        if: ${{ !inputs.SKIP_RELEASE_PUBLISHING && env.CHANGELOG_COMMIT_build }}
        id: generate_changelog_for_vyos-build
        uses: mikepenz/release-changelog-builder-action@v4.1.0
        with:
          owner: "vyos"
          repo: "vyos-build"
          fetchReviewers: false
          fromTag: ${{ steps.commit_ids.outputs.CHANGELOG_COMMIT_build }}
          toTag: HEAD
          configurationJson: |
            {
              "categories": [{"title": "", "labels": []}],
              "template": "#{{CHANGELOG}}",
              "pr_template": "- #{{TITLE}}\n   - PR: vyos/vyos-build##{{NUMBER}}"
            }

      - name: "Release publishing: generate CHANGELOG.md"
        id: generate_changelog_md
        if: ${{ !inputs.SKIP_RELEASE_PUBLISHING }}
        run: |
          cat <<EOF > CHANGELOG.md
          ## vyos-1x
          ${{ steps.generate_changelog_for_vyos-1x.outputs.changelog }}
          ## vyos-build
          ${{ steps.generate-build-changelog.outputs.changelog }}
          EOF
          cat CHANGELOG.md

      - name: "Release publishing: create version.json"
        if: ${{ !inputs.SKIP_RELEASE_PUBLISHING }}
        id: create_version_json
        uses: jsdaniell/create-json@v1.2.3
        with:
          name: "version.json"
          json: |
            [
              {
                "url": "https://github.com/vyos/vyos-rolling-nightly-builds/releases/download/vyos-${{ needs.build_iso.outputs.build_version }}-generic-amd64/vyos-${{ needs.build_iso.outputs.build_version }}-generic-amd64.iso",
                "version": "${{ needs.build_iso.outputs.build_version }}",
                "timestamp": "${{ env.TIMESTAMP }}"
              }
            ]

      - name: "Release publishing: check if the repository was modified during runtime to prevent autocommit failure"
        id: check_if_the_repository_was_modified_during_runtime
        if: ${{ !inputs.SKIP_RELEASE_PUBLISHING }}
        run: |
          sudo chown -R $(whoami):$(whoami) ./*
          git pull --autostash --rebase

      - name: "Release publishing: create autocommit and tag"
        id: create_autocommit_and_tag
        if: ${{ !inputs.SKIP_RELEASE_PUBLISHING }}
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          tagging_message: vyos-${{ needs.build_iso.outputs.build_version }}-generic-amd64
          commit_message: vyos-${{ needs.build_iso.outputs.build_version }}-generic-amd64

      - name: "Release publishing: publish release"
        id: publish_release
        if: github.ref == 'refs/heads/main'
        uses: softprops/action-gh-release@v1
        with:
          body_path: CHANGELOG.md
          tag_name: ${{ needs.build_iso.outputs.build_version }}
          fail_on_unmatched_files: true
          files: |
            ./vyos-${{ needs.build_iso.outputs.build_version }}-generic-amd64.iso
            ./vyos-${{ needs.build_iso.outputs.build_version }}-generic-amd64.iso.minisig