Skip to content

Commit

Permalink
Automate release version generation [main] (cloudfoundry#3267)
Browse files Browse the repository at this point in the history
* Remove build_version file and references

* Remove unused files
Co-authored-by: Pavel Busko <[email protected]>
  • Loading branch information
gururajsh authored and nicolasbender committed Nov 5, 2024
1 parent 50976b6 commit 7c1408a
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 151 deletions.
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"

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 "[email protected]"
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 @@ -610,6 +639,8 @@ jobs:
go install github.com/akavel/[email protected]
- name: Build CF CLI for Windows
env:
CF_BUILD_VERSION: ${VERSION_BUILD}
run: |
Get-Command make
Get-Item Makefile
Expand Down Expand Up @@ -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}"
Expand Down
51 changes: 15 additions & 36 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,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}"
Expand All @@ -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:
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -254,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 @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -490,7 +471,6 @@ jobs:
- name: Setup
run: |
echo "VERSION_BUILD: ${VERSION_BUILD}"
echo "Environment: ${ENVIRONMENT}"
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -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 }}
Expand Down
1 change: 0 additions & 1 deletion BUILD_VERSION

This file was deleted.

1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
50 changes: 0 additions & 50 deletions bin/bump-version

This file was deleted.

Loading

0 comments on commit 7c1408a

Please sign in to comment.