Merge pull request #292 from salvete/main #86
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 | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
env: | |
GO_VERSION: "1.22.0" | |
jobs: | |
build: | |
name: Build Release | |
runs-on: ubuntu-latest | |
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@v4 | |
with: | |
fetch-depth: 100 | |
- 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) #v1.1.3 | |
version="${RELEASE_VERSION#v}" | |
IFS='.' read -ra version_parts <<< "$version" | |
major_version=${version_parts[0]} | |
minor_version=${version_parts[1]} | |
patch_version=${version_parts[2]} | |
((patch_version++)) | |
new_version="$major_version.$minor_version.$patch_version" | |
RELEASE_VERSION="${new_version}rc" #1.1.4rc | |
fi | |
echo "RELEASE_VERSION=${RELEASE_VERSION}" | |
RELEASE_NUM="$(date +%Y%m%d%H%M%S).$(git rev-parse --short HEAD)" | |
docker buildx build --build-arg RELEASE_NUM=${RELEASE_NUM} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --build-arg GO_VERSION=${{ env.GO_VERSION }} -f .github/workflows/release/Dockerfile --platform=linux/amd64,linux/arm64 -o releases/ . | |
ls -l releases/*/ | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: releases | |
path: releases/*/overlaybd-snapshotter* | |
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-snapshotter* | |
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-snapshotter* |