Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate release version generation [v8] #3268

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 57 additions & 28 deletions .github/workflows/release-build-sign-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
gururajsh marked this conversation as resolved.
Show resolved Hide resolved

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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -609,6 +638,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
Expand Down Expand Up @@ -693,14 +724,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}"
Expand Down
37 changes: 15 additions & 22 deletions .github/workflows/release-update-repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,10 +15,11 @@ jobs:
setup:
name: Setup
runs-on: ubuntu-latest
if: ${{ github.action_repository != 'cloudfoundry/cli' }}
env:
VERSION_MAJOR: 8
outputs:
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 }}
Expand All @@ -39,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:
Expand Down Expand Up @@ -245,7 +244,6 @@ jobs:
- name: Setup
run: |
echo "VERSION_BUILD: ${VERSION_BUILD}"
echo "Environment: ${ENVIRONMENT}"

- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -350,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
Expand Down Expand Up @@ -473,7 +467,6 @@ jobs:
- name: Setup
run: |
echo "VERSION_BUILD: ${VERSION_BUILD}"
echo "Environment: ${ENVIRONMENT}"

- name: Checkout
uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ NODES ?= 10
PACKAGES ?= api actor command types util version integration/helpers
LC_ALL = "en_US.UTF-8"

CF_BUILD_VERSION ?= $$(cat BUILD_VERSION) # TODO: version specific
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question(non-blocking): do we still see some value in keeping build_data.yml up to date? As it was introduced as an eventual alternative to BUILD_VERSION.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, even that file can be removed. It was mostly used for min capi tests. Since we don't have any, will remove that as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

CF_BUILD_SHA ?= $$(git rev-parse --short HEAD)
CF_BUILD_DATE ?= $$(date -u +"%Y-%m-%d")
LD_FLAGS_COMMON=-w -s \
Expand Down
50 changes: 0 additions & 50 deletions bin/bump-version
a-b marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

32 changes: 0 additions & 32 deletions bin/generate-release-notes

This file was deleted.

Loading