Skip to content

Update binary otel-collector package to 0.97.0 #58

Update binary otel-collector package to 0.97.0

Update binary otel-collector package to 0.97.0 #58

name: Release Bosh Release
on:
workflow_dispatch: { }
push:
branches:
- "main"
tags:
- '**'
env:
RELEASE: "otelcollector-binary"
DESCRIPTION: "OpenTelemetry Collector binary Release"
BOSH_CLI_VERSION: "7.5.5"
permissions: {}
jobs:
build-bosh-release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
ref: ${{ github.ref_name }}
- name: Git config and checkout LFS blobs
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git lfs checkout
- name: Install Bosh cli and other dependencies
run: |
mkdir -p .bin
wget -nv https://github.com/cloudfoundry/bosh-cli/releases/download/v${BOSH_CLI_VERSION}/bosh-cli-${BOSH_CLI_VERSION}-linux-amd64 -O .bin/bosh
chmod a+x .bin/bosh
echo "$GITHUB_WORKSPACE/.bin" >> $GITHUB_PATH
- name: Create Bosh release
id: boshrelease
run: |
mkdir -p .build
bosh sync-blobs
echo "GITHUB_REF=${GITHUB_REF}"
echo "GITHUB_REF_NAME=${GITHUB_REF_NAME}"
if [[ "${GITHUB_REF#refs/tags/}" =~ ^refs/.* ]]
then
# the trigger does not come from a tag. Not a final version
bosh create-release --tarball="$GITHUB_WORKSPACE/.build/$RELEASE.tgz"
echo "type=dev" | tee -a $GITHUB_OUTPUT
else
tag="${GITHUB_REF_NAME}"
if [[ "${tag#v}" =~ ^([0-9]+\.){0,2}(\*|[0-9]+)$ ]]
then
# Tag is a version, create it with this vesion
echo "Using provided version from the tag (tag=$tag)"
bosh create-release --final --tarball="$GITHUB_WORKSPACE/.build/$RELEASE.tgz" --version "${tag#v}"
else
# Tag is not a version, bosh will increase the minor version automatically
echo "Tag does not match version (tag=$tag). Let bosh to calculate the next one"
bosh create-release --final --tarball="$GITHUB_WORKSPACE/.build/$RELEASE.tgz"
fi
echo "type=final" | tee -a >> $GITHUB_OUTPUT
fi
version=$(ls releases/$RELEASE/*.yml | sed 's/.*\/.*-\(.*\)\.yml$/\1/' | sort -t. -k 1,1nr -k 2,2nr | head -1)
echo "version=${version}" | tee -a $GITHUB_OUTPUT
echo "file=$GITHUB_WORKSPACE/.build/$RELEASE.tgz" | tee -a $GITHUB_OUTPUT
echo "release=$RELEASE" | tee -a $GITHUB_OUTPUT
- name: Uploads artifact release
uses: actions/upload-artifact@v4
with:
name: "${{ steps.boshrelease.outputs.release }}-${{ steps.boshrelease.outputs.version }}-boshrelease"
path: ${{ steps.boshrelease.outputs.file }}
- name: Git commit final resources
if: ${{ steps.boshrelease.outputs.type == 'final' }}
run: |
git add .final_builds blobstore releases
message=$(git tag -l --format='%(contents)' "${GITHUB_REF_NAME}")
git commit -m "${message}"
remote=main
[ "${{ github.ref_type }}" == "branch" ] && remote=${{ github.ref_name }}
# This does not trigger another workflow with built-in `GITHUB_TOKEN` secret
git push origin HEAD:${remote}
- name: Generate release notes from git commits
run: |
lastcommit=$(git log --no-walk --tags --pretty="%h %s" | awk 'NR==1{ print $1 }')
git_changes=$(git log --pretty="%h %aI %s (%an)" $lastcommit..@ | sed 's/^/- /')
version="${{ steps.boshrelease.outputs.version }}"
sha1=$(openssl sha1 "${{ steps.boshrelease.outputs.file }}" | awk '{ print $2 }')
cat <<EOF > .build/release-notes.txt
# $RELEASE version $version
$DESCRIPTION
## Changes since last version
$git_changes
## Using in a bosh Deployment
releases:
- name: $RELEASE
url: https://github.com/${GITHUB_REPOSITORY}/releases/download/v${version}/${RELEASE}.tgz
version: $version
sha1: $sha1
or to always point to latest release:
releases:
- name: $RELEASE
url: https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/${RELEASE}.tgz
version: latest
EOF
- name: Create a Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ steps.boshrelease.outputs.type != 'final' }}
tag_name: "v${{ steps.boshrelease.outputs.version }}"
files: ${{ steps.boshrelease.outputs.file }}
body_path: .build/release-notes.txt
generate_release_notes: true
make_latest: ${{ steps.boshrelease.outputs.type == 'final' }}