diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-apply-patch.sh b/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-apply-patch.sh index 208b399773..fdd17e680d 100755 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-apply-patch.sh +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-apply-patch.sh @@ -2,43 +2,77 @@ set -euo pipefail -# trim the 3rd part in the input semver, e.g. from 1.14.3 to 1.14 -VERSION_SHORT=${VERSION_NEW%.*} -UPDATE_NEEDED=1 +function join_by { + local d=${1-} f=${2-} + if shift 2; then + printf '%s' "$f" "${@/#/$d}" + fi +} + +# create a mapping between short version and new version, e.g. 1.16 -> 1.16.3 +declare -A VERSIONS +for version_new in ${VERSIONS_NEW}; do + version_new_trimmed="${version_new%.*}" + if [[ "${version_new_trimmed%.*}" = "${version_new_trimmed}" ]]; then + version_new_trimmed="${version_new}" + fi + VERSIONS["${version_new_trimmed}"]="${version_new}" +done . .github/workflows/common.sh prepare_git_repo -if ! checkout_branches "go-${VERSION_NEW}-${TARGET}"; then - UPDATE_NEEDED=0 +branch_name="go-$(join_by '-and-' ${VERSIONS_NEW})-${TARGET}" + +if ! checkout_branches "${branch_name}"; then exit 0 fi -pushd "${SDK_OUTER_SRCDIR}/third_party/coreos-overlay" >/dev/null || exit - # Parse the Manifest file for already present source files and keep the latest version in the current series # DIST go1.17.src.tar.gz ... => 1.17 # DIST go1.17.1.src.tar.gz ... => 1.17.1 -VERSION_OLD=$(sed -n "s/^DIST go\(${VERSION_SHORT}\.*[0-9]*\)\.src.*/\1/p" dev-lang/go/Manifest | sort -ruV | head -n1) -if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then - echo "already the latest Go, nothing to do" - UPDATE_NEEDED=0 +declare -a UPDATED_VERSIONS_OLD UPDATED_VERSIONS_NEW +any_different=0 +START_NUMBER=1 +for version_short in "${!VERSIONS[@]}"; do + pushd "${SDK_OUTER_SRCDIR}/third_party/coreos-overlay" >/dev/null || exit + VERSION_NEW="${VERSIONS["${version_short}"]}" + VERSION_OLD=$(sed -n "s/^DIST go\(${version_short}\(\.*[0-9]*\)\?\)\.src.*/\1/p" dev-lang/go/Manifest | sort -ruV | head -n1) + if [[ -z "${VERSION_OLD}" ]]; then + echo "${version_short} is not packaged, skipping" + popd >/dev/null || exit + continue + fi + if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then + echo "${version_short} is already at the latest (${VERSION_NEW}), skipping" + popd >/dev/null || exit + continue + fi + UPDATED_VERSIONS_OLD+=("${VERSION_OLD}") + UPDATED_VERSIONS_NEW+=("${VERSION_NEW}") + + any_different=1 + EBUILD_FILENAME=$(get_ebuild_filename "dev-lang" "go" "${VERSION_OLD}") + git mv "${EBUILD_FILENAME}" "dev-lang/go/go-${VERSION_NEW}.ebuild" + + popd >/dev/null || exit + + generate_patches dev-lang go Go + ((START_NUMBER++)) +done + +if [[ $any_different -eq 0 ]]; then + echo "go packages were already at the latest versions, nothing to do" exit 0 fi -EBUILD_FILENAME=$(get_ebuild_filename "dev-lang" "go" "${VERSION_OLD}") -git mv "${EBUILD_FILENAME}" "dev-lang/go/go-${VERSION_NEW}.ebuild" - -popd >/dev/null || exit - -URL="https://go.googlesource.com/go/+/refs/tags/go${VERSION_NEW}" - -generate_update_changelog 'Go' "${VERSION_NEW}" "${URL}" 'golang' - -generate_patches dev-lang go Go - apply_patches -echo ::set-output name=VERSION_OLD::"${VERSION_OLD}" -echo ::set-output name=UPDATE_NEEDED::"${UPDATE_NEEDED}" +vo_gh="$(join_by ' and ' "${UPDATED_VERSIONS_OLD[@]}")" +vn_gh="$(join_by ' and ' "${UPDATED_VERSIONS_NEW[@]}")" + +echo ::set-output name=VERSIONS_OLD::"${vo_gh}" +echo ::set-output name=VERSIONS_NEW::"${vn_gh}" +echo ::set-output name=BRANCH_NAME::"${branch_name}" +echo ::set-output name=UPDATE_NEEDED::"1" diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-releases-main.yml b/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-releases-main.yml index ee8a5fa3cc..a85de0618b 100644 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-releases-main.yml +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-releases-main.yml @@ -5,21 +5,24 @@ on: workflow_dispatch: jobs: - get-go-release: + get-go-releases: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: token: ${{ secrets.GITHUB_TOKEN }} - - name: Fetch latest Go release - id: fetch-latest-release + - name: Fetch latest Go releases + id: fetch-latest-releases env: - GO_VERSION: "1.17" + GO_VERSIONS: "1.16 1.17 1.18" run: | git clone --depth=1 --no-checkout https://github.com/golang/go - versionMain=$(git -C go ls-remote --tags origin | cut -f2 | sed -n "/refs\/tags\/go${GO_VERSION}\.[0-9]*$/s/^refs\/tags\/go//p" | egrep -v -e '(beta|rc)' | sort -ruV | head -1) + versionsMain=() + for goversion in ${GO_VERSIONS}; do + versionsMain+=($(git -C go ls-remote --tags origin | cut -f2 | sed -n "/refs\/tags\/go${goversion}\(\.[0-9]*\)\?$/s/^refs\/tags\/go//p" | egrep -v -e '(beta|rc)' | sort -ruV | head -1)) + done rm -rf go - echo ::set-output name=VERSION_MAIN::$(echo ${versionMain}) + echo ::set-output name=VERSIONS_MAIN::$(echo ${versionsMain[*]}) echo ::set-output name=BASE_BRANCH_MAIN::main - name: Set up Flatcar SDK id: setup-flatcar-sdk @@ -28,20 +31,20 @@ jobs: id: apply-patch-main env: TARGET: main - BASE_BRANCH: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_MAIN }} + BASE_BRANCH: ${{ steps.fetch-latest-releases.outputs.BASE_BRANCH_MAIN }} PATH: ${{ steps.setup-flatcar-sdk.outputs.path }} - VERSION_NEW: ${{ steps.fetch-latest-release.outputs.VERSION_MAIN }} + VERSIONS_NEW: ${{ steps.fetch-latest-releases.outputs.VERSIONS_MAIN }} run: .github/workflows/go-apply-patch.sh - name: Create pull request for main uses: peter-evans/create-pull-request@v3 if: steps.apply-patch-main.outputs.UPDATE_NEEDED == 1 with: token: ${{ secrets.GITHUB_TOKEN }} - base: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_MAIN }} - branch: go-${{ steps.fetch-latest-release.outputs.VERSION_MAIN }}-main + base: ${{ steps.fetch-latest-releases.outputs.BASE_BRANCH_MAIN }} + branch: ${{ steps.apply-patch-main.outputs.BRANCH_NAME }} author: Flatcar Buildbot committer: Flatcar Buildbot - title: Upgrade Go in main from ${{ steps.apply-patch-main.outputs.VERSION_OLD }} to ${{ steps.fetch-latest-release.outputs.VERSION_MAIN }} - commit-message: Upgrade Go in main from ${{ steps.apply-patch-main.outputs.VERSION_OLD }} to ${{ steps.fetch-latest-release.outputs.VERSION_MAIN }} - body: Upgrade Go in main from ${{ steps.apply-patch-main.outputs.VERSION_OLD }} to ${{ steps.fetch-latest-release.outputs.VERSION_MAIN }} + title: Upgrade Go from ${{ steps.apply-patch-main.outputs.VERSIONS_OLD }} to ${{ steps.apply-patch-main.outputs.VERSIONS_NEW }} + commit-message: Upgrade Go from ${{ steps.apply-patch-main.outputs.VERSIONS_OLD }} to ${{ steps.apply-patch-main.outputs.VERSIONS_NEW }} + body: Upgrade Go from ${{ steps.apply-patch-main.outputs.VERSIONS_OLD }} to ${{ steps.apply-patch-main.outputs.VERSIONS_NEW }} labels: main