Skip to content

Build Binaries And Release #4

Build Binaries And Release

Build Binaries And Release #4

Workflow file for this run

name: Build Binaries And Release
on:
push:
tags:
- v*.*.*
workflow_dispatch:
inputs:
tag:
description: 'Tag to build'
required: true
log_level:
description: 'Log level'
required: false
default: 'info'
jobs:
createRelease:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Build Changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.changelog }}
releases-matrix:
name: Release Binary
runs-on: ubuntu-latest
needs: [createRelease]
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64, 386]
exclude:
- goarch: arm64
goos: windows
- goarch: 386
goos: darwin
- goarch: 386
goos: windows
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Create VERSION file
run: echo ${{ env.RELEASE_VERSION }} > VERSION
- name: Build And Release
uses: wangyoucao577/[email protected]
env:
CGO_ENABLED: 0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
project_path: "./"
binary_name: opensca-cli
extra_files: README.md config.json db-demo.json VERSION
ldflags: "-s -w -X 'main.version=${{ env.RELEASE_VERSION }}' "
push-docker-images:
name: Push Docker Images
runs-on: ubuntu-latest
needs: [releases-matrix]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
sparse-checkout: docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set VERSION ENV
run: echo VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) >> ${GITHUB_ENV}
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: opensca/opensca-cli:latest, opensca/opensca-cli:${{ env.VERSION }}