-
Notifications
You must be signed in to change notification settings - Fork 90
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
lufia
wants to merge
3
commits into
master
Choose a base branch
from
refactor-b
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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: | ||
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/ |
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
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 }} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
andbuild-windows-x86
seem to differ from whatbuild-linux.yml
shows.