mirror of https://github.com/portainer/portainer
feat(build-system): introduce Azure DevOps support (#2666)
parent
fca4f619b5
commit
576f369152
|
@ -1,44 +0,0 @@
|
|||
version: 1.0.{build}
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
- Ubuntu
|
||||
environment:
|
||||
matrix:
|
||||
- ARCH: amd64
|
||||
- ARCH: arm
|
||||
- ARCH: arm64
|
||||
- ARCH: ppc64le
|
||||
- ARCH: s390x
|
||||
DOCKER_USER:
|
||||
secure: JapmC7j5F0mY3j/MVzU+Cw==
|
||||
DOCKER_PASS:
|
||||
secure: QGlCLNWzPD0HL8ipkohVic45/yU3bVOdjn0IiV6NnSQ=
|
||||
matrix:
|
||||
exclude:
|
||||
- image: Visual Studio 2017
|
||||
ARCH: arm
|
||||
- image: Visual Studio 2017
|
||||
ARCH: arm64
|
||||
- image: Visual Studio 2017
|
||||
ARCH: ppc64le
|
||||
- image: Visual Studio 2017
|
||||
ARCH: s390x
|
||||
branches:
|
||||
except:
|
||||
- master
|
||||
stack:
|
||||
- node 9, go 1.10
|
||||
install:
|
||||
- yarn install
|
||||
- npm install -g rebase-docker-image
|
||||
init:
|
||||
- sh: export IMAGE=linux
|
||||
- cmd: SET IMAGE=windows
|
||||
- ps: >-
|
||||
if (!(Test-Path ~/.docker)) { mkdir ~/.docker };
|
||||
Set-Content -Value '{ "experimental": "enabled" }' -Path ~/.docker/config.json -Encoding Ascii
|
||||
build_script:
|
||||
- sh: yarn grunt appveyorbuild:$IMAGE:$ARCH
|
||||
- cmd: yarn grunt appveyorbuild:%IMAGE%:%ARCH%
|
||||
- sh: sudo bash build/ci-linux.sh $IMAGE $ARCH $DOCKER_USER $DOCKER_PASS $APPVEYOR_REPO_BRANCH $APPVEYOR_PULL_REQUEST_NUMBER
|
||||
- cmd: powershell -Command "& .\\build\\ci-windows.ps1"
|
|
@ -1,61 +0,0 @@
|
|||
version: 1.0.{build}
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
- Ubuntu
|
||||
environment:
|
||||
matrix:
|
||||
- ARCH: amd64
|
||||
- ARCH: arm
|
||||
- ARCH: arm64
|
||||
- ARCH: ppc64le
|
||||
- ARCH: s390x
|
||||
DOCKER_USER:
|
||||
secure: JapmC7j5F0mY3j/MVzU+Cw==
|
||||
DOCKER_PASS:
|
||||
secure: QGlCLNWzPD0HL8ipkohVic45/yU3bVOdjn0IiV6NnSQ=
|
||||
PORTAINER_VERSION: "1.19.2"
|
||||
matrix:
|
||||
exclude:
|
||||
- image: Visual Studio 2017
|
||||
ARCH: arm
|
||||
- image: Visual Studio 2017
|
||||
ARCH: arm64
|
||||
- image: Visual Studio 2017
|
||||
ARCH: ppc64le
|
||||
- image: Visual Studio 2017
|
||||
ARCH: s390x
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
stack: node 9, go 1.10
|
||||
artifacts:
|
||||
- path: 'portainer-$(PORTAINER_VERSION)-$(IMAGE)-$(ARCH).tar.gz'
|
||||
type: file
|
||||
- path: 'portainer-$(PORTAINER_VERSION)-$(IMAGE)-$(ARCH)-checksum.txt'
|
||||
type: file
|
||||
install:
|
||||
- yarn install
|
||||
- npm install -g rebase-docker-image
|
||||
init:
|
||||
- sh: export IMAGE=linux
|
||||
- cmd: SET IMAGE=windows
|
||||
- ps: >-
|
||||
if (!(Test-Path ~/.docker)) { mkdir ~/.docker }
|
||||
Set-Content -Value '{ "experimental": "enabled" }' -Path ~/.docker/config.json -Encoding Ascii
|
||||
build_script:
|
||||
- sh: yarn grunt appveyorbuild:$IMAGE:$ARCH
|
||||
- cmd: yarn grunt appveyorbuild:%IMAGE%:%ARCH%
|
||||
- sh: sudo bash build/release-linux.sh $IMAGE $ARCH $PORTAINER_VERSION $DOCKER_USER $DOCKER_PASS
|
||||
- cmd: powershell -Command "& .\\build\\release-windows.ps1"
|
||||
test: off
|
||||
deploy:
|
||||
release: Release $(PORTAINER_VERSION)
|
||||
description: ''
|
||||
provider: GitHub
|
||||
auth_token:
|
||||
secure: BRYVGj94QlFBCMoO8yhSu+AGqKNV1+03LJEFrNUTRzo5erXfUHUIi/rgztnxfSGW
|
||||
artifact: /portainer-$(PORTAINER_VERSION)-$(IMAGE)-$(ARCH).*/
|
||||
draft: true
|
||||
prerelease: false
|
||||
on:
|
||||
branch: master
|
|
@ -0,0 +1,17 @@
|
|||
param (
|
||||
[string]$platform,
|
||||
[string]$arch
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop";
|
||||
|
||||
$binary = "portainer.exe"
|
||||
$project_path = (Get-ITEM -Path env:APPVEYOR_BUILD_FOLDER).Value
|
||||
|
||||
New-Item -Name dist -Path "$project_path" -ItemType Directory | Out-Null
|
||||
Set-Location -Path "$project_path\api\cmd\portainer"
|
||||
|
||||
C:\go\bin\go.exe get -t -d -v ./...
|
||||
C:\go\bin\go.exe build -v
|
||||
|
||||
Move-Item -Path "$($binary)" -Destination "..\..\..\dist"
|
|
@ -0,0 +1,9 @@
|
|||
binary="portainer"
|
||||
mkdir -p dist
|
||||
|
||||
cd 'api/cmd/portainer'
|
||||
|
||||
go get -t -d -v ./...
|
||||
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags '-s'
|
||||
|
||||
mv "${binary}" "../../../dist/portainer"
|
|
@ -0,0 +1,24 @@
|
|||
param (
|
||||
[string]$platform,
|
||||
[string]$arch
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop";
|
||||
|
||||
$binary = "portainer.exe"
|
||||
$project_path = (Get-ITEM -Path env:BUILD_SOURCESDIRECTORY).Value
|
||||
|
||||
Set-Item env:GOPATH "$project_path\api"
|
||||
|
||||
New-Item -Name dist -Path "$project_path" -ItemType Directory | Out-Null
|
||||
New-Item -Name portainer -Path "$project_path\api\src\github.com\" -ItemType Directory | Out-Null
|
||||
|
||||
Copy-Item -Path "$project_path\api" -Destination "$project_path\api\src\github.com\portainer" -Recurse -Force -ErrorAction:SilentlyContinue
|
||||
Rename-Item -Path "$project_path\api\src\github.com\portainer\api" -NewName "portainer" -ErrorAction:SilentlyContinue
|
||||
|
||||
Set-Location -Path "$project_path\api\cmd\portainer"
|
||||
|
||||
go.exe get -t -d -v ./...
|
||||
go.exe build -v
|
||||
|
||||
Move-Item -Path "$project_path\api\cmd\portainer\$($binary)" -Destination "$project_path\dist"
|
|
@ -0,0 +1,15 @@
|
|||
export GOPATH="$BUILD_SOURCESDIRECTORY/api"
|
||||
|
||||
binary="portainer"
|
||||
|
||||
mkdir -p dist
|
||||
mkdir -p api/src/github.com/portainer/
|
||||
|
||||
cp -R api/ api/src/github.com/portainer/portainer/
|
||||
|
||||
cd 'api/cmd/portainer'
|
||||
|
||||
go get -t -d -v ./...
|
||||
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags '-s'
|
||||
|
||||
mv "$BUILD_SOURCESDIRECTORY/api/cmd/portainer/$binary" "$BUILD_SOURCESDIRECTORY/dist/portainer"
|
|
@ -0,0 +1,13 @@
|
|||
param (
|
||||
[string]$docker_version
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop";
|
||||
|
||||
New-Item -Path "docker-binary" -ItemType Directory | Out-Null
|
||||
|
||||
$download_folder = "docker-binary"
|
||||
|
||||
Invoke-WebRequest -O "$($download_folder)/docker-binaries.zip" "https://download.docker.com/win/static/stable/x86_64/docker-$($docker_version).zip"
|
||||
Expand-Archive -Path "$($download_folder)/docker-binaries.zip" -DestinationPath "$($download_folder)"
|
||||
Move-Item -Path "$($download_folder)/docker/docker.exe" -Destination "dist"
|
40
gruntfile.js
40
gruntfile.js
|
@ -51,6 +51,10 @@ module.exports = function(grunt) {
|
|||
grunt.task.run(['config:prod', 'clean:all', 'shell:buildBinary:' + p + ':' + a, 'shell:downloadDockerBinary:' + p + ':' + a, 'before-copy', 'copy:assets', 'after-copy']);
|
||||
});
|
||||
|
||||
grunt.task.registerTask('devopsbuild', 'devopsbuild:<platform>:<arch>', function(p, a) {
|
||||
grunt.task.run(['config:prod', 'clean:all', 'shell:buildBinaryOnDevOps:' + p + ':' + a, 'shell:downloadDockerBinary:' + p + ':' + a, 'before-copy', 'copy:assets', 'after-copy']);
|
||||
});
|
||||
|
||||
grunt.registerTask('lint', ['eslint']);
|
||||
grunt.registerTask('run-dev', ['build', 'shell:run:' + arch, 'watch:build']);
|
||||
grunt.registerTask('clear', ['clean:app']);
|
||||
|
@ -261,13 +265,32 @@ gruntfile_cfg.replace = {
|
|||
|
||||
function shell_buildBinary(p, a) {
|
||||
var binfile = 'dist/portainer-' + p + '-' + a;
|
||||
if (p === 'linux') {
|
||||
return [
|
||||
'if [ -f ' + ((p === 'windows') ? binfile + '.exe' : binfile) + ' ]; then',
|
||||
'if [ -f ' + (binfile) + ' ]; then',
|
||||
'echo "Portainer binary exists";',
|
||||
'else',
|
||||
'build/build_in_container.sh ' + p + ' ' + a + ';',
|
||||
'build/build_binary.sh ' + p + ' ' + a + ';',
|
||||
'fi'
|
||||
].join(' ');
|
||||
} else {
|
||||
return [
|
||||
'powershell -Command "& {if (Get-Item -Path ' + binfile + '.exe -ErrorAction:SilentlyContinue) {',
|
||||
'Write-Host "Portainer binary exists"',
|
||||
'} else {',
|
||||
'& ".\\build\\build_binary.ps1" -platform ' + p + ' -arch ' + a + '',
|
||||
'}}"'
|
||||
].join(' ');
|
||||
}
|
||||
}
|
||||
|
||||
function shell_buildBinaryOnDevOps(p, a) {
|
||||
var binfile = 'portainer-' + p + '-' + a;
|
||||
if (p === 'linux') {
|
||||
return 'build/build_binary_devops.sh ' + p + ' ' + a + ';'
|
||||
} else {
|
||||
return 'powershell -Command ".\\build\\build_binary_devops.ps1 -platform ' + p + ' -arch ' + a + '"'
|
||||
}
|
||||
}
|
||||
|
||||
function shell_run(arch) {
|
||||
|
@ -283,17 +306,28 @@ function shell_downloadDockerBinary(p, a) {
|
|||
var ip = ((ps[p] === undefined) ? p : ps[p]);
|
||||
var ia = ((as[a] === undefined) ? a : as[a]);
|
||||
var binaryVersion = ((p === 'windows' ? '<%= shippedDockerVersionWindows %>' : '<%= shippedDockerVersion %>'));
|
||||
if (p === 'linux') {
|
||||
return [
|
||||
'if [ -f ' + ((p === 'windows') ? 'dist/docker.exe' : 'dist/docker') + ' ]; then',
|
||||
'if [ -f dist/docker ]; then',
|
||||
'echo "Docker binary exists";',
|
||||
'else',
|
||||
'build/download_docker_binary.sh ' + ip + ' ' + ia + ' ' + binaryVersion + ';',
|
||||
'fi'
|
||||
].join(' ');
|
||||
} else {
|
||||
return [
|
||||
'powershell -Command "& {if (Get-Item -Path dist/docker.exe -ErrorAction:SilentlyContinue) {',
|
||||
'Write-Host "Docker binary exists"',
|
||||
'} else {',
|
||||
'& ".\\build\\download_docker_binary.ps1" -docker_version ' + binaryVersion + '',
|
||||
'}}"'
|
||||
].join(' ');
|
||||
}
|
||||
}
|
||||
|
||||
gruntfile_cfg.shell = {
|
||||
buildBinary: { command: shell_buildBinary },
|
||||
buildBinaryOnDevOps: { command: shell_buildBinaryOnDevOps },
|
||||
run: { command: shell_run },
|
||||
downloadDockerBinary: { command: shell_downloadDockerBinary }
|
||||
};
|
Loading…
Reference in New Issue