Skip to content

Commit f6ab24a

Browse files
gururajsha-b
andauthored
Automate release version generation [v8] (#3268)
* Remove build_version file and references * Remove unused files * Update .github/workflows/release-build-sign-upload.yml Co-authored-by: AL Berez <[email protected]> --------- Co-authored-by: AL Berez <[email protected]>
1 parent 0e5962b commit f6ab24a

File tree

7 files changed

+72
-136
lines changed

7 files changed

+72
-136
lines changed

.github/workflows/release-build-sign-upload.yml

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,18 @@ run-name: "Release: Build Sign Upload [${{ github.ref_name }}]"
3838

3939
on:
4040
workflow_dispatch:
41+
inputs:
42+
release_version:
43+
description: 'Release version bump'
44+
required: true
45+
default: 'patch'
46+
type: choice
47+
options:
48+
- minor
49+
- patch
4150

4251
permissions:
43-
contents: read
52+
contents: write
4453

4554
defaults:
4655
run:
@@ -50,39 +59,56 @@ jobs:
5059
setup:
5160
name: Setup
5261
runs-on: ubuntu-latest
53-
62+
env:
63+
VERSION_MAJOR: 8
5464
outputs:
55-
aws-s3-bucket: "v${{ steps.parse-semver.outputs.version-major }}-cf-cli-releases"
65+
aws-s3-bucket: "v${{ steps.bump-version.outputs.version-major }}-cf-cli-releases"
5666

57-
version-build: ${{ steps.parse-semver.outputs.version-build }}
58-
version-major: ${{ steps.parse-semver.outputs.version-major }}
59-
version-minor: ${{ steps.parse-semver.outputs.version-minor }}
60-
version-patch: ${{ steps.parse-semver.outputs.version-patch }}
67+
version-build: ${{ steps.bump-version.outputs.version-build }}
68+
version-major: ${{ env.VERSION_MAJOR }}
69+
version-minor: ${{ steps.bump-version.outputs.version-minor }}
70+
version-patch: ${{ steps.bump-version.outputs.version-patch }}
6171

6272
steps:
6373
- name: Checkout cli
6474
uses: actions/checkout@v4
65-
66-
- name: Check if VERSION_BUILD matches tag ${{ github.ref }}
75+
76+
- name: Bump version
77+
id: bump-version
6778
run: |
68-
echo "Git Ref: ${{ github.ref }}"
69-
echo "VERSION_BUILD: $(cat BUILD_VERSION)"
79+
set -x
80+
git fetch --tags --quiet
81+
latest_tag="$(git tag | sort -V | grep v${VERSION_MAJOR} | tail -1)"
82+
echo "Latest tag is ${latest_tag}"
7083
71-
exit 0
84+
version="${latest_tag#[vV]}"
7285
73-
- name: Parse semver
74-
id: parse-semver
75-
run: |
76-
VERSION=$(cat BUILD_VERSION)
77-
VERSION="${VERSION#[vV]}"
86+
version_minor="${version#*.}"
87+
version_minor="${version_minor%.*}"
88+
version_patch=${version##*.}
7889
79-
VERSION_MINOR="${VERSION#*.}"
80-
VERSION_MINOR="${VERSION_MINOR%.*}"
90+
if [ "${{ inputs.release_version }}" == "minor" ]; then
91+
version_minor=$(($version_minor + 1))
92+
version_patch=0
93+
else
94+
version_patch=$(($version_patch + 1))
95+
fi
8196
82-
echo "version-build=${VERSION}" >> "${GITHUB_OUTPUT}"
83-
echo "version-major=${VERSION%%\.*}" >> "${GITHUB_OUTPUT}"
84-
echo "version-minor=${VERSION_MINOR}" >> "${GITHUB_OUTPUT}"
85-
echo "version-patch=${VERSION##*.}" >> "${GITHUB_OUTPUT}"
97+
new_version="${VERSION_MAJOR}.${version_minor}.${version_patch}"
98+
echo "new version is ${new_version}"
99+
100+
echo "version-build=${new_version}" >> "${GITHUB_OUTPUT}"
101+
echo "version-minor=${version_minor}" >> "${GITHUB_OUTPUT}"
102+
echo "version-patch=${version_patch}" >> "${GITHUB_OUTPUT}"
103+
104+
- name: Publish Tag
105+
run: |
106+
new_tag="v${{ steps.bump-version.outputs.version-build }}"
107+
echo "new version is $new_tag"
108+
git config user.name "GitHub Actions"
109+
git config user.email "[email protected]"
110+
git tag -am "Bump cli version ${new_tag}" ${new_tag}
111+
git push origin $new_tag
86112
87113
build-linux:
88114
name: Build Linux
@@ -135,6 +161,8 @@ jobs:
135161
${{ runner.os }}-go-
136162
137163
- name: Build Linux
164+
env:
165+
CF_BUILD_VERSION: ${VERSION_BUILD}
138166
run: |
139167
make out/cf-cli_linux_i686
140168
make out/cf-cli_linux_x86-64
@@ -252,7 +280,6 @@ jobs:
252280
name: cf-cli-linux-rpm-packages
253281
path: signed-redhat-installer/*.rpm
254282

255-
256283
- name: Build Debian Packages
257284
env:
258285
VERSION_BUILD: ${{ needs.setup.outputs.version-build }}
@@ -431,6 +458,8 @@ jobs:
431458
${{ runner.os }}-go-
432459
433460
- name: Build macOS Binaries
461+
env:
462+
CF_BUILD_VERSION: ${VERSION_BUILD}
434463
run: |
435464
make out/cf-cli_osx
436465
make out/cf-cli_macosarm
@@ -609,6 +638,8 @@ jobs:
609638
go install github.com/akavel/[email protected]
610639
611640
- name: Build CF CLI for Windows
641+
env:
642+
CF_BUILD_VERSION: ${VERSION_BUILD}
612643
run: |
613644
Get-Command make
614645
Get-Item Makefile
@@ -693,14 +724,12 @@ jobs:
693724
694725
- name: Zip Windows artifact
695726
run: |
696-
# strip leading v to go from tag -> semver
697-
$installer_release_version="$(cat BUILD_VERSION)".Replace("v", "")
698727
pushd "${env:RUNNER_TEMP}\win32"
699-
$installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${installer_release_version}_win32.zip"
728+
$installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${env:VERSION_BUILD}_win32.zip"
700729
Compress-Archive -DestinationPath "$installer_zip_filename" -Path *
701730
popd
702731
pushd "${env:RUNNER_TEMP}\winx64"
703-
$installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${installer_release_version}_winx64.zip"
732+
$installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${env:VERSION_BUILD}_winx64.zip"
704733
Compress-Archive -DestinationPath "$installer_zip_filename" -Path *
705734
popd
706735
Get-ChildItem "${env:RUNNER_TEMP}"

.github/workflows/release-update-repos.yml

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ run-name: "Release: Update Repositories [${{ github.ref_name }}]"
33

44
on:
55
workflow_dispatch:
6-
inputs:
7-
build_version:
8-
description: 'build version format: n.n.n'
9-
required: true
10-
type: string
116

127
permissions:
138
contents: write
@@ -20,10 +15,11 @@ jobs:
2015
setup:
2116
name: Setup
2217
runs-on: ubuntu-latest
23-
if: ${{ github.action_repository != 'cloudfoundry/cli' }}
18+
env:
19+
VERSION_MAJOR: 8
2420
outputs:
2521
version-build: ${{ steps.parse-semver.outputs.version-build }}
26-
version-major: ${{ steps.parse-semver.outputs.version-major }}
22+
version-major: ${{ env.VERSION_MAJOR }}
2723
version-minor: ${{ steps.parse-semver.outputs.version-minor }}
2824
version-patch: ${{ steps.parse-semver.outputs.version-patch }}
2925
claw-url: ${{ steps.set-claw-url.outputs.claw-url }}
@@ -39,18 +35,21 @@ jobs:
3935
- name: Parse semver
4036
id: parse-semver
4137
run: |
42-
VERSION=$(cat BUILD_VERSION)
43-
VERSION="${VERSION#[vV]}"
38+
git fetch --tags --quiet
39+
latest_tag="$(git tag | sort -V | grep v${VERSION_MAJOR} | tail -1)"
40+
echo "Latest tag is ${latest_tag}"
41+
42+
version="${latest_tag#[vV]}"
4443
45-
VERSION_MINOR="${VERSION#*.}"
46-
VERSION_MINOR="${VERSION_MINOR%.*}"
44+
version_minor="${version#*.}"
45+
version_minor="${version_minor%.*}"
4746
48-
echo "version-build=${VERSION}" >> "${GITHUB_OUTPUT}"
49-
echo "version-major=${VERSION%%\.*}" >> "${GITHUB_OUTPUT}"
50-
echo "version-minor=${VERSION_MINOR}" >> "${GITHUB_OUTPUT}"
51-
echo "version-patch=${VERSION##*.}" >> "${GITHUB_OUTPUT}"
47+
echo "version-build=${version}" >> "${GITHUB_OUTPUT}"
48+
echo "version-major=${version%%\.*}" >> "${GITHUB_OUTPUT}"
49+
echo "version-minor=${version_minor}" >> "${GITHUB_OUTPUT}"
50+
echo "version-patch=${version##*.}" >> "${GITHUB_OUTPUT}"
5251
53-
echo "VERSION_BUILD=${VERSION}" >> "${GITHUB_ENV}"
52+
echo "VERSION_BUILD=${version}" >> "${GITHUB_ENV}"
5453
5554
- name: Test if CLAW serve this version
5655
env:
@@ -245,7 +244,6 @@ jobs:
245244
- name: Setup
246245
run: |
247246
echo "VERSION_BUILD: ${VERSION_BUILD}"
248-
echo "Environment: ${ENVIRONMENT}"
249247
250248
- name: Checkout
251249
uses: actions/checkout@v4
@@ -350,12 +348,8 @@ jobs:
350348
steps:
351349

352350
- name: Setup
353-
env:
354-
ENVIRONMENT: ${{ github.event.inputs.environment }}
355-
VERSION_BUILD: ${{ github.event.inputs.build_version }}
356351
run: |
357352
echo "VERSION_BUILD: ${VERSION_BUILD}"
358-
echo "Environment: ${ENVIRONMENT}"
359353
360354
# TODO: fix backup
361355
# - name: Download current RPM repodata
@@ -473,7 +467,6 @@ jobs:
473467
- name: Setup
474468
run: |
475469
echo "VERSION_BUILD: ${VERSION_BUILD}"
476-
echo "Environment: ${ENVIRONMENT}"
477470
478471
- name: Checkout
479472
uses: actions/checkout@v4

BUILD_VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ NODES ?= 10
33
PACKAGES ?= api actor command types util version integration/helpers
44
LC_ALL = "en_US.UTF-8"
55

6-
CF_BUILD_VERSION ?= $$(cat BUILD_VERSION) # TODO: version specific
76
CF_BUILD_SHA ?= $$(git rev-parse --short HEAD)
87
CF_BUILD_DATE ?= $$(date -u +"%Y-%m-%d")
98
LD_FLAGS_COMMON=-w -s \

bin/bump-version

Lines changed: 0 additions & 50 deletions
This file was deleted.

bin/generate-release-notes

Lines changed: 0 additions & 32 deletions
This file was deleted.

build_data.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)