forked from TrueCloudLab/neoneo-go
.github: add job to publish image for WSC
Also, remove Go setup from publishing jobs because we don't need Go on runner.
This commit is contained in:
parent
d2d75b8ba5
commit
5ef9f4498e
2 changed files with 92 additions and 24 deletions
106
.github/workflows/publish_to_dockerhub.yml
vendored
106
.github/workflows/publish_to_dockerhub.yml
vendored
|
@ -15,11 +15,11 @@ on:
|
|||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
description: 'Ref to build Docker image [default: latest master; examples: v0.92.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]'
|
||||
description: 'Ref to build Docker images for Ubuntu and Windows Server Core [default: latest master; examples: v0.92.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]'
|
||||
required: false
|
||||
default: ''
|
||||
push_image:
|
||||
description: 'Push image to DockerHub [default: false; examples: true, false]'
|
||||
description: 'Push images to DockerHub [default: false; examples: true, false]'
|
||||
required: false
|
||||
default: 'false'
|
||||
|
||||
|
@ -29,8 +29,8 @@ env:
|
|||
|
||||
# A workflow run.
|
||||
jobs:
|
||||
test:
|
||||
name: Run tests before publishing
|
||||
tests_ubuntu:
|
||||
name: Run Ubuntu-based tests before publishing
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
|
@ -70,10 +70,10 @@ jobs:
|
|||
|
||||
- name: Run tests
|
||||
run: make test
|
||||
publish:
|
||||
publish_ubuntu:
|
||||
# Ensure test job passes before pushing image.
|
||||
needs: test
|
||||
name: Publish image to DockerHub
|
||||
needs: tests_ubuntu
|
||||
name: Publish Ubuntu-based image to DockerHub
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout (manual run)
|
||||
|
@ -91,20 +91,6 @@ jobs:
|
|||
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
|
||||
- name: Restore go modules from cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /home/runner/go/pkg/mod
|
||||
key: deps-${{ hashFiles('go.sum') }}
|
||||
|
||||
- name: Update Go modules
|
||||
run: go mod download -json
|
||||
|
||||
- name: Build image
|
||||
run: make image
|
||||
|
||||
|
@ -125,3 +111,81 @@ jobs:
|
|||
- name: Push image with 'latest' tag to registry
|
||||
if: ${{ github.event_name == 'release' && github.event.release.target_commitish == 'master' }}
|
||||
run: make image-push-latest
|
||||
|
||||
tests_wsc:
|
||||
name: Run WindowsServerCore-based tests before publishing
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
- name: Checkout (manual run)
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.inputs.ref }}
|
||||
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout (automatical run)
|
||||
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Sync VM submodule
|
||||
run: |
|
||||
git submodule sync
|
||||
git submodule update --init
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
|
||||
- name: Restore go modules from cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /home/runner/go/pkg/mod
|
||||
key: deps-${{ hashFiles('go.sum') }}
|
||||
|
||||
- name: Update Go modules
|
||||
run: go mod download -json
|
||||
|
||||
- name: Run tests
|
||||
run: make test
|
||||
publish_wsc:
|
||||
# Ensure test job passes before pushing image.
|
||||
# TODO: currently test_wsc job is failing, so we have `always()` condition.
|
||||
# After #2269 and #2268 this condition should be removed.
|
||||
if: ${{ always() }}
|
||||
needs: tests_wsc
|
||||
name: Publish WindowsServerCore-based image to DockerHub
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Checkout (manual run)
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.inputs.ref }}
|
||||
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout (automatical run)
|
||||
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Build image
|
||||
run: make image-wsc
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Push image to registry
|
||||
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
|
||||
run: make image-wsc-push
|
||||
|
|
10
Makefile
10
Makefile
|
@ -18,7 +18,7 @@ IMAGE_REPO=nspccdev/neo-go
|
|||
|
||||
# All of the targets are phony here because we don't really use make dependency
|
||||
# tracking for files
|
||||
.PHONY: build deps image image-wsc image-latest image-push image-push-latest check-version clean-cluster push-tag \
|
||||
.PHONY: build deps image image-wsc image-latest image-push image-wsc-push image-push-latest check-version clean-cluster push-tag \
|
||||
test vet lint fmt cover
|
||||
|
||||
build: deps
|
||||
|
@ -61,11 +61,15 @@ image-latest: deps
|
|||
@docker build -t $(IMAGE_REPO):latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) .
|
||||
|
||||
image-push:
|
||||
@echo "=> Publish image"
|
||||
@echo "=> Publish image for Ubuntu"
|
||||
@docker push $(IMAGE_REPO):$(VERSION)
|
||||
|
||||
image-wsc-push:
|
||||
@echo "=> Publish image for Windows Server Core"
|
||||
@docker push $(IMAGE_REPO):$(VERSION)_WindowsServerCore
|
||||
|
||||
image-push-latest:
|
||||
@echo "=> Publish image with 'latest' tag"
|
||||
@echo "=> Publish image for Ubuntu with 'latest' tag"
|
||||
@docker push $(IMAGE_REPO):latest
|
||||
|
||||
check-version:
|
||||
|
|
Loading…
Reference in a new issue