forked from RPi-Distro/pi-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
121 lines (102 loc) · 4.37 KB
/
azure-pipelines.yml
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
# Use Azure Build Pipeline for automated rpi images
trigger:
tags:
include:
- '*'
branches:
include:
- master
variables:
img_name: f2fsRaspbian
# config options for pi-gen
stage_list: 'stage0 stage1 stage2'
rootfs_type: f2fs
pool:
vmImage: 'ubuntu-18.04' # avoids tons of: 'qemu: Unsupported syscall: 383' error messages)
#container:
# image: ubuntu:latest
# options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
# fix for sudo
# steps:
# - script: |
# /tmp/docker exec -t -u 0 ci-container \
# sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
# displayName: Set up sudo
jobs:
- job: buildimage
timeoutInMinutes: 360
displayName: Build raspbian image and publish as github release
steps:
- task: PowerShell@2
displayName: Set date time stamp variable
inputs:
targetType: 'inline'
script: |
$Time = Get-Date
$Time = $Time.ToUniversalTime()
$date = $Time.ToString("yyyy-MM-dd HH:mmK")
Write-Host "##vso[task.setvariable variable=datetimestamp]$date"
errorActionPreference: 'continue'
- script: |
kversion=$(uname -r)
sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get remove -y --purge man-db && sudo apt-get install coreutils quilt parted qemu-user-static:i386 debootstrap zerofree zip dosfstools bsdtar libcap2-bin grep rsync xz-utils file git curl f2fs-tools && sudo apt-get install -y linux-modules-extra-$kversion && sudo modprobe -v f2fs
displayName: Install basic build dependencies and f2fs module based on kernel version
- script: pwd && ls -la && env && ls -la work/*/*/rootfs || true
displayName: '[INFO] Check environment and paths'
env: # these are not upper cased, in constrast to variables
TESTVAR: testvalue
# MAIN Script call to build all specified stage in stage_list
- script: sudo -E ./build.sh
displayName: Main Build (build.sh)
# alternative for container based build
# - script: PRESERVE_CONTAINER=1 ./build-docker.sh
- script: |
pwd
mkdir -p work/x/y/rootfs || true
sudo mkdir work/x/y/rootfs/root || true
sudo chmod 700 work/x/y/rootfs/root || true
ls -la work/x/y/rootfs/root || true
sudo ls -la work/x/y/rootfs/root || true
touch work/_dirty || true
mkdir -p deploy/test-date/subfolder/ || true
touch deploy/test-date/subfolder/test.zip || true
echo "some content" >> deploy/test-date/subfolder/test.zip || true
displayName: '[TEST] Fake deployment + touching work dir'
continueOnError: true
condition: false
- script: ls -la deploy/ || true
displayName: '[INFO] List deploy folder files'
- script: ls -la $(System.DefaultWorkingDirectory) && echo $(System.DefaultWorkingDirectory)
displayName: '[INFO] List working directory'
# do not make the publish task below fail, in case only stage0 is built when testing the pipeline
- script: mkdir deploy || true
displayName: Ensure deploy directory exists.
- publish: '$(System.DefaultWorkingDirectory)/deploy'
displayName: 'Publish artifact: images from deploy folder'
artifact: deployable-images
- script: find $(System.DefaultWorkingDirectory)/deploy || true
displayName: '[INFO] List contents of deploy dir'
- task: CopyFiles@2
inputs:
sourceFolder: '$(System.DefaultWorkingDirectory)/deploy'
contents: '**' # recursive
targetFolder: $(Build.ArtifactStagingDirectory)
cleanTargetFolder: true
overWrite: true
flattenFolders: false
preserveTimestamp: false
- script: echo $(Build.ArtifactStagingDirectory) && find $(Build.ArtifactStagingDirectory)
displayName: '[INFO] List contents of artifact staging directory'
- task: GithubRelease@0
displayName: 'Create GitHub Release'
inputs:
isDraft: true
title: 'Raspbian image with f2fs filesystem ($(datetimestamp))'
gitHubConnection: phlogi-personal
repositoryName: phlogi/pi-gen
tagSource: manual
tag: $(Build.BuildNumber)
assets: |
$(Build.ArtifactStagingDirectory)/**
# $(Build.ArtifactStagingDirectory)/*.zip
# $(Build.ArtifactStagingDirectory)/*.img