diff options
| author | Michael Biebl <biebl@debian.org> | 2024-12-25 20:36:29 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2024-12-25 20:36:29 +0100 |
| commit | e465722b908aa870bdc293b9a417d3c15294aa6d (patch) | |
| tree | 7c959d3b73f427d6c40522a7464eaa4531ef2f05 /contrib | |
| parent | 56928734cbcf1d3a02fae4f152a541df1b04e04a (diff) | |
New upstream version 1.50.1 upstream/1.50.1
Diffstat (limited to 'contrib')
| -rwxr-xr-x | contrib/fedora/rpm/release.sh | 139 | ||||
| -rwxr-xr-x | contrib/scripts/find-backports | 8 |
2 files changed, 108 insertions, 39 deletions
diff --git a/contrib/fedora/rpm/release.sh b/contrib/fedora/rpm/release.sh index d5144271..32e5e7d1 100755 --- a/contrib/fedora/rpm/release.sh +++ b/contrib/fedora/rpm/release.sh @@ -27,7 +27,8 @@ # * Run in a "clean" environment, i.e. no unusual environment variables set, on a recent # Fedora, with suitable dependencies installed. # -# * First, ensure that you have ssh keys for "master.gnome.org" installed (and ssh-agent running). +# * First, ensure that you have a valid Gitlab's private token for gitlab.freedestkop.org +# stored in ~/.config/nm-release-token, or pass one with --gitlab-token argument. # Also, ensure you have a GPG key that you want to use for signing. Also, have gpg-agent running # and possibly configure `git config --get user.signingkey` for the proper key. # @@ -39,9 +40,13 @@ # # Run with --no-test to do the actual release. -die() { +fail_msg() { echo -n "FAIL: " echo_color 31 "$@" +} + +die() { + fail_msg "$@" exit 1 } @@ -63,12 +68,13 @@ print_usage() { echo " [--no-check-gitlab] \\" echo " [--no-check-news] \\" echo " [--no-warn-publish-docs] \\" + echo " [--gitlab-token <private_gitlab_token>] \\" } die_help() { print_usage echo - sed -e '/^# /,/# Run with --no-test/!d' -e 's/^#\($\| \)/ /' "$BASH_SOURCE" + sed -e '2,/^$/!d' -e 's/^#\($\| \)/ /' "$BASH_SOURCE" exit 0 } @@ -124,7 +130,7 @@ check_gitlab_pipeline() { local SHA="$2" local PIPELINE_ID - PIPELINE_ID="$(curl --no-progress-meter "https://gitlab.freedesktop.org/api/v4/projects/411/pipelines?ref=$BRANCH&sha=$SHA&order_by=id" 2>/dev/null | jq '.[0].id')" + PIPELINE_ID="$(curl --no-progress-meter "https://gitlab.freedesktop.org/api/v4/projects/411/pipelines?ref=$BRANCH&sha=$SHA&source=push&order_by=id" 2>/dev/null | jq '.[0].id')" if ! [[ $PIPELINE_ID =~ [0-9]+ ]] ; then echo "Cannot find pipeline for branch $BRANCH. Check \"https://gitlab.freedesktop.org/NetworkManager/NetworkManager/pipelines?page=1&scope=branches&ref=$BRANCH\"" return 1 @@ -245,6 +251,11 @@ while [ "$#" -ge 1 ]; do --help|-h) die_help ;; + --gitlab-token) + [ "$#" -ge 1 ] || die_usage "provide a value for --gitlab-token" + GITLAB_TOKEN="$1" + shift + ;; devel|rc1|rc|major|major-post|minor) [ -z "$RELEASE_MODE" ] || die_usage "duplicate release-mode" RELEASE_MODE="$A" @@ -411,7 +422,7 @@ fi if [ $CHECK_GITLAB = 1 ]; then if ! check_gitlab_pipeline "$CUR_BRANCH" "$CUR_HEAD" ; then - echo "Check the pipelines for branch \"$CUR_BRANCH\" at https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/pipelines?ref=$CUR_BRANCH" + echo "Check the pipelines for branch \"$CUR_BRANCH\" at https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/pipelines?ref=$CUR_BRANCH&source=push" echo "Wait for pipeline with \`ci-fairy wait-for-pipeline --project NetworkManager/NetworkManager --sha \"$CUR_HEAD\"\`" die "It seems not all gitlab-ci jobs were running/succeeding. Skip this check with --no-check-gitlab" fi @@ -511,27 +522,23 @@ case "$RELEASE_MODE" in esac build_tag() { - git checkout "$BUILD_TAG" || die "failed to checkout $BUILD_TAG" + local BUILD_TAG="$1" + local TAR_FILE="NetworkManager-$2.tar.xz" + local SUM_FILE="$TAR_FILE.sha256sum" + git checkout "$BUILD_TAG" || die "failed to checkout $BUILD_TAG" ./contrib/fedora/rpm/build_clean.sh -r || die "build release failed" - - test -f "./build/meson-dist/$RELEASE_FILE" \ - || die "release file \"./build/meson-dist/$RELEASE_FILE\" not found" - - cp "./build/meson-dist/$RELEASE_FILE" /tmp/ || die "failed to copy release tarball to /tmp" - - if test -f "./build/meson-dist/$RELEASE_FILE.sig" ; then - cp "./build/meson-dist/$RELEASE_FILE.sig" /tmp/ || die "failed to copy signature for tarball to /tmp" - fi - + cp "./build/meson-dist/$TAR_FILE" /tmp/ || die "failed to copy $TAR_FILE to /tmp" + cp "./build/meson-dist/$SUM_FILE" /tmp/ || die "failed to copy $SUM_FILE to /tmp" git clean -fdx } -RELEASE_FILES=() +RELEASE_TAR_VERSIONS=() +RELEASE_TAGS=() if [ -n "$BUILD_TAG" ]; then - RELEASE_FILE="NetworkManager-$TAR_VERSION.tar.xz" - RELEASE_FILES+=("$RELEASE_FILE") - build_tag + build_tag "$BUILD_TAG" "$TAR_VERSION" + RELEASE_TAR_VERSIONS+=("$TAR_VERSION") + RELEASE_TAGS+=("$BUILD_TAG") fi git checkout -B "$CUR_BRANCH" "$TMP_BRANCH" || die "cannot checkout $CUR_BRANCH" @@ -541,9 +548,6 @@ if [ "$RELEASE_MODE" = rc1 ]; then git branch "$RELEASE_BRANCH" "$TMP_BRANCH" || die "cannot checkout $CUR_BRANCH" BRANCHES+=( "$RELEASE_BRANCH" ) CLEANUP_REFS+=( "refs/heads/$RELEASE_BRANCH" ) -fi - -if [ "$RELEASE_MODE" = rc1 ]; then git checkout "$TMP_BRANCH" b="${VERSION_ARR[0]}.$((${VERSION_ARR[1]} + 2)).0" set_version_number "${VERSION_ARR[0]}" "$((${VERSION_ARR[1]} + 2))" 0 @@ -553,29 +557,86 @@ if [ "$RELEASE_MODE" = rc1 ]; then CLEANUP_REFS+=("refs/tags/$b-dev") BUILD_TAG="$b-dev" TAR_VERSION="$b" - RELEASE_FILE="NetworkManager-$TAR_VERSION.tar.xz" - RELEASE_FILES+=("$RELEASE_FILE") - build_tag + build_tag "$BUILD_TAG" "$TAR_VERSION" + RELEASE_TAR_VERSIONS+=("$TAR_VERSION") + RELEASE_TAGS+=("$BUILD_TAG") git checkout -B "$CUR_BRANCH" "$TMP_BRANCH" || die "cannot checkout $CUR_BRANCH" fi -if ! [ "$DRY_RUN" = 0 ]; then - ssh master.gnome.org true || die "failed to \`ssh master.gnome.org\`" +if [[ $GITLAB_TOKEN == "" ]]; then + [[ -r ~/.config/nm-release-token ]] || die "cannot read ~/.config/nm-release-token" + GITLAB_TOKEN=$(< ~/.config/nm-release-token) fi -for r in "${RELEASE_FILES[@]}"; do - do_command rsync -va --append-verify -P "/tmp/$r" master.gnome.org: || die "failed to rsync \"/tmp/$r\"" -done +# This step is not necessary for authentication, we use it only to provide a meaningful error message. +curl --request GET --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \ + "https://gitlab.freedesktop.org/api/v4/personal_access_tokens/self" &>/dev/null \ + || die "failed to authenticate at gitlab.freedesktop.org with the private token" do_command git push "$ORIGIN" "${BRANCHES[@]}" || die "failed to to push branches ${BRANCHES[@]} to $ORIGIN" -FAIL=0 -for r in "${RELEASE_FILES[@]}"; do - do_command ssh master.gnome.org ftpadmin install --unattended "$r" || FAIL=1 +CREATE_RELEASE_FAIL=0 +for I in "${!RELEASE_TAR_VERSIONS[@]}"; do + TAR_FILE="NetworkManager-${RELEASE_TAR_VERSIONS[$I]}.tar.xz" + SUM_FILE="$TAR_FILE.sha256sum" + BUILD_TAG="${RELEASE_TAGS["$I"]}" + FAIL=0 + + # upload tarball and checksum file as generic packages + for F in "$TAR_FILE" "$SUM_FILE"; do + do_command curl --location --fail-with-body --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \ + --upload-file "/tmp/$F" \ + "https://gitlab.freedesktop.org/api/v4/projects/411/packages/generic/NetworkManager/$BUILD_TAG/$F" \ + || FAIL=1 + + if [[ $FAIL = 1 ]]; then + fail_msg "failed to upload $F" + CREATE_RELEASE_FAIL=1 + break + fi + done + + [[ $FAIL = 1 ]] && continue + + # create release + do_command curl --location --header 'Content-Type: application/json' --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \ + --request POST "https://gitlab.freedesktop.org/api/v4/projects/411/releases" \ + --data "$(cat <<END + { + "name": "NetworkManager $BUILD_TAG", + "tag_name": "$BUILD_TAG", + "assets": { + "links": [ + { + "name": "NetworkManager $BUILD_TAG tarball with docs", + "url": "https://gitlab.freedesktop.org/api/v4/projects/411/packages/generic/NetworkManager/$BUILD_TAG/$TAR_FILE", + "direct_asset_path": "/$TAR_FILE", + "link_type":"package" + }, + { + "name": "NetworkManager $BUILD_TAG tarball sha256sum", + "url": "https://gitlab.freedesktop.org/api/v4/projects/411/packages/generic/NetworkManager/$BUILD_TAG/$SUM_FILE", + "direct_asset_path": "/$SUM_FILE", + "link_type":"package" + }, + { + "name": "NEWS", + "url": "https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/$BUILD_TAG/NEWS?ref_type=tags", + "direct_asset_path": "/NEWS", + "link_type":"other" + } + ] + } + } +END + )" || FAIL=1 + + if [[ $? != 0 ]]; then + fail_msg "failed to create NetworkManager $BUILD_TAG release" + CREATE_RELEASE_FAIL=1 + continue + fi done -if [ "$FAIL" = 1 ]; then - die "ftpadmin install failed. This was the last step. Invoke the command manually" -fi CLEANUP_CHECKOUT_BRANCH= if [ "$DRY_RUN" = 0 ]; then @@ -586,3 +647,7 @@ else git checkout -B "$CUR_BRANCH" "$CUR_HEAD" || die "cannot reset $CUR_BRANCH to $CUR_HEAD" echo "delete reference. Restore with $(echo_color 36 -n git checkout -B "\"$CUR_BRANCH\"" "$H")" fi + +if [[ $CREATE_RELEASE_FAIL == 1 ]]; then + die "failed creating the release at gitlab.freedesktop.org. This was the last step, create it manually from the web UI" +fi \ No newline at end of file diff --git a/contrib/scripts/find-backports b/contrib/scripts/find-backports index c2082570..92116892 100755 --- a/contrib/scripts/find-backports +++ b/contrib/scripts/find-backports @@ -193,7 +193,9 @@ def git_ref_commit_body(ref): def git_ref_commit_body_get_fixes(ref): body = git_ref_commit_body(ref) result = [] - for mo in re.finditer(re_bin("\\b[fF]ixes: *([0-9a-z]+)\\b"), body): + for mo in re.finditer( + re_bin("^\\s*[fF]ixes: *([0-9a-z]+)\\b"), body, flags=re.MULTILINE + ): c = mo.group(1).decode("ascii") h = git_ref_exists(c) if h: @@ -202,7 +204,9 @@ def git_ref_commit_body_get_fixes(ref): # The commit that contains a "Fixes:" line, can also contain an "Ignore-Fixes:" line # to disable it. This only makes sense with refs/notes/bugs notes, to fix up a wrong # annotation. - for mo in re.finditer(re_bin("\\bIgnore-[fF]ixes: *([0-9a-z]+)\\b"), body): + for mo in re.finditer( + re_bin("^\\s*Ignore-[fF]ixes: *([0-9a-z]+)\\b"), body, flags=re.MULTILINE + ): c = mo.group(1).decode("ascii") h = git_ref_exists(c) try: |