-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): Binaries creation in release workflow (#150)
* fix: update version on sedge * feat: add instructions for docker buildx * fix: fix build using buildx * feat: add workflow for macos on release pipeline * fix: remove darwin upload from github * fix: delete unused workflow * fix: rename github action * ci: Add script to generate darwin binaries * ci: Rename script that builds the linux binaries and move Dockerfile * ci: Rename ci.yml workflow to build.yml * fix(ci): Dependencies between jobs in release workflow * ci: Install docker buildx in release workflow * fix: update load path for docker buildx * fix: create build folder if doesn't exist Co-authored-by: AntiD2ta <[email protected]> Co-authored-by: Miguel Tenorio <[email protected]>
- Loading branch information
1 parent
7d5dbea
commit 22df40a
Showing
6 changed files
with
137 additions
and
132 deletions.
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 |
---|---|---|
@@ -1,72 +1,38 @@ | ||
name: 'Release Sedge' | ||
name: sedge CI | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'The version number (e.g: 0.1.2) of the release you want to push' | ||
required: true | ||
default: 'master' | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
on: | ||
push: | ||
branches: [ main, develop ] | ||
pull_request: | ||
branches: [ main, develop ] | ||
|
||
jobs: | ||
build-sedge: | ||
build: | ||
name: Build sedge | ||
runs-on: ubuntu-latest | ||
env: | ||
VERSION: v${{ github.event.inputs.tag }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.18.3' | ||
- run: chmod +x ./scripts/build-go-binaries.sh && ./scripts/build-go-binaries.sh | ||
- uses: actions/upload-artifact@master | ||
name: Uploading sedge darwin amd64 package | ||
with: | ||
name: sedge-${{env.VERSION}}-darwin-amd64 | ||
path: build/sedge-${{env.VERSION}}-darwin-amd64 | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/upload-artifact@master | ||
name: Uploading sedge darwin arm64 package | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
name: sedge-${{env.VERSION}}-darwin-arm64 | ||
path: build/sedge-${{env.VERSION}}-darwin-arm64 | ||
go-version: '1.18.2' | ||
|
||
- uses: actions/upload-artifact@master | ||
name: Uploading sedge linux amd64 package | ||
with: | ||
name: sedge-${{env.VERSION}}-linux-amd64 | ||
path: build/sedge-${{env.VERSION}}-linux-amd64 | ||
|
||
- uses: actions/upload-artifact@master | ||
name: Uploading sedge linux arm64 package | ||
with: | ||
name: sedge-${{env.VERSION}}-linux-arm64 | ||
path: build/sedge-${{env.VERSION}}-linux-arm64 | ||
- name: Check Format | ||
run: make format-check | ||
|
||
publish-github: | ||
name: "Release and upload binaries to github" | ||
runs-on: ubuntu-latest | ||
env: | ||
VERSION: v${{ github.event.inputs.tag }} | ||
needs: build-sedge | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Download packages | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: /tmp/binaries | ||
- name: Upload release to Github Releases | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: "/tmp/binaries/sedge-v*/*" | ||
bodyFile: "CHANGELOG.md" | ||
draft: true | ||
tag: v${{ github.event.inputs.tag }} | ||
name: v${{ github.event.inputs.tag }} | ||
- name: Check go mod status | ||
run: | | ||
make gomod_tidy | ||
if [[ ! -z $(git status -s) ]] | ||
then | ||
echo "Go mod - state is not clean:" | ||
git status -s | ||
git diff "$GITHUB_SHA" | ||
exit 1 | ||
fi | ||
- name: Check build | ||
run: make compile |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM --platform=$BUILDPLATFORM golang:1.18.3 AS build | ||
WORKDIR /src | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
ARG LDFLAGS | ||
ARG OUTPUT_NAME | ||
ARG PACKAGE | ||
COPY . ./ | ||
RUN go mod download | ||
RUN if [ "$TARGETARCH" = "arm64" ] ; \ | ||
then apt update && apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y && \ | ||
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "${LDFLAGS}" -o /src/sedge $PACKAGE ; \ | ||
else \ | ||
CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "${LDFLAGS}" -o /src/sedge $PACKAGE; \ | ||
fi | ||
|
||
FROM golang:1.18.3 | ||
COPY --from=build /src/sedge /sedge |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
package=cmd/sedge/main.go | ||
package_name=sedge | ||
|
||
mkdir -p build | ||
|
||
platforms=("linux/amd64" "linux/arm64") | ||
|
||
for platform in "${platforms[@]}" | ||
do | ||
platform_split=(${platform//\// }) | ||
GOOS=${platform_split[0]} | ||
GOARCH=${platform_split[1]} | ||
output_name=$package_name'-v'$VERSION'-'$GOOS'-'$GOARCH | ||
|
||
LDFLAGS="-X github.com/NethermindEth/sedge/internal/utils.Version=v${VERSION}" | ||
|
||
docker buildx build --platform="$GOOS"/"$GOARCH" -t nethermindeth/sedge:"$VERSION"-"$GOOS"-"$GOARCH" --build-arg TARGETOS="$GOOS" --build-arg TARGETARCH="$GOARCH" --build-arg LDFLAGS="$LDFLAGS" --build-arg OUTPUT_NAME="$output_name" --build-arg PACKAGE="$package" --load . -f scripts/Dockerfile | ||
docker create --name sedge nethermindeth/sedge:"$VERSION"-"$GOOS"-"$GOARCH" | ||
docker cp sedge:/sedge ./build/"$output_name" | ||
docker rm -f sedge | ||
|
||
if [ $? -ne 0 ]; then | ||
echo 'An error has occurred! Aborting the script execution...' | ||
exit 1 | ||
fi | ||
echo "Generated ${output_name} file" | ||
done |