Go CLI をビルド
GitHub Actions を使って Go の CLI アプリをビルドします。
設定ファイル
.github/workflows
cf.
また、Settings > Actions > General > Workflow permissions で read and write 権限を与えないとResource not accessible by integrationが起きるので注意してください。
name: Go
on:
release:
types: [published]
jobs:
build:
name: build
runs-on: ubuntu-latest
env:
module: easycli
strategy:
matrix:
os: [linux, macOS]
include:
- os: linux
goos: linux
goarch: amd64
suffix: linux_amd64
- os: macOS
goos: darwin
goarch: arm64
suffix: macOS_arm64
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
- name: Build
run: |
cd cmd/${module}
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${module}_${{ github.ref_name }}_${{ matrix.suffix }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./cmd/${{ env.module }}/${{ env.module }}_${{ github.ref_name}}_${{ matrix.suffix }}
asset_name: ${{ env.module }}_${{ github.ref_name}}_${{ matrix.suffix }}
asset_content_type: application/octet-stream