Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 0b3ac3d

Browse files
committed
Automatically release a tagged version to github
Signed-off-by: Mathieu Champlon <[email protected]>
1 parent 76c1cce commit 0b3ac3d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Jenkinsfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pipeline {
3030
stash name: 'e2e'
3131
}
3232
if(!(env.BRANCH_NAME ==~ "PR-\\d+")) {
33+
stash name: 'artifacts', includes: '*.tar.gz', excludes: '*-e2e-*'
3334
archiveArtifacts '*.tar.gz'
3435
}
3536
} finally {
@@ -80,5 +81,32 @@ pipeline {
8081
}
8182
}
8283
}
84+
stage('Release') {
85+
agent {
86+
label "linux"
87+
}
88+
when {
89+
buildingTag()
90+
}
91+
steps {
92+
dir('src/github.com/docker/lunchbox') {
93+
deleteDir()
94+
sh 'rm -f *.tar.gz'
95+
unstash 'artifacts'
96+
release('docker/lunchbox')
97+
}
98+
}
99+
}
100+
}
101+
}
102+
103+
def release(repo) {
104+
withCredentials([[$class: 'StringBinding', credentialsId: 'github-release-token', variable: 'GITHUB_TOKEN']]) {
105+
def data = "{\"tag_name\": \"$BRANCH_NAME\", \"name\": \"$BRANCH_NAME\", \"draft\": true, \"prerelease\": true}"
106+
def url = "https://api.github.com/repos/$repo/releases"
107+
def reply = sh(returnStdout: true, script: "curl -sSf -H \"Authorization: token $GITHUB_TOKEN\" -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d '$data' $url")
108+
def release = readJSON text: reply
109+
url = release.upload_url.replace('{?name,label}', '')
110+
sh("ls *.tar.gz | xargs -i curl -sf -H \"Authorization: token $GITHUB_TOKEN\" -H \"Accept: application/json\" -H \"Content-type: application/gzip\" -X POST --data-binary \"@{}\" $url?name={}")
83111
}
84112
}

0 commit comments

Comments
 (0)