diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml new file mode 100644 index 0000000..0991ac1 --- /dev/null +++ b/.github/workflows/build-and-release.yml @@ -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/setup@v0.10.2 + with: + versionSpec: '5.x' + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v0.10.2 + 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