Skip to content

Commit

Permalink
Make publish (stolostron#33)
Browse files Browse the repository at this point in the history
* tag quay when release/tag created

Signed-off-by: Chris Ahl <[email protected]>

* test on non-main branch

Signed-off-by: Chris Ahl <[email protected]>

* test on fork

Signed-off-by: Chris Ahl <[email protected]>

* change back to main branch after testing in fork

Signed-off-by: Chris Ahl <[email protected]>
  • Loading branch information
chrisahl authored Apr 12, 2022
1 parent 8968c6f commit ccdb978
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright Red Hat

name: Publish

on:
push:
branches: [ main ]

jobs:
publish:
if: github.repository_owner == 'stolostron'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Install Dependencies and Publish
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
run: |
export VERSION="0.0.1-$(date -u +'%Y%m%d-%H-%M-%S')-${GITHUB_SHA::7}-${GITHUB_REF_NAME}"
make publish PUSH_LATEST=true
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright Red Hat

on:
push:
# Sequence of patterns matched against refs/tags
# Has to use not-quite-regex from https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
tags:
- '[0-9]+.[0-9]+.[0-9]+*'

name: Create Release

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Install kubebuilder
run: make envtest-tools

- name: Publish a release tagged image
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
run: |
export VERSION=${GITHUB_REF##*/}
export IMG=quay.io/stolostron/cluster-registration-operator:${GITHUB_REF##*/}
make publish
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ endif


#### BUNDLING AND PUBLISHING ####
.PHONY: publish

## Build and push the operator, bundle, and catalog
publish: docker-login docker-build docker-push
if [[ "${PUSH_LATEST}" = true ]]; then \
echo "Tagging operator image as latest and pushing"; \
$(MAKE) docker-push-latest; \
fi;

.PHONY: docker-login
## Log in to the docker registry for ${BUNDLE_IMG}
Expand All @@ -224,7 +232,7 @@ check: check-copyright
check-copyright:
@build/check-copyright.sh

test: fmt vet manifests envtest-tools
test: fmt vet manifests envtest-tools
@ginkgo -r --cover --coverprofile=cover.out --coverpkg ./... &&\
COVERAGE=`go tool cover -func="cover.out" | grep "total:" | awk '{ print $$3 }' | sed 's/[][()><%]/ /g'` &&\
echo "-------------------------------------------------------------------------" &&\
Expand Down Expand Up @@ -265,14 +273,14 @@ undeploy:

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen yq/install
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..."
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..."
${YQ} e '.metadata.name = "cluster-registration-operator-manager-role"' config/rbac/role.yaml > deploy/cluster-registration-operator/clusterrole.yaml && \
${YQ} e '.metadata.name = "leader-election-operator-role" | .metadata.namespace = "{{ .Namespace }}"' config/rbac/leader_election_role.yaml > deploy/cluster-registration-operator/leader_election_role.yaml

# Generate code
generate: kubebuilder-tools controller-gen register-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# Tag the IMG as latest and docker push
docker-push-latest:
docker tag ${IMG} ${IMAGE_TAG_BASE}:latest
Expand Down

0 comments on commit ccdb978

Please sign in to comment.