mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 05:38:04 +00:00
build: use goreleaser for building cross-compiled binaries and add riscv64 target (#2135)
* build: use goreleaser to cross-compile binaries for all platforms and archs The main motivation behind it is because "gox" is unmaintained and archived and it does not support "linux/riscv64" as a target. Right now, goreleaser is only building the binaries, and I've tried to replicate the exact same way the old script does. In the future, if so desired, goreleaser could be used to further automate the build and release pipeline by creating the release in GitHub. * build: create binaries and OCI image for linux/riscv64
This commit is contained in:
parent
bbdd97482f
commit
c46c1a7128
4
.github/workflows/docker-release.yml
vendored
4
.github/workflows/docker-release.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
|||||||
IMAGE_VERSION=${VERSION:1}
|
IMAGE_VERSION=${VERSION:1}
|
||||||
echo "IMAGE_VERSION: ${IMAGE_VERSION}"
|
echo "IMAGE_VERSION: ${IMAGE_VERSION}"
|
||||||
|
|
||||||
PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64"
|
PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64,linux/riscv64"
|
||||||
|
|
||||||
echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}"
|
echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}"
|
||||||
echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin
|
echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin
|
||||||
@ -60,7 +60,7 @@ jobs:
|
|||||||
-t "${IMAGE_NAME}:4" \
|
-t "${IMAGE_NAME}:4" \
|
||||||
-t "${IMAGE_NAME}:latest" \
|
-t "${IMAGE_NAME}:latest" \
|
||||||
.
|
.
|
||||||
|
|
||||||
cd github-action
|
cd github-action
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \
|
--label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \
|
||||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -40,7 +40,7 @@ jobs:
|
|||||||
- name: Cross compile
|
- name: Cross compile
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install rhash -y
|
sudo apt-get install rhash -y
|
||||||
go install github.com/mitchellh/gox@v1.0.1
|
go install github.com/goreleaser/goreleaser/v2@latest
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cp yq.1 build/yq.1
|
cp yq.1 build/yq.1
|
||||||
./scripts/xcompile.sh
|
./scripts/xcompile.sh
|
||||||
|
46
.goreleaser.yaml
Normal file
46
.goreleaser.yaml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
dist: build
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- id: yq
|
||||||
|
|
||||||
|
binary: yq_{{ .Os }}_{{ .Arch }}
|
||||||
|
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
|
||||||
|
targets:
|
||||||
|
- darwin_amd64
|
||||||
|
- darwin_arm64
|
||||||
|
- freebsd_386
|
||||||
|
- freebsd_amd64
|
||||||
|
- freebsd_arm
|
||||||
|
- linux_386
|
||||||
|
- linux_amd64
|
||||||
|
- linux_arm
|
||||||
|
- linux_arm64
|
||||||
|
- linux_mips
|
||||||
|
- linux_mips64
|
||||||
|
- linux_mips64le
|
||||||
|
- linux_mipsle
|
||||||
|
- linux_ppc64
|
||||||
|
- linux_ppc64le
|
||||||
|
- linux_riscv64
|
||||||
|
- linux_s390x
|
||||||
|
- netbsd_386
|
||||||
|
- netbsd_amd64
|
||||||
|
- netbsd_arm
|
||||||
|
- openbsd_386
|
||||||
|
- openbsd_amd64
|
||||||
|
- windows_386
|
||||||
|
- windows_amd64
|
||||||
|
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
|
||||||
|
release:
|
||||||
|
disable: true
|
||||||
|
skip_upload: true
|
@ -1,11 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
|
||||||
# you may need to go install github.com/mitchellh/gox@v1.0.1 first
|
set -eo pipefail
|
||||||
echo $VERSION
|
|
||||||
CGO_ENABLED=0 gox -ldflags "-s -w ${LDFLAGS}" -output="build/yq_{{.OS}}_{{.Arch}}" --osarch="darwin/amd64 darwin/arm64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm linux/arm64 linux/mips linux/mips64 linux/mips64le linux/mipsle linux/ppc64 linux/ppc64le linux/s390x netbsd/386 netbsd/amd64 netbsd/arm openbsd/386 openbsd/amd64 windows/386 windows/amd64"
|
# You may need to go install github.com/goreleaser/goreleaser/v2@latest first
|
||||||
|
GORELEASER="goreleaser build --clean"
|
||||||
|
if [ -z "$CI" ]; then
|
||||||
|
GORELEASER+=" --snapshot"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$GORELEASER
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
|
|
||||||
|
# Remove artifacts from goreleaser
|
||||||
|
rm artifacts.json config.yaml metadata.json
|
||||||
|
|
||||||
find . -executable -type f | xargs -I {} tar czvf {}.tar.gz {} yq.1 -C ../scripts install-man-page.sh
|
find . -executable -type f | xargs -I {} tar czvf {}.tar.gz {} yq.1 -C ../scripts install-man-page.sh
|
||||||
tar czvf yq_man_page_only.tar.gz yq.1 -C ../scripts install-man-page.sh
|
tar czvf yq_man_page_only.tar.gz yq.1 -C ../scripts install-man-page.sh
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ architectures:
|
|||||||
- build-on: armhf
|
- build-on: armhf
|
||||||
- build-on: amd64
|
- build-on: amd64
|
||||||
- build-on: i386
|
- build-on: i386
|
||||||
|
- build-on: riscv64
|
||||||
apps:
|
apps:
|
||||||
yq:
|
yq:
|
||||||
command: bin/yq
|
command: bin/yq
|
||||||
|
Loading…
Reference in New Issue
Block a user