Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from thelamer/prerelease
Browse files Browse the repository at this point in the history
Adding Prerelease branch
  • Loading branch information
thelamer authored Jan 11, 2020
2 parents 7ad93e0 + f1f6cb2 commit d8578e3
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 68 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ RUN \
install -m755 -D jetty-runner /usr/bin/jetty-runner && \
echo "**** install booksonic ****" && \
if [ -z ${BOOKSONIC_RELEASE+x} ]; then \
BOOKSONIC_RELEASE=$(curl -sX GET "https://api.github.com/repos/popeen/Popeens-Subsonic/releases/latest" \
| jq -r '. | .tag_name'); \
BOOKSONIC_RELEASE=$(curl -sX GET "https://api.github.com/repos/popeen/Popeens-Subsonic/releases" \
| jq -r 'first(.[] | select(.prerelease==true)) | .tag_name'); \
fi && \
mkdir -p \
/app/booksonic && \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ RUN \
install -m755 -D jetty-runner /usr/bin/jetty-runner && \
echo "**** install booksonic ****" && \
if [ -z ${BOOKSONIC_RELEASE+x} ]; then \
BOOKSONIC_RELEASE=$(curl -sX GET "https://api.github.com/repos/popeen/Popeens-Subsonic/releases/latest" \
| jq -r '. | .tag_name'); \
BOOKSONIC_RELEASE=$(curl -sX GET "https://api.github.com/repos/popeen/Popeens-Subsonic/releases" \
| jq -r 'first(.[] | select(.prerelease==true)) | .tag_name'); \
fi && \
mkdir -p \
/app/booksonic && \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ RUN \
install -m755 -D jetty-runner /usr/bin/jetty-runner && \
echo "**** install booksonic ****" && \
if [ -z ${BOOKSONIC_RELEASE+x} ]; then \
BOOKSONIC_RELEASE=$(curl -sX GET "https://api.github.com/repos/popeen/Popeens-Subsonic/releases/latest" \
| jq -r '. | .tag_name'); \
BOOKSONIC_RELEASE=$(curl -sX GET "https://api.github.com/repos/popeen/Popeens-Subsonic/releases" \
| jq -r 'first(.[] | select(.prerelease==true)) | .tag_name'); \
fi && \
mkdir -p \
/app/booksonic && \
Expand Down
102 changes: 47 additions & 55 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ pipeline {
GITHUB_TOKEN=credentials('498b4638-2d02-4ce5-832d-8a57d01d97ab')
GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0')
GITLAB_NAMESPACE=credentials('gitlab-namespace-id')
EXT_GIT_BRANCH = 'master'
EXT_USER = 'popeen'
EXT_REPO = 'Popeens-Subsonic'
JSON_URL = 'https://api.github.com/repos/popeen/Popeens-Subsonic/releases'
JSON_PATH = 'first(.[] | select(.prerelease==true)) | .tag_name'
BUILD_VERSION_ARG = 'BOOKSONIC_RELEASE'
LS_USER = 'linuxserver'
LS_REPO = 'docker-booksonic'
Expand All @@ -44,7 +43,7 @@ pipeline {
script{
env.EXIT_STATUS = ''
env.LS_RELEASE = sh(
script: '''docker run --rm alexeiled/skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':latest 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
script: '''docker run --rm alexeiled/skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':prerelease 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
returnStdout: true).trim()
env.LS_RELEASE_NOTES = sh(
script: '''cat readme-vars.yml | awk -F \\" '/date: "[0-9][0-9].[0-9][0-9].[0-9][0-9]:/ {print $4;exit;}' | sed -E ':a;N;$!ba;s/\\r{0,1}\\n/\\\\n/g' ''',
Expand Down Expand Up @@ -101,21 +100,14 @@ pipeline {
/* ########################
External Release Tagging
######################## */
// If this is a stable github release use the latest endpoint from github to determine the ext tag
stage("Set ENV github_stable"){
// If this is a custom json endpoint parse the return to get external tag
stage("Set ENV custom_json"){
steps{
script{
env.EXT_RELEASE = sh(
script: '''curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .tag_name' ''',
script: '''curl -s ${JSON_URL} | jq -r ". | ${JSON_PATH}" ''',
returnStdout: true).trim()
}
}
}
// If this is a stable or devel github release generate the link for the build message
stage("Set ENV github_link"){
steps{
script{
env.RELEASE_LINK = 'https://github.com/' + env.EXT_USER + '/' + env.EXT_REPO + '/releases/tag/' + env.EXT_RELEASE
env.RELEASE_LINK = env.JSON_URL
}
}
}
Expand All @@ -129,10 +121,10 @@ pipeline {
}
}
}
// If this is a master build use live docker endpoints
// If this is a prerelease build use live docker endpoints
stage("Set ENV live build"){
when {
branch "master"
branch "prerelease"
environment name: 'CHANGE_ID', value: ''
}
steps {
Expand All @@ -153,7 +145,7 @@ pipeline {
// If this is a dev build use dev docker endpoints
stage("Set ENV dev build"){
when {
not {branch "master"}
not {branch "prerelease"}
environment name: 'CHANGE_ID', value: ''
}
steps {
Expand Down Expand Up @@ -226,7 +218,7 @@ pipeline {
// Use helper containers to render templated files
stage('Update-Templates') {
when {
branch "master"
branch "prerelease"
environment name: 'CHANGE_ID', value: ''
expression {
env.CONTAINER_NAME != null
Expand All @@ -237,15 +229,15 @@ pipeline {
set -e
TEMPDIR=$(mktemp -d)
docker pull linuxserver/jenkins-builder:latest
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=master -v ${TEMPDIR}:/ansible/jenkins linuxserver/jenkins-builder:latest
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=prerelease -v ${TEMPDIR}:/ansible/jenkins linuxserver/jenkins-builder:latest
CURRENTHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8)
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
NEWHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8)
if [[ "${CURRENTHASH}" != "${NEWHASH}" ]]; then
mkdir -p ${TEMPDIR}/repo
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
cd ${TEMPDIR}/repo/${LS_REPO}
git checkout -f master
git checkout -f prerelease
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/
Expand Down Expand Up @@ -277,7 +269,7 @@ pipeline {
// Exit the build if the Templated files were just updated
stage('Template-exit') {
when {
branch "master"
branch "prerelease"
environment name: 'CHANGE_ID', value: ''
environment name: 'FILES_UPDATED', value: 'true'
expression {
Expand Down Expand Up @@ -396,7 +388,7 @@ pipeline {
// Take the image we just built and dump package versions for comparison
stage('Update-packages') {
when {
branch "master"
branch "prerelease"
environment name: 'CHANGE_ID', value: ''
environment name: 'EXIT_STATUS', value: ''
}
Expand Down Expand Up @@ -424,7 +416,7 @@ pipeline {
echo "Package tag sha from current packages in buit container is ${NEW_PACKAGE_TAG} comparing to old ${PACKAGE_TAG} from github"
if [ "${NEW_PACKAGE_TAG}" != "${PACKAGE_TAG}" ]; then
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/${LS_REPO}
git --git-dir ${TEMPDIR}/${LS_REPO}/.git checkout -f master
git --git-dir ${TEMPDIR}/${LS_REPO}/.git checkout -f prerelease
cp ${TEMPDIR}/package_versions.txt ${TEMPDIR}/${LS_REPO}/
cd ${TEMPDIR}/${LS_REPO}/
wait
Expand All @@ -448,7 +440,7 @@ pipeline {
// Exit the build if the package file was just updated
stage('PACKAGE-exit') {
when {
branch "master"
branch "prerelease"
environment name: 'CHANGE_ID', value: ''
environment name: 'PACKAGE_UPDATED', value: 'true'
environment name: 'EXIT_STATUS', value: ''
Expand All @@ -462,7 +454,7 @@ pipeline {
// Exit the build if this is just a package check and there are no changes to push
stage('PACKAGECHECK-exit') {
when {
branch "master"
branch "prerelease"
environment name: 'CHANGE_ID', value: ''
environment name: 'PACKAGE_UPDATED', value: 'false'
environment name: 'EXIT_STATUS', value: ''
Expand Down Expand Up @@ -557,14 +549,14 @@ pipeline {
echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin
for PUSHIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "${GITLABIMAGE}" "${IMAGE}"; do
docker tag ${IMAGE}:${META_TAG} ${PUSHIMAGE}:${META_TAG}
docker tag ${PUSHIMAGE}:${META_TAG} ${PUSHIMAGE}:latest
docker push ${PUSHIMAGE}:latest
docker tag ${PUSHIMAGE}:${META_TAG} ${PUSHIMAGE}:prerelease
docker push ${PUSHIMAGE}:prerelease
docker push ${PUSHIMAGE}:${META_TAG}
done
for DELETEIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "{GITLABIMAGE}" "${IMAGE}"; do
docker rmi \
${DELETEIMAGE}:${META_TAG} \
${DELETEIMAGE}:latest || :
${DELETEIMAGE}:prerelease || :
done
'''
}
Expand Down Expand Up @@ -607,52 +599,52 @@ pipeline {
docker tag ${IMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG}
docker tag ${IMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG}
docker tag ${IMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG}
docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-latest
docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-latest
docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-latest
docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-prerelease
docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-prerelease
docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-prerelease
docker push ${MANIFESTIMAGE}:amd64-${META_TAG}
docker push ${MANIFESTIMAGE}:arm32v7-${META_TAG}
docker push ${MANIFESTIMAGE}:arm64v8-${META_TAG}
docker push ${MANIFESTIMAGE}:amd64-latest
docker push ${MANIFESTIMAGE}:arm32v7-latest
docker push ${MANIFESTIMAGE}:arm64v8-latest
docker manifest push --purge ${MANIFESTIMAGE}:latest || :
docker manifest create ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm32v7-latest ${MANIFESTIMAGE}:arm64v8-latest
docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm32v7-latest --os linux --arch arm
docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm64v8-latest --os linux --arch arm64 --variant v8
docker push ${MANIFESTIMAGE}:amd64-prerelease
docker push ${MANIFESTIMAGE}:arm32v7-prerelease
docker push ${MANIFESTIMAGE}:arm64v8-prerelease
docker manifest push --purge ${MANIFESTIMAGE}:prerelease || :
docker manifest create ${MANIFESTIMAGE}:prerelease ${MANIFESTIMAGE}:amd64-prerelease ${MANIFESTIMAGE}:arm32v7-prerelease ${MANIFESTIMAGE}:arm64v8-prerelease
docker manifest annotate ${MANIFESTIMAGE}:prerelease ${MANIFESTIMAGE}:arm32v7-prerelease --os linux --arch arm
docker manifest annotate ${MANIFESTIMAGE}:prerelease ${MANIFESTIMAGE}:arm64v8-prerelease --os linux --arch arm64 --variant v8
docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG} || :
docker manifest create ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG}
docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} --os linux --arch arm
docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} --os linux --arch arm64 --variant v8
docker manifest push --purge ${MANIFESTIMAGE}:latest
docker manifest push --purge ${MANIFESTIMAGE}:prerelease
docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG}
done
for LEGACYIMAGE in "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
docker tag ${IMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:amd64-${META_TAG}
docker tag ${IMAGE}:arm32v7-${META_TAG} ${LEGACYIMAGE}:arm32v7-${META_TAG}
docker tag ${IMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-${META_TAG}
docker tag ${LEGACYIMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:latest
docker tag ${LEGACYIMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:prerelease
docker tag ${LEGACYIMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:${META_TAG}
docker tag ${LEGACYIMAGE}:arm32v7-${META_TAG} ${LEGACYIMAGE}:arm32v7-latest
docker tag ${LEGACYIMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-latest
docker tag ${LEGACYIMAGE}:arm32v7-${META_TAG} ${LEGACYIMAGE}:arm32v7-prerelease
docker tag ${LEGACYIMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-prerelease
docker push ${LEGACYIMAGE}:amd64-${META_TAG}
docker push ${LEGACYIMAGE}:arm32v7-${META_TAG}
docker push ${LEGACYIMAGE}:arm64v8-${META_TAG}
docker push ${LEGACYIMAGE}:latest
docker push ${LEGACYIMAGE}:prerelease
docker push ${LEGACYIMAGE}:${META_TAG}
docker push ${LEGACYIMAGE}:arm32v7-latest
docker push ${LEGACYIMAGE}:arm64v8-latest
docker push ${LEGACYIMAGE}:arm32v7-prerelease
docker push ${LEGACYIMAGE}:arm64v8-prerelease
done
'''
sh '''#! /bin/bash
for DELETEIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "${GITLABIMAGE}" "${IMAGE}"; do
docker rmi \
${DELETEIMAGE}:amd64-${META_TAG} \
${DELETEIMAGE}:amd64-latest \
${DELETEIMAGE}:amd64-prerelease \
${DELETEIMAGE}:arm32v7-${META_TAG} \
${DELETEIMAGE}:arm32v7-latest \
${DELETEIMAGE}:arm32v7-prerelease \
${DELETEIMAGE}:arm64v8-${META_TAG} \
${DELETEIMAGE}:arm64v8-latest || :
${DELETEIMAGE}:arm64v8-prerelease || :
done
docker rmi \
lsiodev/buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} \
Expand All @@ -664,7 +656,7 @@ pipeline {
// If this is a public release tag it in the LS Github
stage('Github-Tag-Push-Release') {
when {
branch "master"
branch "prerelease"
expression {
env.LS_RELEASE != env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER
}
Expand All @@ -676,17 +668,17 @@ pipeline {
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \
-d '{"tag":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\
"object": "'${COMMIT_SHA}'",\
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to prerelease",\
"type": "commit",\
"tagger": {"name": "LinuxServer Jenkins","email": "[email protected]","date": "'${GITHUB_DATE}'"}}' '''
echo "Pushing New release for Tag"
sh '''#! /bin/bash
curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json
echo "Data change at JSON endpoint ${JSON_URL}" > releasebody.json
echo '{"tag_name":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\
"target_commitish": "master",\
"target_commitish": "prerelease",\
"name": "'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**'${EXT_REPO}' Changes:**\\n\\n' > start
printf '","draft": false,"prerelease": false}' >> releasebody.json
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**Remote Changes:**\\n\\n' > start
printf '","draft": false,"prerelease": true}' >> releasebody.json
paste -d'\\0' start releasebody.json > releasebody.json.done
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done'''
}
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ The architectures supported by this image are:
| arm64 | arm64v8-latest |
| armhf | arm32v7-latest |

## Version Tags

This image provides various versions that are available via tags. `latest` tag usually provides the latest stable version. Others are considered under development and caution must be exercised when using them.

| Tag | Description |
| :----: | --- |
| latest | Stable Booksonic releases |
| prerelease | Booksonic Pre-releases |

## Usage

Expand Down Expand Up @@ -216,6 +224,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64

## Versions

* **10.01.20:** - Pull most current release.
* **22.12.19:** - Revert to pulling in external war, upgrade jetty.
* **30.04.19:** - Switching to build war from source, use stable booksonic releases.
* **24.03.19:** - Switching to new Base images, shift to arm32v7 tag.
Expand Down
13 changes: 6 additions & 7 deletions jenkins-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

# jenkins variables
project_name: docker-booksonic
external_type: github_stable
release_type: stable
release_tag: latest
ls_branch: master
external_type: custom_json
release_type: prerelease
release_tag: prerelease
ls_branch: prerelease
repo_vars:
- EXT_GIT_BRANCH = 'master'
- EXT_USER = 'popeen'
- EXT_REPO = 'Popeens-Subsonic'
- JSON_URL = 'https://api.github.com/repos/popeen/Popeens-Subsonic/releases'
- JSON_PATH = 'first(.[] | select(.prerelease==true)) | .tag_name'
- BUILD_VERSION_ARG = 'BOOKSONIC_RELEASE'
- LS_USER = 'linuxserver'
- LS_REPO = 'docker-booksonic'
Expand Down
7 changes: 7 additions & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ available_architectures:
- { arch: "{{ arch_arm64 }}", tag: "arm64v8-latest"}
- { arch: "{{ arch_armhf }}", tag: "arm32v7-latest"}

# development version
development_versions: true
development_versions_items:
- { tag: "latest", desc: "Stable Booksonic releases" }
- { tag: "prerelease", desc: "Booksonic Pre-releases" }

# container parameters
common_param_env_vars_enabled: true #PGID, PUID, etc, you can set it to 'optional'
param_container_name: "{{ project_name }}"
Expand All @@ -36,6 +42,7 @@ app_setup_block: "Default user/pass is admin/admin"

# changelog
changelogs:
- { date: "10.01.20:", desc: "Pull most current release." }
- { date: "22.12.19:", desc: "Revert to pulling in external war, upgrade jetty." }
- { date: "30.04.19:", desc: "Switching to build war from source, use stable booksonic releases." }
- { date: "24.03.19:", desc: "Switching to new Base images, shift to arm32v7 tag." }
Expand Down

0 comments on commit d8578e3

Please sign in to comment.