From 1d9cab60b7d079e4146cabc3ecfa5624f9849fcb Mon Sep 17 00:00:00 2001 From: Gilou Date: Sat, 20 Jan 2024 23:10:12 +0000 Subject: [PATCH] Rewrite CI to prepare for -betaX release, and future 2.5.x on OBS --- .gitlab-ci.yml | 46 ++------ ci/README.md | 8 +- ci/create-changelog-and-set-versions.sh | 79 +++++++++---- ci/osc/common-config.sh | 20 ++++ ci/osc/handle-osc-upload.sh | 140 ++++++++++++++---------- ci/osc/nightly-config.sh | 30 +++-- ci/osc/prepare-osc-tools.sh | 28 ++++- ci/osc/release-config.sh | 16 +-- win32/icecast.nsis | 2 +- 9 files changed, 223 insertions(+), 146 deletions(-) create mode 100644 ci/osc/common-config.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e635e257..d3b5f54c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,28 +1,14 @@ # Build Icecast - test +variables: + BASE_IMAGE_REGISTRY: registry.gitlab.xiph.org/xiph/icecast-docker-images default: - image: alpine:3.15 - + image: "$BASE_IMAGE_REGISTRY/alpine-icecast-server:20240114141404" tags: - docker - linux -.TemplateAlpine: - before_script: - - set -xe - - apk update - - cat /etc/os* - - apk add musl-dev git make gcc automake autoconf libtool curl ca-certificates - - apk add curl-dev libogg-dev libvorbis-dev libxslt-dev libxml2-dev libc6-compat rhash-dev - # gzip required because busybox gzip does not understand best / zip for make dist - - apk add gzip zip tar - # Required for tests - #- apk add curl ffmpeg - # Create user to run tests - #- adduser -s /bin/sh -D -H icecast - make_dist: - extends: .TemplateAlpine variables: GIT_SUBMODULE_STRATEGY: recursive LIBIGLOO_PACKAGE_PREFIX: "alpine-libigloo-bins" @@ -33,6 +19,7 @@ make_dist: script: - set -xe # yes i know the scripts will be merged... but for sanities sake + - cat /etc/os* - ./autogen.sh - mkdir EXTRA-LIBS - export PKG_CONFIG_PATH=`pwd`/EXTRA-LIBS/usr/local/lib/pkgconfig @@ -49,6 +36,7 @@ make_dist: - ./configure || cat config.log - make - make dist + - tree # Tests #- su -c "./tests/admin-tests.sh" icecast @@ -57,29 +45,8 @@ make_dist: untracked: true expire_in: 1 week -upload_package: - extends: .TemplateAlpine - stage: deploy - variables: - ICECAST_SERVER_VERSION: "2.4.99.3" - ICECAST_SERVER_PREFIX: "alpine-icecast-server-bins" - - script: - - make install DESTDIR=`pwd`/_install_base/ - - cd _install_base/ - # see above - - export ICECAST_SERVER_BASE=$ICECAST_SERVER_PREFIX-$CI_COMMIT_REF_NAME - - export ICECAST_SERVER_ARCHIVE=$ICECAST_SERVER_BASE.tar.gz - - export ICECAST_SERVER_VERSION_WITH_SUFFIX=$ICECAST_SERVER_VERSION-$CI_COMMIT_REF_NAME - - tar -cvzf ../$ICECAST_SERVER_ARCHIVE * - - cd .. - - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file $ICECAST_SERVER_ARCHIVE "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/$ICECAST_SERVER_PREFIX/$ICECAST_SERVER_VERSION_WITH_SUFFIX/$ICECAST_SERVER_ARCHIVE"' - - needs: - - "make_dist" - - upload_dist: + image: "$BASE_IMAGE_REGISTRY/alpine-osc:20240114141818" only: - master - devel @@ -96,6 +63,7 @@ upload_dist: - ./ci/osc/handle-osc-upload.sh upload_dist_release: + image: "$BASE_IMAGE_REGISTRY/alpine-osc:20240114141818" only: - tags diff --git a/ci/README.md b/ci/README.md index fbab13a7..548509c3 100644 --- a/ci/README.md +++ b/ci/README.md @@ -9,14 +9,16 @@ These are defined in the ci/osc/ for releases and nightlies in their respective To make a new release please call the magic version changer as following from the repo root: ``` -export ICECAST_BETA_VERSION=3 -ci/create-changelog-and-set-versions.sh "$ICECAST_BETA_VERSION" "2.4.99.$ICECAST_BETA_VERSION" "2.5 beta$ICECAST_BETA_VERSION" "25-beta-$ICECAST_BETA_VERSION" "2.5-beta$ICECAST_BETA_VERSION" "_VERSION_ARCHIVE_" "2.4.99.$ICECAST_BETA_VERSION" "now" "Stephan Jauernick " "Preparing for 2.5 beta$ICECAST_BETA_VERSION aka 2.4.99.$ICECAST_BETA_VERSION" "icecast" "mingw32-icecast" "mingw32-icecast-installer" +ci/create-changelog-and-set-versions.sh "2.4.99.4" "_VERSION_ARCHIVE_" "2.4.99.4" "now" "Stephan Jauernick " "Preparing for 2.5.0" +ci/create-changelog-and-set-versions.sh "2.5.0" "_VERSION_ARCHIVE_" "2.5.0" "now" "Stephan Jauernick " "2.5 is great" ``` -Please adapt the "ICECAST_BETA_VERSION", the Author, the Date(now; please enter a valid ISO8601 Date if needed) and the Message as needed. +Please adapt the Author, the Date(now; please enter a valid ISO8601 Date if needed) and the Message as needed. This script/mechanism will update all the version references and then show you a git status/diff. Please check all changes and commit them as needed. +For now, a X.Y.Z.B release will set the versions for a X.Y+1 beta B release, this could be changed to allow patch pre-release. + After tagging and uploading the release will be picked up by gitlabs CI and a release will be pushed to OBS. # Nightlies diff --git a/ci/create-changelog-and-set-versions.sh b/ci/create-changelog-and-set-versions.sh index e7b3a119..328fef9f 100755 --- a/ci/create-changelog-and-set-versions.sh +++ b/ci/create-changelog-and-set-versions.sh @@ -1,20 +1,56 @@ #!/bin/bash -xe -BETA_VERSION=${1:?Missing Beta Version, Use 2}; shift -SHORT_VERSION=${1:?Missing Short Version, Use 2.4.99.2}; shift -STRANGE_VERSION=${1:?Missing Strange Version, Use '2.5 beta2'}; shift -HTML_VERSION=${1:?Missing HTML Version, Use '25-beta-2'}; shift -WIN32_VERSION=${1:?Missing Win32 Version, Use '2.5-beta2'}; shift -ARCHIVE_VERSION=${1:?Missing Archive Version, Use '2.4.99.2' for ci or _VERSION_ARCHIVE_ for release}; shift -CI_VERSION=${1:?Missing CI Version - Use 2.4.99.2+bla}; shift -DATE=`date --date=${1:?ISO DATE or now} --iso-8601=seconds`; shift +# Script to handle version handling for releases manually or through the CI +# SHORT_VERSION (first parameter) will be used for most places +# It should be MAJOR.minor.patch to prepare an actual release +# or MAJOR.minor.patch.extra to prepare for the next minor release +# extra will then be the number of the beta release +# - in configure.ac, for the actual version used for building +# - to build the other version numbers such as : +# - Documentation link for the current version +# - Windows installer "displayed version" and others +SHORT_VERSION=${1:?Missing Short Version, Use 2.5.0 or 2.5.0.1}; shift +# ARCHIVE_VERSION is used as an info to differentiate releases from CI builds +# For releases, it should be set to _VERSION_ARCHIVE_ +# For CI, something resembling the SHORT_VERSION +ARCHIVE_VERSION=${1:?Missing Archive Version, Use '2.5.0' for ci or _VERSION_ARCHIVE_ for release}; shift +# CI_VERSION is used mostly in changelogs and comments about the release +# should be set to something like SHORT_VERSION +CI_VERSION=${1:?Missing CI Version - Use 2.4.99.2+bla without any -}; shift +# Date used throughout for changelogs, and tags where we need a timestamp +DATE=$(LC_TIME=C date --utc --iso-8601=seconds --date="${1:?ISO DATE or now}"); shift +# Author (Email, or Name ) in changelogs and comments AUTHOR=${1:?Mail Address}; shift +# Short description to be added to changelogs TEXT=${1:?Release Text}; shift -ICECAST_PROJECT=${1:?Icecast OSC Project Name}; shift -W32_ICECAST_PROJECT=${1:?Icecast W32 OSC Project Name}; shift -W32_ICECAST_INSTALLER_PROJECT=${1:?Icecast W32 Installer OSC Project Name}; shift -OSC_BASE_DIR=osc_tmp +if [[ "$SHORT_VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]]; then + MAJOR=${BASH_REMATCH[1]} + MINOR=${BASH_REMATCH[2]} + PATCH=${BASH_REMATCH[3]} + EXTRA=${BASH_REMATCH[5]} + LABEL=${EXTRA:+beta} + if [[ -n "$EXTRA" ]]; then + ((MINOR++)) + fi +else + echo "Sorry, that version does not comply to our ^([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?$ regex, use something like 2.5.0 or 2.5.0.1" + exit 3 +fi + +# M.m or M.m -LABEL +STRANGE_VERSION="${MAJOR}.${MINOR}${EXTRA:+ $LABEL$EXTRA}" +# Mm, or Mm-beta-1 +HTML_VERSION="${MAJOR}${MINOR}${EXTRA:+-$LABEL-$EXTRA}" +# M.m or M.m-LABEL +WIN32_VERSION="${MAJOR}.${MINOR}${EXTRA:+-$LABEL$EXTRA}" + +# Name of the package names in OBS for each part. Can be overridden. +ICECAST_PROJECT=${ICECAST_PROJECT:-icecast} +W32_ICECAST_PROJECT=${W32_ICECAST_PROJECT:-mingw32-icecast} +W32_ICECAST_INSTALLER_PROJECT=${W32_ICECAST_INSTALLER_PROJECT:-mingw32-icecast-installer} + +OSC_BASE_DIR="${OSC_TMP:-osc_tmp}" # upon release we modify the templates - in ci we modiy temporary files if [ "$ARCHIVE_VERSION" = "_VERSION_ARCHIVE_" ]; then @@ -23,29 +59,28 @@ fi pushd $OSC_BASE_DIR -sed -i "1s#^#icecast2 ($CI_VERSION-1) UNRELEASED; urgency=medium\n\n * $TEXT\n\n -- $AUTHOR `date --date=$DATE +"%a, %d %b %Y %H:%M:%S %z"`\n\n#" $ICECAST_PROJECT/debian/changelog +# Set changelog for Debian, required. Version will be set to $CI_VERSION-1 +sed -i "1s#^#icecast2 ($CI_VERSION-1) UNRELEASED; urgency=medium\n\n * $TEXT\n\n -- $AUTHOR $(LC_TIME=C date --date="$DATE" +"%a, %d %b %Y %H:%M:%S %z")\n\n#" "$ICECAST_PROJECT/debian/changelog" +# Set .spec to build on OBS, common changelog, version set to $ARCHIVE_VERSION for i in "$ICECAST_PROJECT/$ICECAST_PROJECT.spec" "$W32_ICECAST_INSTALLER_PROJECT/$W32_ICECAST_INSTALLER_PROJECT.spec" "$W32_ICECAST_PROJECT/$W32_ICECAST_PROJECT.spec"; do - sed -i "s/_VERSION_ARCHIVE_/$ARCHIVE_VERSION/; s/^Version:\(\s*\)[^\s]*$/Version:\1$CI_VERSION/; s#^%changelog.*\$#\0\n* `date --date=$DATE +"%a %b %d %Y"` $AUTHOR - $CI_VERSION-1\n- $TEXT\n\n#" "$i"; + sed -i "s/_VERSION_ARCHIVE_/$ARCHIVE_VERSION/; s/^Version:\(\s*\)[^\s]*$/Version:\1$CI_VERSION/; s#^%changelog.*\$#\0\n* $(LC_TIME=C date --date="$DATE" +"%a %b %d %Y") $AUTHOR - $CI_VERSION-1\n- $TEXT\n\n#" "$i"; done -sed -i "s/\(icecast_win32_\).*\(.exe\)/\1$WIN32_VERSION\2/" $W32_ICECAST_INSTALLER_PROJECT/$W32_ICECAST_INSTALLER_PROJECT.spec - popd # we only update the changelog for releases - until i figure out if we want to run the magic script pre CI if [ "$ARCHIVE_VERSION" = "_VERSION_ARCHIVE_" ]; then - sed -i "1s#^#`date --date=$DATE +"%Y-%m-%d %H:%M:%S"` $AUTHOR\n\n * $TEXT\n\n#" ChangeLog + sed -i "1s#^#$(LC_TIME=C date --date="$DATE" +"%Y-%m-%d %H:%M:%S") $AUTHOR\n\n * $TEXT\n\n#" ChangeLog fi - -sed -i "1s#\[[.0-9]*\]#[$SHORT_VERSION]#" configure.ac +# actual version change for the build +sed -i "1s#\[[.0-9]\+\]#[$SHORT_VERSION]#" configure.ac sed -i "s/Icecast .* Documentation/Icecast $STRANGE_VERSION Documentation/; s/icecast-.*-documentation/icecast-$HTML_VERSION-documentation/" doc/index.html sed -i "s/\(\"DisplayVersion\" \"\).*\(\"\)$/\1$STRANGE_VERSION\2/" win32/icecast.nsis -sed -i "s/\(OutFile \"icecast_win32_\).*\(.exe\"\)$/\1$WIN32_VERSION\2/" win32/icecast.nsis - -sed -i "s/^\(export ICECAST_VERSION=\).*$/\1$SHORT_VERSION/; s/\(export ICECAST_BETA_VERSION=\).*$/\1$BETA_VERSION/" ci/osc/*-config.sh +# Update version in all config.sh script used for releases and nightly builds +sed -i "s/^\(export ICECAST_VERSION=\).*$/\1$SHORT_VERSION/" ci/osc/*-config.sh # we only do this for release builds if [ "$ARCHIVE_VERSION" = "_VERSION_ARCHIVE_" ]; then diff --git a/ci/osc/common-config.sh b/ci/osc/common-config.sh new file mode 100644 index 00000000..0547a8d5 --- /dev/null +++ b/ci/osc/common-config.sh @@ -0,0 +1,20 @@ +# Mark the git dir safe, as it may have wider permissions +git config --global --add safe.directory "$PWD" + +GIT_BRANCH=${CI_COMMIT_BRANCH} +GIT_COMMIT=`git rev-parse HEAD` + +# OBS settings, override using OBS_BASE_PROJECT +# By default: use multimedia:xiph (or OBS_BASE_PROJECT) for releases +# multimedia:xiph:nightly-master for master branch nightlies +# multimedia:xiph:nightly-devel for devel branch nightlies +OBS_BASE_PROJECT=${OBS_BASE_PROJECT:-multimedia:xiph} +OBS_BASE_NIGHTLY_MASTER="${OBS_BASE_PROJECT}:nightly-master" +OBS_BASE_NIGHTLY_DEVEL="${OBS_BASE_PROJECT}:nightly-devel" +OBS_BASE_BETA="${OBS_BASE_PROJECT}:beta" +OBS_BASE_RELEASE="${OBS_BASE_PROJECT}" + +export ICECAST_PROJECT=${ICECAST_PROJECT:-icecast} +export W32_ICECAST_PROJECT=${W32_ICECAST_PROJECT:-mingw32-icecast} +export W32_ICECAST_INSTALLER_PROJECT=${W32_ICECAST_INSTALLER_PROJECT:-mingw32-icecast-installer} +export ICECAST_VERSION=2.4.99.3 diff --git a/ci/osc/handle-osc-upload.sh b/ci/osc/handle-osc-upload.sh index d5b008f6..65984990 100755 --- a/ci/osc/handle-osc-upload.sh +++ b/ci/osc/handle-osc-upload.sh @@ -1,85 +1,111 @@ #!/bin/bash -xe +# Script used by Gitlab's CI to push built packgages to OBS for packaging. +# It's configured using common-config.sh and nightly-config.sh for master/devel +# and release-config.sh through variables +# We'll need OBS_BASES to be set as a list of strings indicating OBS projects +# we want to upload our packages to. -SCRIPT_DIR=`dirname $0` -SCRIPT_DIR=`realpath $SCRIPT_DIR` +# Set SCRIPT_DIR to current directory of the script +SCRIPT_DIR=$(realpath "$(dirname "$0")") +# Set OSC_RC_FILE to define which file has osc config (and credentials) +# This can be overriden through CI or when manually called +OSC_RC_FILE=${OSC_RC_FILE:-$HOME/.config/osc/oscrc} + +# Gitlab CI calls the script without parameters for master/devel +# and adds "release" as a param for releases, so we use that to load variables CONFIG=${1:-nightly} -. $SCRIPT_DIR/$CONFIG-config.sh +. "$SCRIPT_DIR/common-config.sh" +. "$SCRIPT_DIR/$CONFIG-config.sh" -: "${OSC_RC:?Variable OSC_RC not set or empty}" +# This is set by Gitlab, but should be set if run manually : "${CI_PIPELINE_URL:?Variable CI_PIPELINE_URL not set or empty}" +# Print current dir for debug pwd - +# Print content ls -la -rm -rf osc_tmp -mkdir -p osc_tmp -cd osc_tmp +# We use $HOME/.local/bin/osc --config=$ORC_RC_FILE as our osc command +# This can be overriden, and would be changed if osc was properly installed +export OSC_CMD="${OSC_CMD:-$HOME/.local/bin/osc} --config=$OSC_RC_FILE" +echo "Using ${OSC_CMD} for \$OSC_CMD, as $(id)" -export HOME=`pwd` -export SOURCE=`pwd`/.. -export OSC_CMD="osc-wrapper.py --config=$OSC_RC" +# Remember where we are +export SOURCE=$PWD -# checkout into a dkirectory named like the project - avoiding having it in a subdir called OBS_BASE -for i in "$ICECAST_PROJECT" "$W32_ICECAST_INSTALLER_PROJECT" "$W32_ICECAST_PROJECT"; do - $OSC_CMD checkout -o "$i" $OBS_BASE "$i" - rm -vrf "$i"/* -done +# For each project on OBS +for OBS_BASE in $OBS_BASES; do + # Create a temp dir for our upload, clean it up + export OSC_TMP=osc_tmp-$OBS_BASE + rm -rf "$OSC_TMP" + mkdir -p "$OSC_TMP" + cd "$OSC_TMP" + # init dir for osc for the repository + $OSC_CMD init "$OBS_BASE" -# no comment needed -for i in "$ICECAST_PROJECT" "$W32_ICECAST_PROJECT"; do - cp $SOURCE/icecast-$ICECAST_VERSION.tar.gz "$i"/icecast2_$ICECAST_CI_VERSION.orig.tar.gz -done - -# we copy the spec for these projects - for the icecast project the spec is globeed -for i in "$W32_ICECAST_INSTALLER_PROJECT" "$W32_ICECAST_PROJECT"; do - cp -a $SCRIPT_DIR/$i/$i.spec $i/ -done - -# this is more complex because we have more files. -cp -a $SCRIPT_DIR/$ICECAST_PROJECT/icecast* $ICECAST_PROJECT/ -cp -a $SCRIPT_DIR/$ICECAST_PROJECT/debian $ICECAST_PROJECT/ - -if [ "$DISABLE_CHANGELOG" == "0" ]; then - pushd $SOURCE - $SCRIPT_DIR/../create-changelog-and-set-versions.sh "$ICECAST_BETA_VERSION" "$ICECAST_VERSION" "2.5 beta$ICECAST_BETA_VERSION" "25-beta-$ICECAST_BETA_VERSION" "2.5-beta$ICECAST_BETA_VERSION" "$ICECAST_VERSION" "$ICECAST_CI_VERSION" "$RELEASE_DATETIME" "$RELEASE_AUTHOR" "CI Build - $CI_PIPELINE_URL" "$ICECAST_PROJECT" "$W32_ICECAST_INSTALLER_PROJECT" "$W32_ICECAST_PROJECT" - popd -else - for i in "$ICECAST_PROJECT/$ICECAST_PROJECT.spec" "$W32_ICECAST_INSTALLER_PROJECT/$W32_ICECAST_INSTALLER_PROJECT.spec" "$W32_ICECAST_PROJECT/$W32_ICECAST_PROJECT.spec"; do - sed -i "s/_VERSION_ARCHIVE_/$ICECAST_VERSION/;" "$i"; + # checkout into a dkirectory named like the project - avoiding having it in a subdir called OBS_BASE + for i in "$ICECAST_PROJECT" "$W32_ICECAST_INSTALLER_PROJECT" "$W32_ICECAST_PROJECT"; do + $OSC_CMD checkout -o "$i" "$OBS_BASE" "$i" || $OSC_CMD mkpac "$i" + rm -vrf "${i:?}"/* done -fi -tar -C $ICECAST_PROJECT -cvzf $ICECAST_PROJECT/icecast2_$ICECAST_CI_VERSION-1.debian.tar.gz debian/ + # Place the built archive in the source for OBS + for i in "$ICECAST_PROJECT" "$W32_ICECAST_PROJECT"; do + cp "$SOURCE/icecast-$ICECAST_VERSION.tar.gz" "$i/icecast2_$ICECAST_CI_VERSION.orig.tar.gz" + done -# remove debian/ so it does not end up in the archive -rm -rf $ICECAST_PROJECT/debian + # we copy the spec for these projects - for the icecast project the spec is globeed + for i in "$W32_ICECAST_INSTALLER_PROJECT" "$W32_ICECAST_PROJECT"; do + cp -a "$SCRIPT_DIR/$i/$i.spec" "$i/" + done -# we fix the dsc to have the correct hashsums so dpkg-buildpackage and co do not complain + # this is more complex because we have more files. + cp -a "$SCRIPT_DIR/$ICECAST_PROJECT"/icecast* "$ICECAST_PROJECT/" + cp -a "$SCRIPT_DIR/$ICECAST_PROJECT"/debian "$ICECAST_PROJECT/" -pushd $ICECAST_PROJECT + # If we need to add automated changelog, call the versionning script + # Otherwise, assume it's a release, and we clean up the .spec files to be updated later by the script + if [ "$DISABLE_CHANGELOG" == "0" ]; then + pushd "$SOURCE" + "$SCRIPT_DIR/../create-changelog-and-set-versions.sh" "$ICECAST_VERSION" "$ICECAST_VERSION" "$ICECAST_CI_VERSION" "$RELEASE_DATETIME" "$RELEASE_AUTHOR" "CI Build - $CI_PIPELINE_URL" "$ICECAST_PROJECT" + popd + else + for i in "$ICECAST_PROJECT/$ICECAST_PROJECT.spec" "$W32_ICECAST_INSTALLER_PROJECT/$W32_ICECAST_INSTALLER_PROJECT.spec" "$W32_ICECAST_PROJECT/$W32_ICECAST_PROJECT.spec"; do + sed -i "s/_VERSION_ARCHIVE_/$ICECAST_VERSION/;" "$i"; + done + fi -$SCRIPT_DIR/../fix-dsc.sh + tar -C "$ICECAST_PROJECT" -cvzf "$ICECAST_PROJECT/icecast2_$ICECAST_CI_VERSION-1.debian.tar.gz" debian/ -popd + # remove debian/ so it does not end up in the archive + rm -rf "$ICECAST_PROJECT/debian" -# we use addremove to detect changes and commit them to the server -for i in "$ICECAST_PROJECT" "$W32_ICECAST_INSTALLER_PROJECT" "$W32_ICECAST_PROJECT"; do - pushd $i + # we fix the dsc to have the correct hashsums so dpkg-buildpackage and co do not complain - $OSC_CMD addremove - $OSC_CMD diff - $OSC_CMD commit -m "Commit via $CI_PIPELINE_URL" + pushd "$ICECAST_PROJECT" + + "$SCRIPT_DIR/../fix-dsc.sh" popd + + # we use addremove to detect changes and commit them to the server + for i in "$ICECAST_PROJECT" "$W32_ICECAST_INSTALLER_PROJECT" "$W32_ICECAST_PROJECT"; do + pushd "$i" + + $OSC_CMD addremove + $OSC_CMD diff + $OSC_CMD commit -m "Commit via $CI_PIPELINE_URL" + + popd + done done -# we cleanup because the OSC_RC should not remain on disk + # we cleanup because the OSC_RC should not remain on disk if [ "$NOCLEANUP" != "1" ]; then - shred -vzf $OSC_RC .osc_cookiejar - cd .. - echo > $OSC_RC - rm -rf "osc_tmp" + for file in "$OSC_RC" "$OSC_RC_FILE" .osc_cookiejar; do + [ -n "$file" ] && [ -f "$file" ] && shred -vzf "$file" + echo > "$file" + done + rm -rf osc_tmp* fi - diff --git a/ci/osc/nightly-config.sh b/ci/osc/nightly-config.sh index 2292d650..8516d20b 100644 --- a/ci/osc/nightly-config.sh +++ b/ci/osc/nightly-config.sh @@ -1,22 +1,30 @@ -GIT_BRANCH=${CI_COMMIT_BRANCH:?Please define CI_COMMIT_BRANCH} - -if [ "z$OBS_BASE" = "z" ]; then +if [ "z$OBS_BASES" = "z" ]; then if [ "$GIT_BRANCH" = "master" ]; then - export OBS_BASE=multimedia:xiph:nightly-master + export OBS_BASES=$OBS_BASE_NIGHTLY_MASTER elif [ "$GIT_BRANCH" = "devel" ]; then - export OBS_BASE=multimedia:xiph:nightly-devel + export OBS_BASES=$OBS_BASE_NIGHTLY_DEVEL else echo "branch '$GIT_BRANCH' is not master or devel, please export OBS_BASE accordingly"; exit 1 fi fi -export ICECAST_PROJECT=icecast -export W32_ICECAST_PROJECT=mingw32-icecast -export W32_ICECAST_INSTALLER_PROJECT=mingw32-icecast-installer -export ICECAST_BETA_VERSION=3 -export ICECAST_VERSION=2.4.99.3 -export ICECAST_CI_VERSION=$ICECAST_VERSION+`date +%Y%m%d%H%M%S`+`git rev-parse HEAD` + +# How long should the hash be, overridable +GIT_HASH_LENGTH=${GIT_HASH_LENGTH:-4} +# Get the current commit ID +GIT_HASH=$(git rev-parse --short="$GIT_HASH_LENGTH" HEAD) +# How long should the date be, we want it to be increasing +# Consider "nightly", but this can be overriden +SHORT_DATE_FORMAT=${SHORT_DATE_FORMAT:-%Y%m%d%H} + +# Compute date for CI VERSION +SHORT_DATE=$(date --utc +"$SHORT_DATE_FORMAT") + +ICECAST_PLUS_VERSION=${ICECAST_VERSION/-/+} + +# CI_VERSION will be something like 2.5.0+202411171222+1234 +export ICECAST_CI_VERSION=${ICECAST_PLUS_VERSION}+${SHORT_DATE}+${GIT_HASH} export DISABLE_CHANGELOG=0 export RELEASE_AUTHOR=${CI_COMMIT_AUTHOR:?Please set CI_COMMIT_AUTHOR} export RELEASE_DATETIME=now diff --git a/ci/osc/prepare-osc-tools.sh b/ci/osc/prepare-osc-tools.sh index 1e8e51e9..14d2011b 100755 --- a/ci/osc/prepare-osc-tools.sh +++ b/ci/osc/prepare-osc-tools.sh @@ -1,7 +1,25 @@ #!/bin/sh -xe +# Script used to make sure we are ready to use osc to upload to OBS +# Installing osc could (should) be done in the image +# Second part handle a OSC_RC set to a file variable from gitlab, +# in the proper path, with the proper permissions +# actual config path can be overridden using $OSC_RC_FILE + +# Debug info for the pipeline cat /etc/os* -apk update -apk add python3 py3-pip python3-dev openssl-dev g++ make swig coreutils bash ca-certificates git -pip install osc -which osc-wrapper.py -osc-wrapper.py --version + +# We are alone using this container. Let's break stuff (someday use a venv). +pip install osc --break-system-packages + +OSC_RC_FILE=${OSC_RC_FILE:-$HOME/.config/osc/oscrc} +echo "Using $OSC_RC_FILE as osc config (override with \$OSC_RC_FILE)" + +# if $OSC_RC is set, and the file exists, copy it as osc's config + +if [ -n "$OSC_RC" ] && [ -f "$OSC_RC" ]; then + echo "Found config at $OSC_RC, copying to $OSC_RC_FILE" + install -m 600 "$OSC_RC" -D "$OSC_RC_FILE" +else + echo "\$OSC_RC not set or file does not exist" + exit 1 +fi diff --git a/ci/osc/release-config.sh b/ci/osc/release-config.sh index bf33596c..7fbb849c 100644 --- a/ci/osc/release-config.sh +++ b/ci/osc/release-config.sh @@ -1,18 +1,18 @@ -if [ "z$OBS_BASE" = "z" ]; then +if [ "z$OBS_BASES" = "z" ]; then if [ "z$CI_COMMIT_TAG" != "z" ]; then - export OBS_BASE=multimedia:xiph:beta + if echo $CI_COMMIT_TAG | grep -q '^v[0-9]\+\.[0-9]\+\.[0-9]\+$'; then + export OBS_BASES="$OBS_BASE_RELEASE $OBS_BASE_BETA" + else + export OBS_BASES="$OBS_BASE_BETA" + fi else - echo "tag variable CI_COMMIT_TAG not defined, please export OBS_BASE accordingly"; + echo "tag variable CI_COMMIT_TAG not defined, please export OBS_BASES accordingly"; exit 1 fi fi -export ICECAST_PROJECT=icecast -export W32_ICECAST_PROJECT=mingw32-icecast -export W32_ICECAST_INSTALLER_PROJECT=mingw32-icecast-installer -export ICECAST_BETA_VERSION=3 export ICECAST_VERSION=2.4.99.3 -export ICECAST_CI_VERSION=$ICECAST_VERSION +export ICECAST_CI_VERSION=${ICECAST_VERSION/-/+} export DISABLE_CHANGELOG=1 export RELEASE_AUTHOR="Philipp Schafft " export RELEASE_DATETIME=2022-03-13T18:25:33+00:00 diff --git a/win32/icecast.nsis b/win32/icecast.nsis index 3e07c858..ceacc355 100644 --- a/win32/icecast.nsis +++ b/win32/icecast.nsis @@ -17,7 +17,7 @@ ;Name and file Name "Icecast" - OutFile "icecast_win32_2.5-beta3.exe" + OutFile "icecast_win32_TOBEREPLACED.exe" ;Default installation folder InstallDir "$PROGRAMFILES32\Icecast"