debug #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Bosh Release | |
on: | |
workflow_dispatch: { } | |
push: | |
branches: | |
- "main" | |
env: | |
RELEASE: "otelcollector-binary" | |
DESCRIPTION: "OpenTelemetry Collector binary Release" | |
BOSH_CLI_VERSION: "7.5.5" | |
permissions: {} | |
jobs: | |
build-final-release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
lfs: true | |
- 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 final bosh release | |
id: boshrelease | |
run: | | |
mkdir -p .build | |
bosh sync-blobs | |
echo "${GITHUB_REF#refs/tags/}" | |
if [[ "${GITHUB_REF#refs/tags/}" =~ ^refs/tags.* ]]; | |
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" >> $GITHUB_OUTPUT | |
else | |
tag="${GITHUB_REF#refs/tags/}" | |
if [[ "${tag#v}" =~ ^([0-9]+\.){0,2}(\*|[0-9]+)$ ]] | |
then | |
# Tag is a version, create it with this vesion | |
bosh create-release --final --tarball="$GITHUB_WORKSPACE/.build/$RELEASE.tgz" --version "${tag#v}" | |
else | |
# Tag is not a version, major version | |
bosh create-release --final --tarball="$GITHUB_WORKSPACE/.build/$RELEASE.tgz" | |
fi | |
echo "type=final" >> $GITHUB_OUTPUT | |
fi | |
version=$(ls releases/$RELEASE/$RELEASE-*.yml | sed 's/.*\/.*-\(.*\)\.yml$/\1/' | sort -t. -k 1,1nr -k 2,2nr | head -1) | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
echo "file=$GITHUB_WORKSPACE/.build/$RELEASE.tgz" >> $GITHUB_OUTPUT | |
- name: Uploads artifact release | |
uses: actions/upload-artifact@v4 | |
with: | |
name: boshelease | |
path: ${{ steps.boshrelease.outputs.file }} | |
# - name: Git commit final resources | |
# if: ${{ steps.boshrelease.outputs.type == 'final' }} | |
# run: | | |
# git add .final_builds blobstore releases | |
# git commit -m "Release version ${{ steps.boshrelease.outputs.version }}" | |
# # This does not trigger another workflow with built-in `GITHUB_TOKEN` secret | |
# git push | |
- 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 final bosh release | |
run: | | |
cat .build/release-notes.txt | |
echo ${{ steps.boshrelease.outputs.type }} | |
# - name: Create a Release | |
# uses: softprops/action-gh-release@v2 | |
# with: | |
# token: ${{ secrets.GITHUB_TOKEN }} | |
# draft: ${{ 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' }} |