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 :
2022-07-20 16:21:40 +00:00
- uses : actions/checkout@v3
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
2022-07-20 16:19:51 +00:00
uses : actions/setup-go@v3
2021-11-19 12:42:53 +00:00
with :
2022-08-08 10:42:49 +00:00
go-version : 1.19
2022-07-20 16:19:51 +00:00
cache : true
2021-11-19 12:42:53 +00:00
- name : Update Go modules
run : go mod download -json
- 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
uses : actions/upload-artifact@v2
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
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 :
2022-07-20 16:21:40 +00:00
- uses : actions/checkout@v3
2022-07-18 16:14:42 +00:00
with :
ref : ${{ github.event.inputs.ref }}
fetch-depth : 0
- name : Set up QEMU
uses : docker/setup-qemu-action@v2
- name : Set up Docker Buildx
uses : docker/setup-buildx-action@v2
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') }}
2022-07-20 10:36:00 +00:00
uses : docker/login-action@v2
with :
username : ${{ secrets.DOCKERHUB_USERNAME }}
password : ${{ secrets.DOCKERHUB_PASSWORD }}
2022-07-18 16:14:42 +00:00
- name : Set vars
id : setvars
run : make gh-docker-vars
2022-07-20 10:36:00 +00:00
- name : Set latest tag
id : setlatest
if : ${{ (github.event_name == 'release' && github.event.release.target_commitish == 'master') || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true' && github.event.inputs.use_latest_tag == 'true') }}
run : echo "::set-output name=latest::,${{ steps.setvars.outputs.repo }}:latest"
2022-07-18 16:14:42 +00:00
- name : Build and push
uses : docker/build-push-action@v3
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 :
2022-07-20 16:21:40 +00:00
- uses : actions/checkout@v3
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
2022-07-20 16:19:51 +00:00
uses : actions/setup-go@v3
2022-02-22 16:37:27 +00:00
with :
2022-08-08 10:42:49 +00:00
go-version : 1.19
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') }}
2022-07-20 10:36:00 +00:00
uses : docker/login-action@v2
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