Skip to content

Modify go.yml and release.yml for GitHub Actions (#32) #142

Modify go.yml and release.yml for GitHub Actions (#32)

Modify go.yml and release.yml for GitHub Actions (#32) #142

Workflow file for this run

name: build
on: [ push, pull_request ]
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
# https://docs.github.com/ja/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-latest, macos-11, macos-12, macos-13, macos-latest, windows-2019, windows-2022, windows-latest ]
go: [ '1.21' ]
steps:
- name: Setup go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
cache: false
go-version: ${{ matrix.go }}
check-latest: true
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- run: go test
- shell: bash
run: echo "fmcsadmin_version=2.2.0-dev" >> "$GITHUB_ENV"
- run: go build -ldflags "-X main.version=${{ env.fmcsadmin_version }}" fmcsadmin.go
- if: runner.os == 'macOS'
run: make dist && cp -p "dist/fmcsadmin-${{ env.fmcsadmin_version }}-macos/fmcsadmin" .
- if: runner.os == 'Linux' && matrix.os == 'ubuntu-22.04'
run: make build-linux-arm64
- shell: bash
run: echo "goss_commit_hash=7e70e27fd419534b2a208af8eea1747af5658e01" >> "$GITHUB_ENV" # v0.4.0
- if: runner.os == 'macOS' || runner.os == 'Windows'
shell: bash
run: echo "GOSS_USE_ALPHA=1" >> "$GITHUB_ENV"
- if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
curl -L "https://github.com/goss-org/goss/archive/${{ env.goss_commit_hash }}.tar.gz" -o goss.tar.gz
tar xzvf goss.tar.gz
cd "goss-${{ env.goss_commit_hash }}"
make build
cd ..
- if: runner.os == 'Windows'
shell: bash
run: |
curl -L "https://github.com/goss-org/goss/archive/${{ env.goss_commit_hash }}.tar.gz" -o goss.tar.gz
tar xzvf goss.tar.gz
cd "goss-${{ env.goss_commit_hash }}"
go build -o goss-windows-amd64.exe github.com/goss-org/goss/cmd/goss
mkdir release
mv goss-windows-amd64.exe release/
cd ..
- if: runner.os == 'Linux'
run: |
OS=linux "./goss-${{ env.goss_commit_hash }}/release/goss-linux-amd64" --gossfile tests/goss.yaml validate --format documentation
- if: runner.os == 'macOS'
run: |
OS=darwin "./goss-${{ env.goss_commit_hash }}/release/goss-darwin-amd64" --gossfile tests/goss.yaml validate --format documentation
- if: runner.os == 'Windows'
shell: bash
run: |
OS=windows "./goss-${{ env.goss_commit_hash }}/release/goss-windows-amd64.exe" --gossfile tests/goss.yaml validate --format documentation
- run: ./fmcsadmin -v
- if: runner.os == 'Linux' && matrix.os == 'ubuntu-22.04'
name: Set up QEMU
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0
- if: runner.os == 'Linux' && matrix.os == 'ubuntu-22.04'
run: |
docker run --rm --env GOSS_COMMIT_HASH=${{ env.goss_commit_hash }} -i -v /$(pwd):/tmp arm64v8/ubuntu:22.04 bash <<'EOF'
cd /tmp
cp -p ./dist/linux-arm64/fmcsadmin ./fmcsadmin
"./goss-$GOSS_COMMIT_HASH/release/goss-linux-arm64" --gossfile tests/goss.yaml validate --format documentation
./fmcsadmin -v
EOF
# based on: github.com/koron-go/_skeleton/.github/workflows/go.yml