Add GitHub Action for building and releasing #1
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: Build and Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_version: | ||
description: 'Release version (leave empty for GitVersion)' | ||
required: false | ||
type: string | ||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Docker | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
versionSpec: '5.x' | ||
- name: Determine Version | ||
id: gitversion | ||
uses: gittools/actions/gitversion/[email protected] | ||
if: inputs.release_version == '' | ||
- name: Set version | ||
id: set_version | ||
run: | | ||
if [ -n "${{ inputs.release_version }}" ]; then | ||
echo "version=${{ inputs.release_version }}" >> $GITHUB_OUTPUT | ||
else | ||
echo "version=${{ steps.gitversion.outputs.semVer }}" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Build | ||
run: | | ||
cd Redfish | ||
make | ||
- name: Store artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: redfish-${{ steps.set_version.outputs.version }} | ||
path: Redfish/build/ | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: v${{ steps.set_version.outputs.version }} | ||
release_name: Release ${{ steps.set_version.outputs.version }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./Redfish/build/redfish | ||
asset_name: redfish-${{ steps.set_version.outputs.version }} | ||
asset_content_type: application/octet-stream |