From 7c1408ad7ac1332c74da41aa8d74cc27a0f6438c Mon Sep 17 00:00:00 2001 From: Shwetha Gururaj Date: Mon, 28 Oct 2024 17:24:40 -0400 Subject: [PATCH] Automate release version generation [main] (#3267) * Remove build_version file and references * Remove unused files Co-authored-by: Pavel Busko --- .../workflows/release-build-sign-upload.yml | 85 +++++++++++++------ .github/workflows/release-update-repos.yml | 51 ++++------- BUILD_VERSION | 1 - Makefile | 1 - bin/bump-version | 50 ----------- bin/generate-release-notes | 32 ------- build_data.yml | 3 - 7 files changed, 72 insertions(+), 151 deletions(-) delete mode 100644 BUILD_VERSION delete mode 100755 bin/bump-version delete mode 100755 bin/generate-release-notes delete mode 100644 build_data.yml diff --git a/.github/workflows/release-build-sign-upload.yml b/.github/workflows/release-build-sign-upload.yml index 911a1348a32..84e6ed2895b 100644 --- a/.github/workflows/release-build-sign-upload.yml +++ b/.github/workflows/release-build-sign-upload.yml @@ -38,9 +38,18 @@ run-name: "Release: Build Sign Upload [${{ github.ref_name }}]" on: workflow_dispatch: + inputs: + release_version: + description: 'Release version bump' + required: true + default: 'patch' + type: choice + options: + - minor + - patch permissions: - contents: read + contents: write defaults: run: @@ -50,39 +59,56 @@ jobs: setup: name: Setup runs-on: ubuntu-latest - + env: + VERSION_MAJOR: 8 outputs: - aws-s3-bucket: "v${{ steps.parse-semver.outputs.version-major }}-cf-cli-releases" + aws-s3-bucket: "v${{ steps.bump-version.outputs.version-major }}-cf-cli-releases" - version-build: ${{ steps.parse-semver.outputs.version-build }} - version-major: ${{ steps.parse-semver.outputs.version-major }} - version-minor: ${{ steps.parse-semver.outputs.version-minor }} - version-patch: ${{ steps.parse-semver.outputs.version-patch }} + version-build: ${{ steps.bump-version.outputs.version-build }} + version-major: ${{ env.VERSION_MAJOR }} + version-minor: ${{ steps.bump-version.outputs.version-minor }} + version-patch: ${{ steps.bump-version.outputs.version-patch }} steps: - name: Checkout cli uses: actions/checkout@v4 - - - name: Check if VERSION_BUILD matches tag ${{ github.ref }} + + - name: Bump version + id: bump-version run: | - echo "Git Ref: ${{ github.ref }}" - echo "VERSION_BUILD: $(cat BUILD_VERSION)" + set -x + git fetch --tags --quiet + latest_tag="$(git tag | sort -V | grep v${VERSION_MAJOR} | tail -1)" + echo "Latest tag is ${latest_tag}" - exit 0 + version="${latest_tag#[vV]}" - - name: Parse semver - id: parse-semver - run: | - VERSION=$(cat BUILD_VERSION) - VERSION="${VERSION#[vV]}" + version_minor="${version#*.}" + version_minor="${version_minor%.*}" + version_patch=${version##*.} - VERSION_MINOR="${VERSION#*.}" - VERSION_MINOR="${VERSION_MINOR%.*}" + if [ "${{ inputs.release_version }}" == "minor" ]; then + version_minor=$(($version_minor + 1)) + version_patch=0 + else + version_patch=$(($version_patch + 1)) + fi - echo "version-build=${VERSION}" >> "${GITHUB_OUTPUT}" - echo "version-major=${VERSION%%\.*}" >> "${GITHUB_OUTPUT}" - echo "version-minor=${VERSION_MINOR}" >> "${GITHUB_OUTPUT}" - echo "version-patch=${VERSION##*.}" >> "${GITHUB_OUTPUT}" + new_version="${VERSION_MAJOR}.${version_minor}.${version_patch}" + echo "new version is ${new_version}" + + echo "version-build=${new_version}" >> "${GITHUB_OUTPUT}" + echo "version-minor=${version_minor}" >> "${GITHUB_OUTPUT}" + echo "version-patch=${version_patch}" >> "${GITHUB_OUTPUT}" + + - name: Publish Tag + run: | + new_tag="v${{ steps.bump-version.outputs.version-build }}" + echo "new version is $new_tag" + git config user.name "GitHub Actions" + git config user.email "github-actions@users.noreply.github.com" + git tag -am "Bump cli version ${new_tag}" ${new_tag} + git push origin $new_tag build-linux: name: Build Linux @@ -135,6 +161,8 @@ jobs: ${{ runner.os }}-go- - name: Build Linux + env: + CF_BUILD_VERSION: ${VERSION_BUILD} run: | make out/cf-cli_linux_i686 make out/cf-cli_linux_x86-64 @@ -252,7 +280,6 @@ jobs: name: cf-cli-linux-rpm-packages path: signed-redhat-installer/*.rpm - - name: Build Debian Packages env: VERSION_BUILD: ${{ needs.setup.outputs.version-build }} @@ -431,6 +458,8 @@ jobs: ${{ runner.os }}-go- - name: Build macOS Binaries + env: + CF_BUILD_VERSION: ${VERSION_BUILD} run: | make out/cf-cli_osx make out/cf-cli_macosarm @@ -610,6 +639,8 @@ jobs: go install github.com/akavel/rsrc@v0.10.2 - name: Build CF CLI for Windows + env: + CF_BUILD_VERSION: ${VERSION_BUILD} run: | Get-Command make Get-Item Makefile @@ -694,14 +725,12 @@ jobs: - name: Zip Windows artifact run: | - # strip leading v to go from tag -> semver - $installer_release_version="$(cat BUILD_VERSION)".Replace("v", "") pushd "${env:RUNNER_TEMP}\win32" - $installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${installer_release_version}_win32.zip" + $installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${env:VERSION_BUILD}_win32.zip" Compress-Archive -DestinationPath "$installer_zip_filename" -Path * popd pushd "${env:RUNNER_TEMP}\winx64" - $installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${installer_release_version}_winx64.zip" + $installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${env:VERSION_BUILD}_winx64.zip" Compress-Archive -DestinationPath "$installer_zip_filename" -Path * popd Get-ChildItem "${env:RUNNER_TEMP}" diff --git a/.github/workflows/release-update-repos.yml b/.github/workflows/release-update-repos.yml index 5d223e5fc79..a36ef277d4a 100644 --- a/.github/workflows/release-update-repos.yml +++ b/.github/workflows/release-update-repos.yml @@ -3,11 +3,6 @@ run-name: "Release: Update Repositories [${{ github.ref_name }}]" on: workflow_dispatch: - inputs: - build_version: - description: 'build version format: n.n.n' - required: true - type: string permissions: contents: write @@ -20,21 +15,16 @@ jobs: setup: name: Setup runs-on: ubuntu-latest - if: ${{ github.action_repository != 'cloudfoundry/cli' }} + env: + VERSION_MAJOR: 8 outputs: - secrets-environment: ${{ steps.set-secrets-environment.outputs.secrets-environment }} - version-build: ${{ steps.parse-semver.outputs.version-build }} - version-major: ${{ steps.parse-semver.outputs.version-major }} + version-major: ${{ env.VERSION_MAJOR }} version-minor: ${{ steps.parse-semver.outputs.version-minor }} version-patch: ${{ steps.parse-semver.outputs.version-patch }} claw-url: ${{ steps.set-claw-url.outputs.claw-url }} steps: - - name: Set environment - id: set-secrets-environment - run: echo "secrets-environment=PROD" >> "${GITHUB_OUTPUT}" - - name: Set CLAW URL id: set-claw-url run: echo "claw-url=https://packages.cloudfoundry.org" >> "${GITHUB_OUTPUT}" @@ -45,18 +35,21 @@ jobs: - name: Parse semver id: parse-semver run: | - VERSION=$(cat BUILD_VERSION) - VERSION="${VERSION#[vV]}" + git fetch --tags --quiet + latest_tag="$(git tag | sort -V | grep v${VERSION_MAJOR} | tail -1)" + echo "Latest tag is ${latest_tag}" + + version="${latest_tag#[vV]}" - VERSION_MINOR="${VERSION#*.}" - VERSION_MINOR="${VERSION_MINOR%.*}" + version_minor="${version#*.}" + version_minor="${version_minor%.*}" - echo "version-build=${VERSION}" >> "${GITHUB_OUTPUT}" - echo "version-major=${VERSION%%\.*}" >> "${GITHUB_OUTPUT}" - echo "version-minor=${VERSION_MINOR}" >> "${GITHUB_OUTPUT}" - echo "version-patch=${VERSION##*.}" >> "${GITHUB_OUTPUT}" + echo "version-build=${version}" >> "${GITHUB_OUTPUT}" + echo "version-major=${version%%\.*}" >> "${GITHUB_OUTPUT}" + echo "version-minor=${version_minor}" >> "${GITHUB_OUTPUT}" + echo "version-patch=${version##*.}" >> "${GITHUB_OUTPUT}" - echo "VERSION_BUILD=${VERSION}" >> "${GITHUB_ENV}" + echo "VERSION_BUILD=${version}" >> "${GITHUB_ENV}" - name: Test if CLAW serve this version env: @@ -71,7 +64,6 @@ jobs: name: Update Homebrew Repository runs-on: ubuntu-latest needs: setup - environment: ${{ needs.setup.outputs.secrets-environment }} env: CLAW_URL: ${{ needs.setup.outputs.claw-url }} VERSION_BUILD: ${{ needs.setup.outputs.version-build }} @@ -216,7 +208,6 @@ jobs: needs: - setup - update-homebrew - environment: ${{ needs.setup.outputs.secrets-environment }} env: CLAW_URL: ${{ needs.setup.outputs.claw-url }} VERSION_BUILD: ${{ needs.setup.outputs.version-build }} @@ -244,7 +235,6 @@ jobs: name: Update Debian Repository runs-on: ubuntu-20.04 needs: setup - environment: ${{ needs.setup.outputs.secrets-environment }} env: CLAW_URL: ${{ needs.setup.outputs.claw-url }} VERSION_BUILD: ${{ needs.setup.outputs.version-build }} @@ -254,7 +244,6 @@ jobs: - name: Setup run: | echo "VERSION_BUILD: ${VERSION_BUILD}" - echo "Environment: ${ENVIRONMENT}" - name: Checkout uses: actions/checkout@v4 @@ -320,7 +309,6 @@ jobs: needs: - setup - update-deb - environment: ${{ needs.setup.outputs.secrets-environment }} env: CLAW_URL: ${{ needs.setup.outputs.claw-url }} VERSION_BUILD: ${{ needs.setup.outputs.version-build }} @@ -352,7 +340,6 @@ jobs: update-rpm: name: Update RPM Repository runs-on: ubuntu-latest - environment: ${{ needs.setup.outputs.secrets-environment }} needs: setup env: CLAW_URL: ${{ needs.setup.outputs.claw-url }} @@ -361,12 +348,8 @@ jobs: steps: - name: Setup - env: - ENVIRONMENT: ${{ github.event.inputs.environment }} - VERSION_BUILD: ${{ github.event.inputs.build_version }} run: | echo "VERSION_BUILD: ${VERSION_BUILD}" - echo "Environment: ${ENVIRONMENT}" # TODO: fix backup # - name: Download current RPM repodata @@ -450,7 +433,6 @@ jobs: runs-on: ubuntu-latest container: image: fedora - environment: ${{ needs.setup.outputs.secrets-environment }} env: CLAW_URL: ${{ needs.setup.outputs.claw-url }} VERSION_BUILD: ${{ needs.setup.outputs.version-build }} @@ -480,7 +462,6 @@ jobs: run: shell: pwsh needs: setup - environment: ${{ needs.setup.outputs.secrets-environment }} env: CLAW_URL: ${{ needs.setup.outputs.claw-url }} VERSION_BUILD: ${{ needs.setup.outputs.version-build }} @@ -490,7 +471,6 @@ jobs: - name: Setup run: | echo "VERSION_BUILD: ${VERSION_BUILD}" - echo "Environment: ${ENVIRONMENT}" - name: Checkout uses: actions/checkout@v4 @@ -549,7 +529,6 @@ jobs: needs: - setup - update-windows - environment: ${{ needs.setup.outputs.secrets-environment }} env: VERSION_BUILD: ${{ needs.setup.outputs.version-build }} VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} diff --git a/BUILD_VERSION b/BUILD_VERSION deleted file mode 100644 index bf4e26f4a85..00000000000 --- a/BUILD_VERSION +++ /dev/null @@ -1 +0,0 @@ -9.0.0-beta diff --git a/Makefile b/Makefile index 83423e8e012..c428976a443 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ FLAKE_ATTEMPTS ?=5 PACKAGES ?= api actor command types util version integration/helpers LC_ALL = "en_US.UTF-8" -CF_BUILD_VERSION ?= $$(cat BUILD_VERSION) # TODO: version specific CF_BUILD_SHA ?= $$(git rev-parse --short HEAD) CF_BUILD_DATE ?= $$(date -u +"%Y-%m-%d") LD_FLAGS_COMMON=-w -s \ diff --git a/bin/bump-version b/bin/bump-version deleted file mode 100755 index b4693dc4e90..00000000000 --- a/bin/bump-version +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -set -eo pipefail - -component=$1 -script_dir=$(dirname $0) -version_file="$script_dir/../BUILD_VERSION" - -old_version=$(cat $version_file) -major=$(echo $old_version | cut -d'.' -f 1) -minor=$(echo $old_version | cut -d'.' -f 2) -patchAndSuffix=$(echo $old_version | cut -d'.' -f 3) -patch=$(echo $patchAndSuffix | cut -d'-' -f 1) -suffix=$(echo $patchAndSuffix | cut -s -d'-' -f 2) - -case "$component" in - major ) - major=$(expr $major + 1) - minor=0 - patch=0 - ;; - minor ) - minor=$(expr $minor + 1) - patch=0 - ;; - patch ) - patch=$(expr $patch + 1) - ;; - * ) - echo "Error - argument must be 'major', 'minor' or 'patch'" - echo "Usage: bump-version [major | minor | patch]" - exit 1 - ;; -esac -set -u - -version=$major.$minor.$patch - -if [ ! -z "$suffix" ]; then - version="${version}-${suffix}" -fi - -echo "Updating BUILD_VERSION file to $version" -echo $version > $version_file - -echo "Committing change" -git reset . -git add $version_file - -git commit -m "Bump version to $version" diff --git a/bin/generate-release-notes b/bin/generate-release-notes deleted file mode 100755 index 0a06524f399..00000000000 --- a/bin/generate-release-notes +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -VERSION=$(cat BUILD_VERSION) - -cat <<-NOTES -Package Manager Installation ----------- -- [apt-get, yum, homebrew](https://github.com/cloudfoundry/cli#getting-started) - -Installers ----------- -- Debian [64 bit](https://packages.cloudfoundry.org/stable?release=debian64&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=debian32&version=$VERSION&source=github-rel) / [arm64](https://packages.cloudfoundry.org/stable?release=debianarm64&version=$VERSION&source=github-rel) (deb) -- Redhat [64 bit](https://packages.cloudfoundry.org/stable?release=redhat64&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=redhat32&version=$VERSION&source=github-rel) / [aarch64](https://packages.cloudfoundry.org/stable?release=redhataarch64&version=$VERSION&source=github-rel) (rpm) -- macOS [64 bit](https://packages.cloudfoundry.org/stable?release=macosx64&version=$VERSION&source=github-rel) / [arm](https://packages.cloudfoundry.org/stable?release=macosarm&version=$VERSION&source=github-rel) (pkg) -- Windows [64 bit](https://packages.cloudfoundry.org/stable?release=windows64&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=windows32&version=$VERSION&source=github-rel) (zip) - -Binaries --------- -- Linux [64 bit](https://packages.cloudfoundry.org/stable?release=linux64-binary&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=linux32-binary&version=$VERSION&source=github-rel) / [arm64](https://packages.cloudfoundry.org/stable?release=linuxarm64-binary&version=$VERSION&source=github-rel) (tgz) -- macOS [64 bit](https://packages.cloudfoundry.org/stable?release=macosx64-binary&version=$VERSION&source=github-rel) / [arm](https://packages.cloudfoundry.org/stable?release=macosarm-binary&version=$VERSION&source=github-rel) (tgz) -- Windows [64 bit](https://packages.cloudfoundry.org/stable?release=windows64-exe&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=windows32-exe&version=$VERSION&source=github-rel) (zip) - - -Docker --------- -\`\`\`shell -docker pull cloudfoundry/cli:$VERSION -\`\`\` - -Change Log ----------- -NOTES diff --git a/build_data.yml b/build_data.yml deleted file mode 100644 index 06100fe6449..00000000000 --- a/build_data.yml +++ /dev/null @@ -1,3 +0,0 @@ -build-version: 9.0.0-beta -capi-version-min: v16.11.0 -capi-version-max: v99.99.99