Build and Release #7
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@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v1 | |
with: | |
versionSpec: '5.x' | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v1 | |
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: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Build | |
run: | | |
cd redfish-exporter | |
# Generate API | |
cd api | |
make | |
cd .. | |
# Main build | |
go mod tidy | |
go mod verify | |
make | |
working-directory: ${{ github.workspace }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: redfish-exporter-${{ steps.set_version.outputs.version }} | |
path: redfish-exporter/amd-redfish-exporter | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ steps.set_version.outputs.version }} | |
name: Release ${{ steps.set_version.outputs.version }} | |
draft: false | |
prerelease: false | |
files: | | |
./redfish-exporter/amd-redfish-exporter | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |