2021-11-19 12:42:53 +00:00
name : Build
on :
pull_request :
branches :
- master
types : [ opened, synchronize]
paths-ignore :
- 'scripts/**'
- '**/*.md'
2022-07-20 10:36:00 +00:00
push :
# Build for the master branch.
branches :
- master
release :
# Publish released commit as Docker `latest` and `git_revision` images.
types :
- published
2021-11-19 12:42:53 +00:00
workflow_dispatch :
2021-12-03 09:22:48 +00:00
inputs :
ref :
description: 'Ref to build CLI for Ubuntu and Windows Server Core [default: latest master; examples : v0.92.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]'
required : false
default : ''
2022-07-20 10:36:00 +00:00
push_image :
description: 'Push images to DockerHub [default: false; examples : true , false ] '
required : false
default : 'false'
use_latest_tag :
description: 'Use `latest` tag while pushing images to DockerHub (applied to Ubuntu image only) [default: false; examples : true , false ] '
required : false
default : 'false'
2021-11-19 12:42:53 +00:00
jobs :
2022-07-15 10:55:18 +00:00
build_cli :
name : Build CLI
2022-10-06 04:16:50 +00:00
runs-on : ${{matrix.os.name}}
2022-07-15 10:55:18 +00:00
strategy :
matrix :
2022-10-06 04:16:50 +00:00
os : [ { name: ubuntu-20.04, bin-name : linux }, { name: windows-2022, bin-name: windows }, { name: macos-12, bin-name: darwin }]
2022-07-15 10:56:08 +00:00
arch : [ amd64, arm64]
exclude :
2022-10-06 04:16:50 +00:00
- os : { name: windows-2022, bin-name : windows }
2022-07-15 10:56:08 +00:00
arch : 'arm64'
2021-11-19 12:42:53 +00:00
steps :
2024-02-19 19:13:17 +00:00
- uses : actions/checkout@v4
2021-11-19 12:42:53 +00:00
with :
2021-12-03 09:22:48 +00:00
ref : ${{ github.event.inputs.ref }}
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
2021-11-19 12:42:53 +00:00
fetch-depth : 0
- name : Set up Go
2024-02-19 19:13:17 +00:00
uses : actions/setup-go@v5
2021-11-19 12:42:53 +00:00
with :
2023-10-11 08:34:42 +00:00
go-version : '1.21'
2022-07-20 16:19:51 +00:00
cache : true
2021-11-19 12:42:53 +00:00
- name : Build CLI
run : make build
2022-07-15 10:56:08 +00:00
env :
GOARCH : ${{ matrix.arch }}
2021-11-19 12:42:53 +00:00
2022-10-06 04:16:50 +00:00
- name : Rename CLI binary
run : mv ./bin/neo-go* ./bin/neo-go-${{ matrix.os.bin-name }}-${{ matrix.arch }}${{ (matrix.os.bin-name == 'windows' && '.exe') || '' }}
2021-12-03 08:41:15 +00:00
- name : Upload artifact
2024-02-19 19:13:17 +00:00
uses : actions/upload-artifact@v4
2021-12-03 08:41:15 +00:00
with :
2022-10-06 04:16:50 +00:00
name : neo-go-${{ matrix.os.bin-name }}-${{ matrix.arch }}
2022-07-15 10:55:18 +00:00
path : ./bin/neo-go*
2021-12-03 08:41:15 +00:00
if-no-files-found : error
2023-05-10 15:55:03 +00:00
- name : Attach binary to the release as an asset
if : ${{ github.event_name == 'release' }}
run : gh release upload ${{ github.event.release.tag_name }} ./bin/neo-go-${{ matrix.os.bin-name }}-${{ matrix.arch }}${{ (matrix.os.bin-name == 'windows' && '.exe') || '' }}
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2022-07-15 10:55:18 +00:00
build_image :
needs : build_cli
2022-07-20 10:36:00 +00:00
name : Build and push docker image
2022-07-18 16:14:42 +00:00
runs-on : ubuntu-20.04
steps :
2024-02-19 19:13:17 +00:00
- uses : actions/checkout@v4
2022-07-18 16:14:42 +00:00
with :
ref : ${{ github.event.inputs.ref }}
fetch-depth : 0
- name : Set up QEMU
2024-02-19 19:13:17 +00:00
uses : docker/setup-qemu-action@v3
2022-07-18 16:14:42 +00:00
- name : Set up Docker Buildx
2024-02-19 19:13:17 +00:00
uses : docker/setup-buildx-action@v3
2022-07-18 16:14:42 +00:00
2022-07-20 10:36:00 +00:00
- name : Login to DockerHub
2022-07-21 12:32:00 +00:00
if : ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
2024-02-19 19:13:17 +00:00
uses : docker/login-action@v3
2022-07-20 10:36:00 +00:00
with :
username : ${{ secrets.DOCKERHUB_USERNAME }}
password : ${{ secrets.DOCKERHUB_PASSWORD }}
2022-07-18 16:14:42 +00:00
- name : Set vars
id : setvars
2022-11-14 09:37:06 +00:00
run : make gh-docker-vars >> $GITHUB_OUTPUT
2022-07-18 16:14:42 +00:00
2022-07-20 10:36:00 +00:00
- name : Set latest tag
id : setlatest
2022-11-14 09:37:41 +00:00
if : ${{ (github.event_name == 'release' && github.event.release.target_commitish == 'master') || (github.event_name == 'workflow_dispatch' && github.event.inputs.use_latest_tag == 'true') }}
2022-11-14 09:37:06 +00:00
run : echo "latest=,${{ steps.setvars.outputs.repo }}:latest" >> $GITHUB_OUTPUT
2022-07-20 10:36:00 +00:00
2022-07-18 16:14:42 +00:00
- name : Build and push
2024-02-19 19:13:17 +00:00
uses : docker/build-push-action@v5
2022-07-18 16:14:42 +00:00
with :
2022-07-21 13:27:34 +00:00
context : .
2022-07-20 10:36:00 +00:00
push : ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
2022-07-18 16:14:42 +00:00
platforms : linux/amd64,linux/arm64
build-args : |
2022-07-21 14:20:37 +00:00
REPO=github.com/${{ github.repository }}
2022-07-18 16:14:42 +00:00
VERSION=${{ steps.setvars.outputs.version }}
2022-07-20 10:36:00 +00:00
tags : ${{ steps.setvars.outputs.repo }}:${{ steps.setvars.outputs.version }}${{ steps.setvars.outputs.suffix }}${{ steps.setlatest.outputs.latest }}
2022-07-18 16:14:42 +00:00
build_image_wsc :
needs : build_cli
2022-07-20 10:36:00 +00:00
name : Build and push docker image (Windows Server Core)
2022-07-18 16:14:42 +00:00
runs-on : windows-2022
2021-11-19 12:42:53 +00:00
steps :
2024-02-19 19:13:17 +00:00
- uses : actions/checkout@v4
2021-11-19 12:42:53 +00:00
with :
2021-12-03 09:22:48 +00:00
ref : ${{ github.event.inputs.ref }}
2021-11-19 12:42:53 +00:00
fetch-depth : 0
2022-02-22 16:37:27 +00:00
# For proper `deps` make target execution.
- name : Set up Go
2024-02-19 19:13:17 +00:00
uses : actions/setup-go@v5
2022-02-22 16:37:27 +00:00
with :
2023-10-11 08:34:42 +00:00
go-version : '1.21'
2022-07-20 16:19:51 +00:00
cache : true
2022-02-22 16:37:27 +00:00
2022-07-20 10:36:00 +00:00
- name : Login to DockerHub
2022-07-21 12:32:00 +00:00
if : ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
2024-02-19 19:13:17 +00:00
uses : docker/login-action@v3
2022-07-20 10:36:00 +00:00
with :
username : ${{ secrets.DOCKERHUB_USERNAME }}
password : ${{ secrets.DOCKERHUB_PASSWORD }}
2021-11-19 12:42:53 +00:00
- name : Build Docker image
run : make image
2022-07-20 10:36:00 +00:00
- name : Push image to registry
if : ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
run : make image-push