otlpinf-release #97
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: otlpinf-release | |
on: | |
push: | |
branches: [ "main" ] | |
schedule: | |
- cron: '0 0 * * 1' | |
jobs: | |
check: | |
outputs: | |
release: ${{ steps.early.outputs.release }} | |
runs-on: ubuntu-latest | |
steps: | |
- id: early | |
name: New version check | |
run: | | |
OTEL_LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/open-telemetry/opentelemetry-collector-releases/releases/latest) | |
OTEL_LATEST_VERSION=$(echo $OTEL_LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/') | |
INF_LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/leoparente/opentelemetry-infinity/releases/latest) | |
INF_LATEST_VERSION=$(echo $INF_LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/') | |
release='' | |
if [[ $OTEL_LATEST_VERSION != $INF_LATEST_VERSION ]]; then | |
release=$OTEL_LATEST_VERSION | |
fi | |
echo "release=$release" >> $GITHUB_OUTPUT | |
release: | |
runs-on: ubuntu-latest | |
needs: check | |
permissions: | |
packages: write | |
contents: write | |
if: needs.check.outputs.release != '' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download Version | |
env: | |
RELEASE: ${{needs.check.outputs.release}} | |
run: | | |
echo "LAST_TAG=`git tag --sort=committerdate | tail -1`" >> $GITHUB_ENV | |
echo "TAG=$RELEASE" >> $GITHUB_ENV | |
ARTIFACT_VERSION=${RELEASE:1} | |
ARTIFACT="otelcol-contrib_${ARTIFACT_VERSION}_linux_amd64.tar.gz" | |
ARTIFACT_URL="https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/$RELEASE/$ARTIFACT" | |
mkdir .temp/ | |
wget -O .temp/otelcol-contrib.tar.gz $ARTIFACT_URL | |
tar -xvzf .temp/otelcol-contrib.tar.gz -C .temp/ | |
mv .temp/otelcol-contrib runner/ | |
rm -rf .temp/ | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
- name: Build Binary | |
run: make build | |
- name: Unit Tests | |
run: make test | |
- name: Zip files | |
run: | | |
zip -j otlpinf-amd64.zip build/otlpinf | |
zip -j otelcol-contrib-amd64.zip runner/otelcol-contrib | |
- name: Generate release changelog | |
run: | | |
echo "# What's new" > changelog.md | |
git log ${{ env.LAST_TAG }}..HEAD --pretty=format:"$ad- %s [%an]" >> changelog.md | |
sed -i -e "s/- /• /g" changelog.md | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.TAG }} | |
body_path: ./changelog.md | |
files: | | |
otlpinf-amd64.zip | |
otelcol-contrib-amd64.zip | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker release | |
run: make release | |
- name: Push opentelemetry-infinity container | |
run: | | |
docker push -a ghcr.io/leoparente/opentelemetry-infinity |