Skip to content

release

release #5

Workflow file for this run

name: release
on:
release:
types: [published]
permissions:
contents: read
packages: write
jobs:
binary:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-apple-darwin
- os: macos-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: stable
- run: cargo clippy
- run: cargo build --release
- if: matrix.os == 'ubuntu-latest'
run: mv target/release/kitops target/release/kitops-x86_64-unknown-linux-gnu
- if: matrix.os == 'windows-latest'
run: mv target/release/kitops.exe target/release/kitops-x86_64-pc-windows-msvc.exe
- if: matrix.os == 'macos-latest'
run: mv target/release/kitops target/release/kitops-x86_64-apple-darwin
- uses: softprops/action-gh-release@v2
with:
files: target/release/kitops*
image:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Prepare
id: prep
run: |
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
VERSION=sha-${GITHUB_SHA::8}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF/refs\/tags\//}
fi
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_OUTPUT
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Get GitHub Tag
id: get_tag
run: |
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Cache container layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: bittrance
password: ${{ secrets.DOCKER_SECRET }}
- name: Build and push container
uses: docker/build-push-action@v4
with:
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: bittrance/kitops:${{ steps.get_tag.outputs.tag }}
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}