forked from ayufan-rock64/linux-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
90 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,102 @@ | ||
/** | ||
properties([ | ||
parameters([ | ||
string(defaultValue: '1.0', description: 'Current version number', name: 'VERSION'), | ||
text(defaultValue: '', description: 'A list of changes', name: 'CHANGES'), | ||
booleanParam(defaultValue: false, description: 'If build should be marked as pre-release', name: 'PRERELEASE'), | ||
string(defaultValue: 'ayufan-pine64', description: 'GitHub username or organization', name: 'GITHUB_USER'), | ||
string(defaultValue: 'build-pine64-image', description: 'GitHub repository', name: 'GITHUB_REPO'), | ||
]) | ||
]) | ||
*/ | ||
pipeline { | ||
// parameters { | ||
// string ( | ||
// defaultValue: '1.0', | ||
// description: 'Current version number', | ||
// name : 'VERSION') | ||
// text ( | ||
// defaultValue: '', | ||
// description: 'A list of changes', | ||
// name : 'CHANGES') | ||
// booleanParam ( | ||
// defaultValue: false, | ||
// description: 'If build should be marked as pre-release', | ||
// name : 'PRERELEASE') | ||
// string ( | ||
// defaultValue: '1.0', | ||
// description: 'GitHub username or organization', | ||
// name : 'GITHUB_USER') | ||
// string ( | ||
// defaultValue: '1.0', | ||
// description: 'GitHub repository', | ||
// name : 'GITHUB_REPO') | ||
// } | ||
|
||
node('docker && linux-build') { | ||
timestamps { | ||
wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) { | ||
stage "Environment" | ||
checkout scm | ||
agent { | ||
dockerfile { | ||
dir 'build-environment' | ||
label 'docker && linux-build' | ||
args '--privileged -u 0:0' | ||
} | ||
} | ||
environment { | ||
USE_CCACHE = 'true' | ||
RELEASE_NAME = "$RELEASE_NAME" | ||
RELEASE = "$BUILD_NUMBER" | ||
CCACHE_DIR = "$WORKSPACE/ccache" | ||
PRERELEASE = "$PRERELEASE" | ||
GITHUB_USER = "$GITHUB_USER" | ||
GITHUB_REPO = "$GITHUB_REPO" | ||
} | ||
options { | ||
timestamps() | ||
} | ||
|
||
def environment = docker.build('build-environment:build-pine64-image', 'build-environment') | ||
stages { | ||
stage('Prepare') { | ||
steps { | ||
sh 'ccache -M 0 -F 0' | ||
sh 'git clean -ffdx -e ccache' | ||
} | ||
} | ||
|
||
stage('Build') { | ||
steps { | ||
sh 'make' | ||
} | ||
} | ||
|
||
environment.inside("--privileged -u 0:0") { | ||
withEnv([ | ||
"USE_CCACHE=true", | ||
"RELEASE_NAME=$VERSION", | ||
"RELEASE=$BUILD_NUMBER" | ||
]) { | ||
stage 'Prepare' | ||
sh '''#!/bin/bash | ||
set +xe | ||
export CCACHE_DIR=$WORKSPACE/ccache | ||
ccache -M 0 -F 0 | ||
git clean -ffdx -e ccache | ||
''' | ||
stage('Release') { | ||
steps { | ||
sh '''#!/bin/bash | ||
set -xe | ||
shopt -s nullglob | ||
stage 'Build' | ||
sh '''#!/bin/bash | ||
set +xe | ||
export CCACHE_DIR=$WORKSPACE/ccache | ||
make | ||
''' | ||
} | ||
|
||
withEnv([ | ||
"VERSION=$VERSION", | ||
"CHANGES=$CHANGES", | ||
"PRERELEASE=$PRERELEASE", | ||
"GITHUB_USER=$GITHUB_USER", | ||
"GITHUB_REPO=$GITHUB_REPO" | ||
]) { | ||
stage 'Release' | ||
sh '''#!/bin/bash | ||
set -xe | ||
shopt -s nullglob | ||
github-release release \ | ||
--tag "${VERSION}" \ | ||
--name "$VERSION: $BUILD_TAG" \ | ||
--description "${CHANGES}\n\n${BUILD_URL}" \ | ||
--draft | ||
github-release release \ | ||
for file in *.xz *.deb; do | ||
github-release upload \ | ||
--tag "${VERSION}" \ | ||
--name "$VERSION: $BUILD_TAG" \ | ||
--description "${CHANGES}\n\n${BUILD_URL}" \ | ||
--draft | ||
for file in *.xz *.deb; do | ||
github-release upload \ | ||
--tag "${VERSION}" \ | ||
--name "$(basename "$file")" \ | ||
--file "$file" & | ||
done | ||
--name "$(basename "$file")" \ | ||
--file "$file" & | ||
done | ||
wait | ||
wait | ||
if [[ "$PRERELEASE" == "true" ]]; then | ||
github-release edit \ | ||
--tag "${VERSION}" \ | ||
--name "$VERSION: $BUILD_TAG" \ | ||
--description "${CHANGES}\n\n${BUILD_URL}" \ | ||
--pre-release | ||
else | ||
github-release edit \ | ||
--tag "${VERSION}" \ | ||
--name "$VERSION: $BUILD_TAG" \ | ||
--description "${CHANGES}\n\n${BUILD_URL}" | ||
fi | ||
''' | ||
} | ||
if [[ "$PRERELEASE" == "true" ]]; then | ||
github-release edit \ | ||
--tag "${VERSION}" \ | ||
--name "$VERSION: $BUILD_TAG" \ | ||
--description "${CHANGES}\n\n${BUILD_URL}" \ | ||
--pre-release | ||
else | ||
github-release edit \ | ||
--tag "${VERSION}" \ | ||
--name "$VERSION: $BUILD_TAG" \ | ||
--description "${CHANGES}\n\n${BUILD_URL}" | ||
fi | ||
''' | ||
} | ||
} | ||
} | ||
|
||
post { | ||
always { | ||
sh 'git clean -ffdx -e ccache' | ||
} | ||
} | ||
} |