Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: refactor build actions #974

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build(Linux packages)

on:
push:
branches:
- master
- refactor-b # temp
tags:
- v*
pull_request:

jobs:
build-linux:
name: Build (Unix-like OSes)
uses: ./.github/workflows/go-build.yml
with:
os-version: ubuntu-latest
run: |
sudo apt-get update
sudo apt-get install -y devscripts debhelper fakeroot binutils-mips-linux-gnu binutils-aarch64-linux-gnu binutils-arm-linux-gnueabihf
docker pull mackerel/docker-mackerel-rpm-builder:c7
make rpm deb rpm-kcps deb-kcps rpm-stage deb-stage tgz
make crossbuild
upload-artifact-path: |
rpmbuild/RPMS/*/*.rpm
packaging/*.deb
snapshot/*.zip
snapshot/*.tar.gz
build/*.tar.gz
build-windows-x64:
Copy link
Member

@ne-sachirou ne-sachirou Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jobs build-windows-x64 and build-windows-x86 seem to differ from what build-linux.yml shows.

name: Build (64bit Windows)
uses: ./.github/workflows/go-build.yml
with:
os-version: windows-2022
architecture: amd64
with-cgo: true
run: |
commit=$(git rev-parse --short HEAD)
mkdir build/
go build -o build/mackerel-agent.exe -ldflags="-X main.gitcommit=$commit" github.com/mackerelio/mackerel-agent
go build -o build/mackerel-agent-kcps.exe -ldflags="-X main.gitcommit=$commit -X github.com/mackerelio/mackerel-agent/config.apibase=http://198.18.0.16" github.com/mackerelio/mackerel-agent

cd wix
for p in $(./pluginlist.sh)
do
name=$(basename "$p")
go build -o "../build/$name.exe" "$p"
done
go build -o ../build/wrapper.exe wrapper/wrapper_windows.go wrapper/install.go
go build -o ../build/replace.exe replace/replace_windows.go replace/shell_windows.go
go build -o ../build/generate_wxs.exe generate_wxs/generate_wxs.go
upload-artifact-name: windows-build-artifacts-x64
upload-artifact-path: build/
build-windows-x86:
name: Build (32bit Windows)
uses: ./.github/workflows/go-build.yml
with:
os-version: windows-2022
architecture: '386'
with-cgo: true
run: |
commit=$(git rev-parse --short HEAD)
mkdir build/
go build -o build/mackerel-agent.exe -ldflags="-X main.gitcommit=$commit" github.com/mackerelio/mackerel-agent
go build -o build/mackerel-agent-kcps.exe -ldflags="-X main.gitcommit=$commit -X github.com/mackerelio/mackerel-agent/config.apibase=http://198.18.0.16" github.com/mackerelio/mackerel-agent

cd wix
for p in $(./pluginlist.sh)
do
name=$(basename "$p")
go build -o "../build/$name.exe" "$p"
done
go build -o ../build/wrapper.exe wrapper/wrapper_windows.go wrapper/install.go
go build -o ../build/replace.exe replace/replace_windows.go replace/shell_windows.go
go build -o ../build/generate_wxs.exe generate_wxs/generate_wxs.go
upload-artifact-name: windows-build-artifacts-x86
upload-artifact-path: build/
99 changes: 99 additions & 0 deletions .github/workflows/go-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Build(Go)
run-name: Build (${{ inputs.os-version }}/${{ inputs.go-version }})

on:
workflow_call:
inputs:
os-version:
description: 'GitHub-hosted runnners'
default: ubuntu-22.04
required: false
type: string
go-version:
description: 'target Go versions'
default: 1.22.x
required: false
type: string
architecture:
description: 'Target architecture for Go to use (GOARCH)'
default: ''
required: false
type: string
platform:
description: 'Target operating system for Go to use (GOOS)'
default: ''
required: false
type: string
with-cgo:
description: 'xx (CGO_ENABLED)'
default: false
type: boolean
run:
description: 'The commands to run in bash'
default: go build
required: false
type: string
upload-artifact-path:
description: >
A file, directory or wildcard pattern that describes what to upload.
If empty, the workflow will upload no artifacts.
default: ''
required: false
type: string
upload-artifact-name:
description: 'Artifact name'
default: artifact
required: false
type: string

env:
DEBIAN_FRONTEND: noninteractive
jobs:
run:
runs-on: ${{ inputs.os-version }}
env:
CGO_ENABLED: ${{ inputs.with-cgo && 1 || 0 }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
cache: true
- name: Setup environment variables
id: spec
run: |
GOHOSTARCH="$(go env GOHOSTARCH)"
GOARCH="${INPUT_ARCHITECTURE:-$GOHOSTARCH}"
echo "GOARCH=$GOARCH" >>"$GITHUB_ENV"

GOHOSTOS="$(go env GOHOSTOS)"
GOOS="${INPUT_PLATFORM:-$GOHOSTOS}"
echo "GOOS=$GOOS" >>"$GITHUB_ENV"

if [[ $GOHOSTOS = windows && $CGO_ENABLED = 1 ]]
then
case "$GOARCH" in
*64)
echo 'MSYS=MINGW64' >>"$GITHUB_ENV" ;;
*)
echo 'MSYS=MINGW32' >>"$GITHUB_ENV" ;;
esac
fi
shell: bash
- if: env.MSYS != ''
uses: msys2/setup-msys2@v2
with:
msystem: ${{ env.MSYS }}
path-type: inherit
install: mingw-w64-i686-gcc
- if: env.MSYS == ''
run: ${{ inputs.run }}
shell: bash
- if: env.MSYS != ''
run: ${{ inputs.run }}
shell: msys2 {0}
- if: inputs.upload-artifact-path != ''
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.upload-artifact-name }}
path: ${{ inputs.upload-artifact-path }}
2 changes: 1 addition & 1 deletion spec/freebsd/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ type InterfaceGenerator struct {
// Generate XXX
func (g *InterfaceGenerator) Generate() ([]mkr.Interface, error) {
// TODO
return []mkr.any, nil
return []mkr.Interface(nil), nil
}
2 changes: 1 addition & 1 deletion spec/netbsd/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ type InterfaceGenerator struct {
// Generate XXX
func (g *InterfaceGenerator) Generate() ([]mkr.Interface, error) {
// TODO
return []mkr.any, nil
return []mkr.Interface(nil), nil
}
Loading