Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit e59c7ce

Browse files
authored
New Github Workflow (#58)
* new workflow * fix make file issue Signed-off-by: Tarun Pothulapati <[email protected]> * remove circleci Signed-off-by: Tarun Pothulapati <[email protected]> * add job dependency Signed-off-by: Tarun Pothulapati <[email protected]> * add release file Signed-off-by: Tarun Pothulapati <[email protected]> * only build at each pr Signed-off-by: Tarun Pothulapati <[email protected]> * update release Signed-off-by: Tarun Pothulapati <[email protected]> * update release workflow to take GITHUB_TOKEN env Signed-off-by: Tarun Pothulapati <[email protected]> * update descriptions of build workflow Signed-off-by: Tarun Pothulapati <[email protected]> * update release workflow Signed-off-by: Tarun Pothulapati <[email protected]> * move to a single workflow Signed-off-by: Tarun Pothulapati <[email protected]> * remove tag build Signed-off-by: Tarun Pothulapati <[email protected]> * check tag for release Signed-off-by: Tarun Pothulapati <[email protected]>
1 parent 1e08ed0 commit e59c7ce

File tree

3 files changed

+63
-82
lines changed

3 files changed

+63
-82
lines changed

.circleci/config.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Testing
2+
on:
3+
pull_request: {}
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
paths-ignore:
8+
- '*.md'
9+
- '**/*.md'
10+
branches:
11+
- master
12+
jobs:
13+
go_build_test:
14+
name: Go Build and Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@master
19+
- name: Setup Go
20+
uses: actions/setup-go@v1
21+
with:
22+
go-version: 1.12
23+
- name: Validate go deps
24+
run: |
25+
make dep
26+
- name: Running go linting and unit tests
27+
run: |
28+
make lint test
29+
docker_build:
30+
name: Docker Build
31+
needs: go_build_test
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@master
36+
- name: Docker Build
37+
run: |
38+
make build
39+
release:
40+
name: Docker Push and Release
41+
needs: docker_build
42+
runs-on: ubuntu-latest
43+
if: github.event_name == 'push' && startsWith(github.ref, 'v')
44+
steps:
45+
- name: Set env
46+
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF/refs\/tags\//}
47+
- name: Docker Build and Push
48+
run: |
49+
docker login -u ${{ secrets.DOCKER_USER}} -p ${{ secrets.DOCKER_PASS}} && \
50+
make push
51+
- name: Performing a Github release
52+
run: |
53+
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
54+
make release

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ HAS_HELM := $(shell command -v helm;)
99
IMAGE_NAME ?= deislabs/smi-metrics
1010

1111
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
12-
ifdef CIRCLE_TAG
13-
IMAGE := ${IMAGE_NAME}:${CIRCLE_TAG}
14-
VERSION := $(shell echo ${CIRCLE_TAG} | cut -c2- )
12+
ifdef RELEASE_VERSION
13+
IMAGE := ${IMAGE_NAME}:${RELEASE_VERSION}
14+
VERSION := $(shell echo ${RELEASE_VERSION} | cut -c2- )
1515
else
1616
IMAGE := ${IMAGE_NAME}:git-${GIT_COMMIT}
1717
endif
@@ -60,14 +60,14 @@ tmp:
6060

6161
.PHONY: build-chart
6262
build-chart: tmp release-bootstrap
63-
ifndef CIRCLE_TAG
64-
@echo "Missing CIRCLE_TAG, is this being run from circleci?"
63+
ifndef RELEASE_VERSION
64+
@echo "Missing RELEASE_VERSION, is this being run from CI?"
6565
@exit 1
6666
endif
6767
cp -R chart tmp/smi-metrics
6868
sed -i.bak 's/CHART_VERSION/${VERSION}/g' tmp/smi-metrics/Chart.yaml
6969
for fname in $$(grep -rnl '$*' tmp/smi-metrics); do \
70-
sed -i.bak 's/VERSION/${CIRCLE_TAG}/g' $$fname; \
70+
sed -i.bak 's/VERSION/${RELEASE_VERSION}/g' $$fname; \
7171
done
7272
helm package tmp/smi-metrics -d tmp --save=false
7373
rm -rf tmp/smi-metrics/
@@ -78,16 +78,16 @@ dev: bootstrap
7878

7979
.PHONY: release
8080
release: release-bootstrap build-chart
81-
ifndef CIRCLE_TAG
82-
@echo "Missing CIRCLE_TAG, is this being run from circleci?"
81+
ifndef RELEASE_VERSION
82+
@echo "Missing RELEASE_VERSION, is this being run from CI?"
8383
@exit 1
8484
endif
8585
ifndef GITHUB_TOKEN
8686
@echo "Requires a GITHUB_TOKEN with edit permissions for releases."
8787
@exit 1
8888
endif
8989
ghr -u deislabs \
90-
${CIRCLE_TAG} \
90+
${RELEASE_VERSION} \
9191
tmp/smi-metrics-*
9292

9393
.PHONY: push

0 commit comments

Comments
 (0)