Update build-and-release.yml #14
Workflow file for this run
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: | |
push: | |
tags: | |
- 'v*.*.*' | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: | |
- amd64 | |
- arm64 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21' | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build binary | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf | |
mkdir -p ./build | |
if [ "${{ matrix.arch }}" == "arm64" ]; then | |
CC=aarch64-linux-gnu-gcc go build -o ./build/redfishcli-${{ matrix.arch }} | |
else | |
go build -o ./build/redfishcli-${{ matrix.arch }} | |
fi | |
env: | |
GOARCH: ${{ matrix.arch }} | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: redfishcli-${{ matrix.arch }} | |
path: ./build/redfishcli-${{ matrix.arch }} | |
if-no-files-found: error | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download amd64,arm64 binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: redfishcli-amd64 | |
path: release | |
pattern: redfishcli-* | |
merge-multiple: true | |
- run: ls -R release | |
- name: Create Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ github.ref_name }} | |
run: | | |
gh release create "$tag" \ | |
./release/redfishcli-amd64#redfishcli-amd64 \ | |
./release/redfishcli-arm64#redfishcli-arm64 \ | |
--repo="$GITHUB_REPOSITORY" \ | |
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ | |
--generate-notes |