Skip to content

remove debug

remove debug #35

name: Release Docker image
on:
workflow_dispatch: { }
push:
branches:
- "main"
tags:
- '**'
env:
# Default image for the Chart
DOCKER_IMAGE_NAME: otel-collector
DOCKER_REGISTRY: ghcr.io/${{ github.repository }}
DOCKER_BUILD_DIR: '.'
permissions: {}
jobs:
compile:
runs-on: ubuntu-latest
outputs:
artifact: ${{ steps.artifact.outputs.artifact-id }}
version: ${{ steps.versions.outputs.version }}
build-name: ${{ steps.versions.outputs.build-name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup golang stable
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Get build versions
id: versions
run: |
OTELCOL_VERSION=$(awk -F':' '/^[[:blank:]]+otelcol_version[[:blank:]]*:/{ gsub("\"","",$2); gsub(" ", "", $2); print $2 }' builder-config.yaml)
echo "otelcol-version=$OTELCOL_VERSION" | tee -a $GITHUB_OUTPUT
BUILD_PATH=$(awk -F':' '/^[[:blank:]]+output_path[[:blank:]]*:/{ gsub("\"","",$2); gsub(" ", "", $2); print $2 }' builder-config.yaml)
echo "build-path=$BUILD_PATH" | tee -a $GITHUB_OUTPUT
BUILD_NAME=$(awk -F':' '/^[[:blank:]]+name[[:blank:]]*:/{ gsub("\"","",$2); gsub(" ", "", $2); print $2 }' builder-config.yaml)
echo "build-name=$BUILD_NAME" | tee -a $GITHUB_OUTPUT
VERSION=$(awk -F':' '/^[[:blank:]]+version[[:blank:]]*:/{ gsub("\"","",$2); gsub(" ", "", $2); print $2 }' builder-config.yaml)
echo "version=$VERSION" | tee -a $GITHUB_OUTPUT
- name: Download the collector builder
run: |
curl -Ss -fL -o ocb https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/cmd%2Fbuilder%2Fv${VERSION}/ocb_${VERSION}_linux_amd64
chmod +x ocb
env:
VERSION: "${{ steps.versions.outputs.otelcol-version }}"
- name: Build the OTEL collectory binary
run: |
./ocb --config builder-config.yaml
- name: Archive binary
id: artifact
uses: actions/upload-artifact@v4
with:
name: "otelcol-${{ steps.versions.outputs.version }}_linux_amd64"
retention-days: 1
path: "${{ steps.versions.outputs.build-path }}/${{ steps.versions.outputs.build-name }}"
if-no-files-found: error
overwrite: true
build-image:
permissions:
contents: read
packages: write
needs:
- compile
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifact
id: artifact
uses: actions/download-artifact@v4
with:
name: "otelcol-${{ needs.compile.outputs.version }}_linux_amd64"
path: build
- name: Get metadata for Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=ref,event=branch
type=sha
- name: Build and export to Docker
uses: docker/build-push-action@v6
with:
context: ${{ env.DOCKER_BUILD_DIR }}
build-args: |
"OTEL_BIN=build/${{ needs.compile.outputs.build-name }}"
load: true
tags: otelcol
# - name: Test
# run: |
# docker run --rm otelcol
- name: Log in to the GitHub Container registry
if: ${{ (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags/')) }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to Github Packages
uses: docker/build-push-action@v6
if: ${{ (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags/')) }}
with:
context: ${{ env.DOCKER_BUILD_DIR }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
"OTEL_BIN=build/${{ needs.compile.outputs.build-name }}"
tags: |
${{ steps.meta.outputs.tags }}
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.compile.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
release:
permissions:
contents: write
packages: read
needs:
- compile
- build-image
if: ${{ (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags/')) }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get artifact
id: artifact
uses: actions/download-artifact@v4
with:
name: "otelcol-${{ needs.compile.outputs.version }}_linux_amd64"
path: build
- name: Get list of artifacts
run: |
cd "${{ steps.artifact.outputs.download-path }}"
mkdir "otelcol-custom_${{ needs.compile.outputs.version }}"
cp "${{ needs.compile.outputs.build-name }}" "otelcol-custom_${{ needs.compile.outputs.version }}/otelcol-custom_${{ needs.compile.outputs.version }}_linux_amd64"
mv "${{ needs.compile.outputs.build-name }}" "otelcol-custom_${{ needs.compile.outputs.version }}_linux_amd64.bin"
tar zcvf "otelcol-custom_${{ needs.compile.outputs.version }}.tgz" "otelcol-custom_${{ needs.compile.outputs.version }}"
rm "otelcol-custom_${{ needs.compile.outputs.version }}"
- name: Create a Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: "${{ steps.artifact.outputs.download-path }}/*"