Skip to content

Add GitHub Action for building and releasing #1

Add GitHub Action for building and releasing

Add GitHub Action for building and releasing #1

name: Build and Release
on:

Check failure on line 3 in .github/workflows/build-and-release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-and-release.yml

Invalid workflow file

You have an error in your yaml syntax on line 3
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