Skip to content

Create Bosh Release #54

Create Bosh Release

Create Bosh Release #54

name: Create Bosh Release
on:
workflow_dispatch:
inputs:
version_bump_type:
type: choice
default: minor
description: Make a choice
options:
- patch
- minor
- major
defaults:
run:
shell: bash
env:
BOSH_DEPLOYMENT: cf-cli-test
BOSH_NON_INTERACTIVE: true
PAGER: cat
BBL_IAAS: gcp
BBL_GCP_REGION: us-east1
BBL_GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_CREDENTIALS_JSON }}
jobs:
create_bosh_release:
name: Create Bosh Release
runs-on: ubuntu-latest
container:
image: "ghcr.io/${{ github.repository }}-ci:main-latest"
permissions:
contents: write
steps:
- name: Checkout cli bosh release repo
uses: actions/checkout@v4
- name: Acquire latest CF CLI binaries
run: |
./ci/scripts/download-cf-cli-binary.sh --major-version 8 --output-dir ./build/cf-cli-binaries
- name: Overwrite config/final.yml with the destination bucket
if: ${{ vars.PRODUCTION == 'true' }}
run: |
cat << EOF > config/final.yml
name: cf-cli
blobstore:
provider: s3
options:
region: ${{ vars.AWS_S3_REGION }}
bucket_name: ${{ vars.AWS_S3_BUCKET }}
endpoint: http://s3-us-west-1.amazonaws.com
EOF
- name: Configure S3 backend for bosh in config/private.yml
if: ${{ vars.PRODUCTION == 'true' }}
run: |
cat << EOF > config/private.yml
blobstore:
options:
access_key_id: "${{ secrets.AWS_S3_ACCESS_KEY_ID }}"
assume_role_arn: "${{ secrets.AWS_S3_ASSUME_ROLE_ARN }}"
secret_access_key: "${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}"
EOF
- name: Create bosh release candidate
env:
TRACE: ${{ runner.debug }}
run: |
./ci/scripts/create-bosh-release-candidate.sh \
--downloaded-binaries-dir ./build/cf-cli-binaries \
--git-username "github-actions[bot]" \
--git-email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Store bosh release artifact
uses: actions/upload-artifact@v4
with:
name: bosh-release-candidate
path: ./cf-cli-dev-release.tgz
- name: Upload bosh blobs to blobstore
if: ${{ vars.PRODUCTION == 'true' }}
run: |
bosh upload-blobs
- name: Push changes
if: ${{ vars.PRODUCTION == 'true' }}
uses: ad-m/github-push-action@9870d48124da805820c70ebc6ba563c715551019
with:
branch: ${{ format('{0}{1}', github.ref, vars.BRANCH_SUFFIX) }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout bosh-bootloader
uses: actions/checkout@v4
with:
repository: cloudfoundry/bosh-bootloader
path: bosh-bootloader
- name: Setup bbl
id: setup-bbl-env
run: |
env_name="$(grep '^.\{1,4\}$' /usr/share/dict/words |
shuf -n1 |
tr -dc '[:alnum:]\n\r' |
tr '[:upper:]' '[:lower:]')"
if [ ! -z "${env_name}" ]; then
env_name=cli-bosh-rel-${env_name}
mkdir -p $env_name/bbl-state
fi
echo "Bbl environment name: $env_name"
echo "envName=$env_name" >> $GITHUB_OUTPUT
- name: Create bbl env
id: create-env
run: |
env_name=${{ steps.setup-bbl-env.outputs.envName }}
cd $env_name/bbl-state
cp -R ${GITHUB_WORKSPACE}/bosh-bootloader/plan-patches/bosh-lite-gcp/* .
bbl plan --name $env_name
bbl up
eval "$(bbl print-env)"
bosh upload-stemcell "https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-jammy-go_agent?v=${{ vars.STEMCELL_VERSION }}"
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }}
- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@v1
- name: Save bbl state
run: |
env_name=${{ steps.setup-bbl-env.outputs.envName }}
gsutil -m cp -P -R ./$env_name gs://cf-cli-bosh-lites/
- name: Deploy and run tests
if: ${{ vars.SKIP_TESTS != 'true' }}
run: |
env_name=${{ steps.setup-bbl-env.outputs.envName }}
pushd $env_name/bbl-state
eval "$(bbl print-env)"
popd
echo "::group::Bosh deploy"
bosh deploy ./manifests/test.yml
echo "::endgroup::"
echo "::group::Bosh run-errand cf-cli-8-linux-test"
bosh run-errand cf-cli-8-linux-test \
| tee /tmp/cf-cli-8-linux-test.out
echo "::endgroup::"
bosh delete-deployment
bosh clean-up --all
- name: Verify test results
if: ${{ vars.SKIP_TESTS != 'true' }}
run: |
set -x -o errexit -o nounset -o pipefail
for test_result in /tmp/cf-cli-*-test.out; do
cf_version=$(grep -e 'cf version' $test_result | sed 's/cf version //')
echo "result_${test_result%.*}=${cf_version}" >> $GITHUB_OUTPUT
done
- name: Generate next release version
id: generate-next-release-version
env:
BUMP_TYPE: ${{ inputs.version_bump_type }}
run: |
_last_cf_cli_bosh_release_version=$(find releases/cf-cli -name 'cf-cli-*.yml' | sort -V | tail -1 | sed 's/.*cf-cli-\([[:digit:]].*\).yml/\1/')
echo "Last CF CLI bosh release version: ${_last_cf_cli_bosh_release_version}"
if ! [[ "$_last_cf_cli_bosh_release_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Release version must be in the format X.Y.Z"
exit 1
fi
IFS='.' read -r -a version_parts <<< "$_last_cf_cli_bosh_release_version"
major="${version_parts[0]}"
minor="${version_parts[1]}"
patch="${version_parts[2]}"
case "$BUMP_TYPE" in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
*)
echo "BUMP_TYPE must be one of: major, minor, patch"
exit 1
;;
esac
_new_cf_cli_bosh_release_version="${major}.${minor}.${patch}"
echo "New CF CLI bosh release version: ${_new_cf_cli_bosh_release_version}"
echo "version=${_new_cf_cli_bosh_release_version}" >> $GITHUB_OUTPUT
# Finalize bosh release
# Get final release from assets
# Push commit with final release
- name: Finalize bosh release
env:
TRACE: ${{ runner.debug }}
RELEASE_VERSION: ${{ steps.generate-next-release-version.outputs.version }}
run: |
set -o errexit -o nounset -o pipefail
[[ "${TRACE:-0}" == "1" ]] && set -o xtrace
echo "Releasing version: ${RELEASE_VERSION:?}"
echo "::group::Blobs included in cf-cli release: v${RELEASE_VERSION}"
bosh blobs
echo "::endgroup::"
git config --global --add safe.directory "$(pwd)"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com "
echo "::group::Git state before final release"
git diff --patch
git status
echo "::endgroup::"
git update-index --skip-worktree config/blobs.yml
git update-index --skip-worktree config/final.yml
bosh create-release --final --version="${RELEASE_VERSION}" --tarball="./cf-cli-v${RELEASE_VERSION}.tgz"
echo "::group::Git state after final release"
git diff --patch
git status
echo "::endgroup::"
git add \
.final_builds/packages/cf-cli-8-linux/index.yml \
releases
echo "::group::Git before the commit"
git diff --patch
git status
echo "::endgroup::"
_message="create final release ${RELEASE_VERSION}"
git commit --message "${_message}"
git log --pretty=full --max-count=3
_git_tag="v${RELEASE_VERSION:?}"
git tag $_git_tag
- name: Push changes
if: ${{ vars.PRODUCTION == 'true' }}
uses: ad-m/github-push-action@9870d48124da805820c70ebc6ba563c715551019
with:
branch: ${{ format('{0}{1}', github.ref, vars.BRANCH_SUFFIX) }}
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: true
- name: Generate Release Notes
run: |
_cf_cli_versions=$(bosh blobs | cut -d_ -f2)
cat << EOF > release_notes
### Included CF CLI versions:
${_cf_cli_versions:?}
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: release_notes
fail_on_unmatched_files: true
make_latest: true
name: v${{ steps.generate-next-release-version.outputs.version }}
tag_name: v${{ steps.generate-next-release-version.outputs.version }}
files: |
./cf-cli-v${{ steps.generate-next-release-version.outputs.version }}.tgz
- name: Delete env
if: ${{ always() && !vars.ENV_ID && steps.create-env.outcome == 'success' && !runner.debug }}
run: |
env_name=${{ steps.setup-bbl-env.outputs.envName }}
cd $env_name/bbl-state
bbl destroy --no-confirm
rm -rf $env_name
gsutil rm -R gs://cf-cli-bosh-lites/$env_name