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.
This reverts commit e00164e.
- Loading branch information
Showing
1 changed file
with
75 additions
and
90 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,102 +1,87 @@ | ||
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') | ||
// } | ||
/** | ||
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'), | ||
]) | ||
]) | ||
*/ | ||
|
||
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() | ||
} | ||
node('docker && linux-build') { | ||
timestamps { | ||
wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) { | ||
stage "Environment" | ||
checkout scm | ||
|
||
stages { | ||
stage('Prepare') { | ||
steps { | ||
sh 'ccache -M 0 -F 0' | ||
sh 'git clean -ffdx -e ccache' | ||
} | ||
} | ||
|
||
stage('Build') { | ||
steps { | ||
sh 'make' | ||
} | ||
} | ||
def environment = docker.build('build-environment:build-pine64-image', 'build-environment') | ||
|
||
stage('Release') { | ||
steps { | ||
sh '''#!/bin/bash | ||
set -xe | ||
shopt -s nullglob | ||
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 | ||
''' | ||
|
||
github-release release \ | ||
--tag "${VERSION}" \ | ||
--name "$VERSION: $BUILD_TAG" \ | ||
--description "${CHANGES}\n\n${BUILD_URL}" \ | ||
--draft | ||
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 | ||
for file in *.xz *.deb; do | ||
github-release upload \ | ||
github-release release \ | ||
--tag "${VERSION}" \ | ||
--name "$(basename "$file")" \ | ||
--file "$file" & | ||
done | ||
--name "$VERSION: $BUILD_TAG" \ | ||
--description "${CHANGES}\n\n${BUILD_URL}" \ | ||
--draft | ||
wait | ||
for file in *.xz *.deb; do | ||
github-release upload \ | ||
--tag "${VERSION}" \ | ||
--name "$(basename "$file")" \ | ||
--file "$file" & | ||
done | ||
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 | ||
''' | ||
} | ||
} | ||
} | ||
wait | ||
post { | ||
always { | ||
sh 'git clean -ffdx -e ccache' | ||
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 | ||
''' | ||
} | ||
} | ||
} | ||
} | ||
} |