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

Commit

Permalink
New Github Workflow (#58)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Pothulapati authored Mar 13, 2020
1 parent 1e08ed0 commit e59c7ce
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 82 deletions.
73 changes: 0 additions & 73 deletions .circleci/config.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Testing
on:
pull_request: {}
push:
tags:
- 'v*.*.*'
paths-ignore:
- '*.md'
- '**/*.md'
branches:
- master
jobs:
go_build_test:
name: Go Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.12
- name: Validate go deps
run: |
make dep
- name: Running go linting and unit tests
run: |
make lint test
docker_build:
name: Docker Build
needs: go_build_test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Docker Build
run: |
make build
release:
name: Docker Push and Release
needs: docker_build
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'v')
steps:
- name: Set env
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF/refs\/tags\//}
- name: Docker Build and Push
run: |
docker login -u ${{ secrets.DOCKER_USER}} -p ${{ secrets.DOCKER_PASS}} && \
make push
- name: Performing a Github release
run: |
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
make release
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ HAS_HELM := $(shell command -v helm;)
IMAGE_NAME ?= deislabs/smi-metrics

GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
ifdef CIRCLE_TAG
IMAGE := ${IMAGE_NAME}:${CIRCLE_TAG}
VERSION := $(shell echo ${CIRCLE_TAG} | cut -c2- )
ifdef RELEASE_VERSION
IMAGE := ${IMAGE_NAME}:${RELEASE_VERSION}
VERSION := $(shell echo ${RELEASE_VERSION} | cut -c2- )
else
IMAGE := ${IMAGE_NAME}:git-${GIT_COMMIT}
endif
Expand Down Expand Up @@ -60,14 +60,14 @@ tmp:

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

.PHONY: release
release: release-bootstrap build-chart
ifndef CIRCLE_TAG
@echo "Missing CIRCLE_TAG, is this being run from circleci?"
ifndef RELEASE_VERSION
@echo "Missing RELEASE_VERSION, is this being run from CI?"
@exit 1
endif
ifndef GITHUB_TOKEN
@echo "Requires a GITHUB_TOKEN with edit permissions for releases."
@exit 1
endif
ghr -u deislabs \
${CIRCLE_TAG} \
${RELEASE_VERSION} \
tmp/smi-metrics-*

.PHONY: push
Expand Down

0 comments on commit e59c7ce

Please sign in to comment.