Skip to content

Merge pull request #247 from BigVan/fix_metrics #47

Merge pull request #247 from BigVan/fix_metrics

Merge pull request #247 from BigVan/fix_metrics #47

Workflow file for this run

name: Release
on:
push:
branches:
- main
tags:
- "v*"
jobs:
build:
name: "Build Release"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
images: [ubuntu_18.04, ubuntu_20.04, ubuntu_22.04, centos_7, centos_8, mcr.microsoft.com/cbl-mariner/base/core_2.0]
platforms: [linux/amd64, linux/arm64]
steps:
- name: Set Release Version
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
releasever=${{ github.ref }}
releasever="${releasever#refs/tags/}"
echo "RELEASE_VERSION=${releasever}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Setup buildx instance
uses: docker/setup-buildx-action@v2
with:
use: true
- name: Build
shell: bash
run: |
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
if [[ -z ${RELEASE_VERSION} ]]; then
git fetch --tags
RELEASE_VERSION=$(git tag --sort=v:refname -l v* | tail -1)
fi
RELEASE_VERSION=${RELEASE_VERSION#v}
echo "RELEASE_VERSION=${RELEASE_VERSION}"
# parse BUILD_IMAGE and OS from IMAGE
BUILD_IMAGE=${IMAGE/_/:}
OS=${BUILD_IMAGE}
if [[ "${BUILD_IMAGE}" =~ "mcr.microsoft.com/cbl-mariner/base/core:" ]]; then
OS="mariner:${BUILD_IMAGE#mcr.microsoft.com/cbl-mariner/base/core:}"
fi
echo "BUILD_IMAGE=${BUILD_IMAGE}"
echo "OS=${OS}"
docker buildx build --build-arg BUILD_IMAGE=${BUILD_IMAGE} --build-arg OS=${OS} --build-arg RELEASE_VERSION=${RELEASE_VERSION} -f .github/workflows/release/Dockerfile --platform=${{ matrix.platforms }} -o releases/ .
# remove unused package
if [[ "${OS}" =~ "ubuntu" ]]; then
rm -f releases/overlaybd-*.rpm
elif [[ "${OS}" =~ "centos" ]]; then
rm -f releases/overlaybd-*.deb
elif [[ "${OS}" =~ "mariner" ]]; then
rm -f releases/overlaybd-*.deb
fi
ls -l releases/
env:
IMAGE: ${{ matrix.images }}
- name: Upload
uses: actions/upload-artifact@v3
with:
name: releases
path: releases/overlaybd-*.*
dev-release:
name: "Development Release"
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download builds and release notes
uses: actions/download-artifact@v3
- name: Display downloaded files
shell: bash
run: ls -l releases
- name: Create Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: |
releases/overlaybd-*.*
release:
name: "Tagged Release"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download builds and release notes
uses: actions/download-artifact@v3
- name: Display downloaded files
shell: bash
run: ls -l releases
- name: Create Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
releases/overlaybd-*.*