-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Action for building and releasing
- Loading branch information
Daniel Zautner
committed
Oct 16, 2024
1 parent
8725831
commit bb5ffc0
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
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 |